aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/processor_throttling.c10
-rw-r--r--drivers/ata/libata-core.c1
-rw-r--r--drivers/ata/sata_mv.c31
-rw-r--r--drivers/atm/iphase.c7
-rw-r--r--drivers/atm/nicstar.c117
-rw-r--r--drivers/atm/nicstar.h12
-rw-r--r--drivers/base/core.c2
-rw-r--r--drivers/base/cpu.c48
-rw-r--r--drivers/base/node.c29
-rw-r--r--drivers/base/topology.c41
-rw-r--r--drivers/block/cryptoloop.c1
-rw-r--r--drivers/bluetooth/hci_usb.c24
-rw-r--r--drivers/bluetooth/hci_usb.h5
-rw-r--r--drivers/char/Kconfig4
-rw-r--r--drivers/char/generic_serial.c1
-rw-r--r--drivers/char/keyboard.c3
-rw-r--r--drivers/char/rio/rioboot.c1
-rw-r--r--drivers/char/rio/riocmd.c1
-rw-r--r--drivers/char/rio/rioctrl.c1
-rw-r--r--drivers/char/rio/rioinit.c1
-rw-r--r--drivers/char/rio/riointr.c1
-rw-r--r--drivers/char/rio/rioparam.c1
-rw-r--r--drivers/char/rio/rioroute.c1
-rw-r--r--drivers/char/rio/riotable.c1
-rw-r--r--drivers/char/rio/riotty.c1
-rw-r--r--drivers/char/snsc.h2
-rw-r--r--drivers/clocksource/Makefile1
-rw-r--r--drivers/clocksource/tcb_clksrc.c302
-rw-r--r--drivers/firewire/fw-device.c3
-rw-r--r--drivers/firewire/fw-transaction.c1
-rw-r--r--drivers/firmware/dcdbas.c5
-rw-r--r--drivers/i2c/busses/Kconfig2
-rw-r--r--drivers/i2c/busses/i2c-pxa.c1
-rw-r--r--drivers/i2c/chips/Kconfig1
-rw-r--r--drivers/i2c/chips/tps65010.c101
-rw-r--r--drivers/i2c/i2c-core.c2
-rw-r--r--drivers/ieee1394/nodemgr.c2
-rw-r--r--drivers/infiniband/core/user_mad.c2
-rw-r--r--drivers/infiniband/hw/amso1100/c2.h1
-rw-r--r--drivers/infiniband/hw/mthca/mthca_dev.h3
-rw-r--r--drivers/infiniband/hw/nes/nes.h1
-rw-r--r--drivers/input/keyboard/Kconfig9
-rw-r--r--drivers/input/keyboard/Makefile1
-rw-r--r--drivers/input/keyboard/corgikbd.c1
-rw-r--r--drivers/input/keyboard/sh_keysc.c280
-rw-r--r--drivers/input/keyboard/spitzkbd.c1
-rw-r--r--drivers/input/serio/hp_sdc_mlc.c2
-rw-r--r--drivers/input/touchscreen/ads7846.c40
-rw-r--r--drivers/input/touchscreen/corgi_ts.c1
-rw-r--r--drivers/leds/Kconfig7
-rw-r--r--drivers/leds/Makefile1
-rw-r--r--drivers/leds/leds-tosa.c132
-rw-r--r--drivers/lguest/lg.h1
-rw-r--r--drivers/macintosh/adb.c2
-rw-r--r--drivers/macintosh/windfarm_smu_sat.c2
-rw-r--r--drivers/media/radio/radio-aimslab.c1
-rw-r--r--drivers/media/video/ir-kbd-i2c.c1
-rw-r--r--drivers/media/video/ov511.c1
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-context.c1
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.c1
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-sysfs.c1
-rw-r--r--drivers/mfd/Kconfig16
-rw-r--r--drivers/mfd/Makefile3
-rw-r--r--drivers/mfd/htc-egpio.c440
-rw-r--r--drivers/mfd/htc-pasic3.c265
-rw-r--r--drivers/mfd/ucb1x00-ts.c1
-rw-r--r--drivers/misc/Kconfig33
-rw-r--r--drivers/misc/Makefile1
-rw-r--r--drivers/misc/atmel_tclib.c161
-rw-r--r--drivers/mtd/nand/Kconfig2
-rw-r--r--drivers/mtd/nand/orion_nand.c2
-rw-r--r--drivers/net/3c527.c2
-rw-r--r--drivers/net/Kconfig2
-rw-r--r--drivers/net/appletalk/cops.c3
-rw-r--r--drivers/net/arm/at91_ether.c4
-rw-r--r--drivers/net/cxgb3/adapter.h1
-rw-r--r--drivers/net/cxgb3/t3cdev.h1
-rw-r--r--drivers/net/hamradio/6pack.c2
-rw-r--r--drivers/net/ibmveth.c1
-rw-r--r--drivers/net/irda/pxaficp_ir.c11
-rw-r--r--drivers/net/netxen/netxen_nic_hdr.h1
-rw-r--r--drivers/net/tg3.c52
-rw-r--r--drivers/net/tg3.h1
-rw-r--r--drivers/net/usb/kaweth.c1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-debugfs.c18
-rw-r--r--drivers/parport/Kconfig2
-rw-r--r--drivers/pci/pci-driver.c9
-rw-r--r--drivers/pci/pci-sysfs.c20
-rw-r--r--drivers/pci/probe.c27
-rw-r--r--drivers/pcmcia/Kconfig1
-rw-r--r--drivers/pcmcia/pxa2xx_cm_x270.c1
-rw-r--r--drivers/rtc/rtc-sh.c296
-rw-r--r--drivers/s390/cio/ccwgroup.c1
-rw-r--r--drivers/s390/cio/qdio.c2
-rw-r--r--drivers/scsi/aacraid/aachba.c1
-rw-r--r--drivers/scsi/aacraid/commctrl.c2
-rw-r--r--drivers/scsi/aacraid/comminit.c1
-rw-r--r--drivers/scsi/aacraid/commsup.c2
-rw-r--r--drivers/scsi/aacraid/dpcsup.c2
-rw-r--r--drivers/scsi/aacraid/linit.c1
-rw-r--r--drivers/scsi/aacraid/rx.c1
-rw-r--r--drivers/scsi/aacraid/sa.c1
-rw-r--r--drivers/scsi/dpt/dpti_i2o.h1
-rw-r--r--drivers/scsi/megaraid/mega_common.h1
-rw-r--r--drivers/scsi/megaraid/megaraid_ioctl.h2
-rw-r--r--drivers/scsi/qla2xxx/qla_def.h2
-rw-r--r--drivers/serial/imx.c111
-rw-r--r--drivers/serial/mcfserial.c1
-rw-r--r--drivers/serial/sh-sci.c7
-rw-r--r--drivers/serial/sh-sci.h60
-rw-r--r--drivers/usb/atm/usbatm.h1
-rw-r--r--drivers/usb/core/hub.c1
-rw-r--r--drivers/usb/gadget/Kconfig4
-rw-r--r--drivers/usb/gadget/atmel_usba_udc.c156
-rw-r--r--drivers/usb/gadget/atmel_usba_udc.h9
-rw-r--r--drivers/usb/host/ehci-hcd.c2
-rw-r--r--drivers/usb/host/ehci-orion.c37
-rw-r--r--drivers/usb/misc/appledisplay.c1
-rw-r--r--drivers/usb/serial/io_ti.c1
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c1
-rw-r--r--drivers/video/pxafb.c1
-rw-r--r--drivers/watchdog/sc1200wdt.c2
122 files changed, 2359 insertions, 697 deletions
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index 1b8e592a8241..0bba3a914e86 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -838,10 +838,10 @@ static int acpi_processor_get_throttling(struct acpi_processor *pr)
838 * Migrate task to the cpu pointed by pr. 838 * Migrate task to the cpu pointed by pr.
839 */ 839 */
840 saved_mask = current->cpus_allowed; 840 saved_mask = current->cpus_allowed;
841 set_cpus_allowed(current, cpumask_of_cpu(pr->id)); 841 set_cpus_allowed_ptr(current, &cpumask_of_cpu(pr->id));
842 ret = pr->throttling.acpi_processor_get_throttling(pr); 842 ret = pr->throttling.acpi_processor_get_throttling(pr);
843 /* restore the previous state */ 843 /* restore the previous state */
844 set_cpus_allowed(current, saved_mask); 844 set_cpus_allowed_ptr(current, &saved_mask);
845 845
846 return ret; 846 return ret;
847} 847}
@@ -1025,7 +1025,7 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
1025 * it can be called only for the cpu pointed by pr. 1025 * it can be called only for the cpu pointed by pr.
1026 */ 1026 */
1027 if (p_throttling->shared_type == DOMAIN_COORD_TYPE_SW_ANY) { 1027 if (p_throttling->shared_type == DOMAIN_COORD_TYPE_SW_ANY) {
1028 set_cpus_allowed(current, cpumask_of_cpu(pr->id)); 1028 set_cpus_allowed_ptr(current, &cpumask_of_cpu(pr->id));
1029 ret = p_throttling->acpi_processor_set_throttling(pr, 1029 ret = p_throttling->acpi_processor_set_throttling(pr,
1030 t_state.target_state); 1030 t_state.target_state);
1031 } else { 1031 } else {
@@ -1056,7 +1056,7 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
1056 continue; 1056 continue;
1057 } 1057 }
1058 t_state.cpu = i; 1058 t_state.cpu = i;
1059 set_cpus_allowed(current, cpumask_of_cpu(i)); 1059 set_cpus_allowed_ptr(current, &cpumask_of_cpu(i));
1060 ret = match_pr->throttling. 1060 ret = match_pr->throttling.
1061 acpi_processor_set_throttling( 1061 acpi_processor_set_throttling(
1062 match_pr, t_state.target_state); 1062 match_pr, t_state.target_state);
@@ -1074,7 +1074,7 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
1074 &t_state); 1074 &t_state);
1075 } 1075 }
1076 /* restore the previous state */ 1076 /* restore the previous state */
1077 set_cpus_allowed(current, saved_mask); 1077 set_cpus_allowed_ptr(current, &saved_mask);
1078 return ret; 1078 return ret;
1079} 1079}
1080 1080
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 733eb94d055e..b0b00af90d0e 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -61,7 +61,6 @@
61#include <scsi/scsi_cmnd.h> 61#include <scsi/scsi_cmnd.h>
62#include <scsi/scsi_host.h> 62#include <scsi/scsi_host.h>
63#include <linux/libata.h> 63#include <linux/libata.h>
64#include <asm/semaphore.h>
65#include <asm/byteorder.h> 64#include <asm/byteorder.h>
66#include <linux/cdrom.h> 65#include <linux/cdrom.h>
67 66
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
index 05ff8c776497..d52ce1188327 100644
--- a/drivers/ata/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -76,6 +76,7 @@
76#include <linux/device.h> 76#include <linux/device.h>
77#include <linux/platform_device.h> 77#include <linux/platform_device.h>
78#include <linux/ata_platform.h> 78#include <linux/ata_platform.h>
79#include <linux/mbus.h>
79#include <scsi/scsi_host.h> 80#include <scsi/scsi_host.h>
80#include <scsi/scsi_cmnd.h> 81#include <scsi/scsi_cmnd.h>
81#include <scsi/scsi_device.h> 82#include <scsi/scsi_device.h>
@@ -370,6 +371,9 @@ enum {
370#define IS_GEN_IIE(hpriv) ((hpriv)->hp_flags & MV_HP_GEN_IIE) 371#define IS_GEN_IIE(hpriv) ((hpriv)->hp_flags & MV_HP_GEN_IIE)
371#define HAS_PCI(host) (!((host)->ports[0]->flags & MV_FLAG_SOC)) 372#define HAS_PCI(host) (!((host)->ports[0]->flags & MV_FLAG_SOC))
372 373
374#define WINDOW_CTRL(i) (0x20030 + ((i) << 4))
375#define WINDOW_BASE(i) (0x20034 + ((i) << 4))
376
373enum { 377enum {
374 /* DMA boundary 0xffff is required by the s/g splitting 378 /* DMA boundary 0xffff is required by the s/g splitting
375 * we need on /length/ in mv_fill-sg(). 379 * we need on /length/ in mv_fill-sg().
@@ -2769,6 +2773,27 @@ static int mv_create_dma_pools(struct mv_host_priv *hpriv, struct device *dev)
2769 return 0; 2773 return 0;
2770} 2774}
2771 2775
2776static void mv_conf_mbus_windows(struct mv_host_priv *hpriv,
2777 struct mbus_dram_target_info *dram)
2778{
2779 int i;
2780
2781 for (i = 0; i < 4; i++) {
2782 writel(0, hpriv->base + WINDOW_CTRL(i));
2783 writel(0, hpriv->base + WINDOW_BASE(i));
2784 }
2785
2786 for (i = 0; i < dram->num_cs; i++) {
2787 struct mbus_dram_window *cs = dram->cs + i;
2788
2789 writel(((cs->size - 1) & 0xffff0000) |
2790 (cs->mbus_attr << 8) |
2791 (dram->mbus_dram_target_id << 4) | 1,
2792 hpriv->base + WINDOW_CTRL(i));
2793 writel(cs->base, hpriv->base + WINDOW_BASE(i));
2794 }
2795}
2796
2772/** 2797/**
2773 * mv_platform_probe - handle a positive probe of an soc Marvell 2798 * mv_platform_probe - handle a positive probe of an soc Marvell
2774 * host 2799 * host
@@ -2823,6 +2848,12 @@ static int mv_platform_probe(struct platform_device *pdev)
2823 res->end - res->start + 1); 2848 res->end - res->start + 1);
2824 hpriv->base -= MV_SATAHC0_REG_BASE; 2849 hpriv->base -= MV_SATAHC0_REG_BASE;
2825 2850
2851 /*
2852 * (Re-)program MBUS remapping windows if we are asked to.
2853 */
2854 if (mv_platform_data->dram != NULL)
2855 mv_conf_mbus_windows(hpriv, mv_platform_data->dram);
2856
2826 rc = mv_create_dma_pools(hpriv, &pdev->dev); 2857 rc = mv_create_dma_pools(hpriv, &pdev->dev);
2827 if (rc) 2858 if (rc)
2828 return rc; 2859 return rc;
diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
index 670c093ed25f..5c28ca7380ff 100644
--- a/drivers/atm/iphase.c
+++ b/drivers/atm/iphase.c
@@ -60,7 +60,8 @@
60#include <asm/uaccess.h> 60#include <asm/uaccess.h>
61#include <asm/string.h> 61#include <asm/string.h>
62#include <asm/byteorder.h> 62#include <asm/byteorder.h>
63#include <linux/vmalloc.h> 63#include <linux/vmalloc.h>
64#include <linux/jiffies.h>
64#include "iphase.h" 65#include "iphase.h"
65#include "suni.h" 66#include "suni.h"
66#define swap(x) (((x & 0xff) << 8) | ((x & 0xff00) >> 8)) 67#define swap(x) (((x & 0xff) << 8) | ((x & 0xff00) >> 8))
@@ -189,7 +190,7 @@ static u16 get_desc (IADEV *dev, struct ia_vcc *iavcc) {
189 int ltimeout; 190 int ltimeout;
190 191
191 ia_hack_tcq (dev); 192 ia_hack_tcq (dev);
192 if(((jiffies - timer)>50)||((dev->ffL.tcq_rd==dev->host_tcq_wr))){ 193 if((time_after(jiffies,timer+50)) || ((dev->ffL.tcq_rd==dev->host_tcq_wr))) {
193 timer = jiffies; 194 timer = jiffies;
194 i=0; 195 i=0;
195 while (i < dev->num_tx_desc) { 196 while (i < dev->num_tx_desc) {
@@ -1225,7 +1226,7 @@ static void rx_intr(struct atm_dev *dev)
1225 iadev->rx_tmp_jif = jiffies; 1226 iadev->rx_tmp_jif = jiffies;
1226 iadev->rxing = 0; 1227 iadev->rxing = 0;
1227 } 1228 }
1228 else if (((jiffies - iadev->rx_tmp_jif) > 50) && 1229 else if ((time_after(jiffies, iadev->rx_tmp_jif + 50)) &&
1229 ((iadev->rx_pkt_cnt - iadev->rx_tmp_cnt) == 0)) { 1230 ((iadev->rx_pkt_cnt - iadev->rx_tmp_cnt) == 0)) {
1230 for (i = 1; i <= iadev->num_rx_desc; i++) 1231 for (i = 1; i <= iadev->num_rx_desc; i++)
1231 free_desc(dev, i); 1232 free_desc(dev, i);
diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
index 0c205b000e8b..38c769f8d2b7 100644
--- a/drivers/atm/nicstar.c
+++ b/drivers/atm/nicstar.c
@@ -125,85 +125,6 @@
125#define ATM_SKB(s) (&(s)->atm) 125#define ATM_SKB(s) (&(s)->atm)
126#endif 126#endif
127 127
128 /* Spinlock debugging stuff */
129#ifdef NS_DEBUG_SPINLOCKS /* See nicstar.h */
130#define ns_grab_int_lock(card,flags) \
131 do { \
132 unsigned long nsdsf, nsdsf2; \
133 local_irq_save(flags); \
134 save_flags(nsdsf); cli();\
135 if (nsdsf & (1<<9)) printk ("nicstar.c: ints %sabled -> enabled.\n", \
136 (flags)&(1<<9)?"en":"dis"); \
137 if (spin_is_locked(&(card)->int_lock) && \
138 (card)->cpu_int == smp_processor_id()) { \
139 printk("nicstar.c: line %d (cpu %d) int_lock already locked at line %d (cpu %d)\n", \
140 __LINE__, smp_processor_id(), (card)->has_int_lock, \
141 (card)->cpu_int); \
142 printk("nicstar.c: ints were %sabled.\n", ((flags)&(1<<9)?"en":"dis")); \
143 } \
144 if (spin_is_locked(&(card)->res_lock) && \
145 (card)->cpu_res == smp_processor_id()) { \
146 printk("nicstar.c: line %d (cpu %d) res_lock locked at line %d (cpu %d)(trying int)\n", \
147 __LINE__, smp_processor_id(), (card)->has_res_lock, \
148 (card)->cpu_res); \
149 printk("nicstar.c: ints were %sabled.\n", ((flags)&(1<<9)?"en":"dis")); \
150 } \
151 spin_lock_irq(&(card)->int_lock); \
152 (card)->has_int_lock = __LINE__; \
153 (card)->cpu_int = smp_processor_id(); \
154 restore_flags(nsdsf); } while (0)
155#define ns_grab_res_lock(card,flags) \
156 do { \
157 unsigned long nsdsf, nsdsf2; \
158 local_irq_save(flags); \
159 save_flags(nsdsf); cli();\
160 if (nsdsf & (1<<9)) printk ("nicstar.c: ints %sabled -> enabled.\n", \
161 (flags)&(1<<9)?"en":"dis"); \
162 if (spin_is_locked(&(card)->res_lock) && \
163 (card)->cpu_res == smp_processor_id()) { \
164 printk("nicstar.c: line %d (cpu %d) res_lock already locked at line %d (cpu %d)\n", \
165 __LINE__, smp_processor_id(), (card)->has_res_lock, \
166 (card)->cpu_res); \
167 printk("nicstar.c: ints were %sabled.\n", ((flags)&(1<<9)?"en":"dis")); \
168 } \
169 spin_lock_irq(&(card)->res_lock); \
170 (card)->has_res_lock = __LINE__; \
171 (card)->cpu_res = smp_processor_id(); \
172 restore_flags(nsdsf); } while (0)
173#define ns_grab_scq_lock(card,scq,flags) \
174 do { \
175 unsigned long nsdsf, nsdsf2; \
176 local_irq_save(flags); \
177 save_flags(nsdsf); cli();\
178 if (nsdsf & (1<<9)) printk ("nicstar.c: ints %sabled -> enabled.\n", \
179 (flags)&(1<<9)?"en":"dis"); \
180 if (spin_is_locked(&(scq)->lock) && \
181 (scq)->cpu_lock == smp_processor_id()) { \
182 printk("nicstar.c: line %d (cpu %d) this scq_lock already locked at line %d (cpu %d)\n", \
183 __LINE__, smp_processor_id(), (scq)->has_lock, \
184 (scq)->cpu_lock); \
185 printk("nicstar.c: ints were %sabled.\n", ((flags)&(1<<9)?"en":"dis")); \
186 } \
187 if (spin_is_locked(&(card)->res_lock) && \
188 (card)->cpu_res == smp_processor_id()) { \
189 printk("nicstar.c: line %d (cpu %d) res_lock locked at line %d (cpu %d)(trying scq)\n", \
190 __LINE__, smp_processor_id(), (card)->has_res_lock, \
191 (card)->cpu_res); \
192 printk("nicstar.c: ints were %sabled.\n", ((flags)&(1<<9)?"en":"dis")); \
193 } \
194 spin_lock_irq(&(scq)->lock); \
195 (scq)->has_lock = __LINE__; \
196 (scq)->cpu_lock = smp_processor_id(); \
197 restore_flags(nsdsf); } while (0)
198#else /* !NS_DEBUG_SPINLOCKS */
199#define ns_grab_int_lock(card,flags) \
200 spin_lock_irqsave(&(card)->int_lock,(flags))
201#define ns_grab_res_lock(card,flags) \
202 spin_lock_irqsave(&(card)->res_lock,(flags))
203#define ns_grab_scq_lock(card,scq,flags) \
204 spin_lock_irqsave(&(scq)->lock,flags)
205#endif /* NS_DEBUG_SPINLOCKS */
206
207 128
208/* Function declarations ******************************************************/ 129/* Function declarations ******************************************************/
209 130
@@ -422,7 +343,7 @@ static u32 ns_read_sram(ns_dev *card, u32 sram_address)
422 sram_address <<= 2; 343 sram_address <<= 2;
423 sram_address &= 0x0007FFFC; /* address must be dword aligned */ 344 sram_address &= 0x0007FFFC; /* address must be dword aligned */
424 sram_address |= 0x50000000; /* SRAM read command */ 345 sram_address |= 0x50000000; /* SRAM read command */
425 ns_grab_res_lock(card, flags); 346 spin_lock_irqsave(&card->res_lock, flags);
426 while (CMD_BUSY(card)); 347 while (CMD_BUSY(card));
427 writel(sram_address, card->membase + CMD); 348 writel(sram_address, card->membase + CMD);
428 while (CMD_BUSY(card)); 349 while (CMD_BUSY(card));
@@ -440,7 +361,7 @@ static void ns_write_sram(ns_dev *card, u32 sram_address, u32 *value, int count)
440 count--; /* count range now is 0..3 instead of 1..4 */ 361 count--; /* count range now is 0..3 instead of 1..4 */
441 c = count; 362 c = count;
442 c <<= 2; /* to use increments of 4 */ 363 c <<= 2; /* to use increments of 4 */
443 ns_grab_res_lock(card, flags); 364 spin_lock_irqsave(&card->res_lock, flags);
444 while (CMD_BUSY(card)); 365 while (CMD_BUSY(card));
445 for (i = 0; i <= c; i += 4) 366 for (i = 0; i <= c; i += 4)
446 writel(*(value++), card->membase + i); 367 writel(*(value++), card->membase + i);
@@ -1166,7 +1087,7 @@ static void push_rxbufs(ns_dev *card, struct sk_buff *skb)
1166 card->lbfqc += 2; 1087 card->lbfqc += 2;
1167 } 1088 }
1168 1089
1169 ns_grab_res_lock(card, flags); 1090 spin_lock_irqsave(&card->res_lock, flags);
1170 1091
1171 while (CMD_BUSY(card)); 1092 while (CMD_BUSY(card));
1172 writel(addr2, card->membase + DR3); 1093 writel(addr2, card->membase + DR3);
@@ -1206,7 +1127,7 @@ static irqreturn_t ns_irq_handler(int irq, void *dev_id)
1206 1127
1207 PRINTK("nicstar%d: NICStAR generated an interrupt\n", card->index); 1128 PRINTK("nicstar%d: NICStAR generated an interrupt\n", card->index);
1208 1129
1209 ns_grab_int_lock(card, flags); 1130 spin_lock_irqsave(&card->int_lock, flags);
1210 1131
1211 stat_r = readl(card->membase + STAT); 1132 stat_r = readl(card->membase + STAT);
1212 1133
@@ -1585,7 +1506,7 @@ static void ns_close(struct atm_vcc *vcc)
1585 unsigned long flags; 1506 unsigned long flags;
1586 1507
1587 addr = NS_RCT + (vcc->vpi << card->vcibits | vcc->vci) * NS_RCT_ENTRY_SIZE; 1508 addr = NS_RCT + (vcc->vpi << card->vcibits | vcc->vci) * NS_RCT_ENTRY_SIZE;
1588 ns_grab_res_lock(card, flags); 1509 spin_lock_irqsave(&card->res_lock, flags);
1589 while(CMD_BUSY(card)); 1510 while(CMD_BUSY(card));
1590 writel(NS_CMD_CLOSE_CONNECTION | addr << 2, card->membase + CMD); 1511 writel(NS_CMD_CLOSE_CONNECTION | addr << 2, card->membase + CMD);
1591 spin_unlock_irqrestore(&card->res_lock, flags); 1512 spin_unlock_irqrestore(&card->res_lock, flags);
@@ -1607,7 +1528,7 @@ static void ns_close(struct atm_vcc *vcc)
1607 NS_SKB(iovb)->iovcnt); 1528 NS_SKB(iovb)->iovcnt);
1608 NS_SKB(iovb)->iovcnt = 0; 1529 NS_SKB(iovb)->iovcnt = 0;
1609 NS_SKB(iovb)->vcc = NULL; 1530 NS_SKB(iovb)->vcc = NULL;
1610 ns_grab_int_lock(card, flags); 1531 spin_lock_irqsave(&card->int_lock, flags);
1611 recycle_iov_buf(card, iovb); 1532 recycle_iov_buf(card, iovb);
1612 spin_unlock_irqrestore(&card->int_lock, flags); 1533 spin_unlock_irqrestore(&card->int_lock, flags);
1613 vc->rx_iov = NULL; 1534 vc->rx_iov = NULL;
@@ -1629,7 +1550,7 @@ static void ns_close(struct atm_vcc *vcc)
1629 1550
1630 for (;;) 1551 for (;;)
1631 { 1552 {
1632 ns_grab_scq_lock(card, scq, flags); 1553 spin_lock_irqsave(&scq->lock, flags);
1633 scqep = scq->next; 1554 scqep = scq->next;
1634 if (scqep == scq->base) 1555 if (scqep == scq->base)
1635 scqep = scq->last; 1556 scqep = scq->last;
@@ -1691,7 +1612,7 @@ static void ns_close(struct atm_vcc *vcc)
1691 unsigned long flags; 1612 unsigned long flags;
1692 scq_info *scq = card->scq0; 1613 scq_info *scq = card->scq0;
1693 1614
1694 ns_grab_scq_lock(card, scq, flags); 1615 spin_lock_irqsave(&scq->lock, flags);
1695 1616
1696 for(i = 0; i < scq->num_entries; i++) { 1617 for(i = 0; i < scq->num_entries; i++) {
1697 if(scq->skb[i] && ATM_SKB(scq->skb[i])->vcc == vcc) { 1618 if(scq->skb[i] && ATM_SKB(scq->skb[i])->vcc == vcc) {
@@ -1892,7 +1813,7 @@ static int push_scqe(ns_dev *card, vc_map *vc, scq_info *scq, ns_scqe *tbd,
1892 u32 data; 1813 u32 data;
1893 int index; 1814 int index;
1894 1815
1895 ns_grab_scq_lock(card, scq, flags); 1816 spin_lock_irqsave(&scq->lock, flags);
1896 while (scq->tail == scq->next) 1817 while (scq->tail == scq->next)
1897 { 1818 {
1898 if (in_interrupt()) { 1819 if (in_interrupt()) {
@@ -1904,7 +1825,7 @@ static int push_scqe(ns_dev *card, vc_map *vc, scq_info *scq, ns_scqe *tbd,
1904 scq->full = 1; 1825 scq->full = 1;
1905 spin_unlock_irqrestore(&scq->lock, flags); 1826 spin_unlock_irqrestore(&scq->lock, flags);
1906 interruptible_sleep_on_timeout(&scq->scqfull_waitq, SCQFULL_TIMEOUT); 1827 interruptible_sleep_on_timeout(&scq->scqfull_waitq, SCQFULL_TIMEOUT);
1907 ns_grab_scq_lock(card, scq, flags); 1828 spin_lock_irqsave(&scq->lock, flags);
1908 1829
1909 if (scq->full) { 1830 if (scq->full) {
1910 spin_unlock_irqrestore(&scq->lock, flags); 1831 spin_unlock_irqrestore(&scq->lock, flags);
@@ -1953,7 +1874,7 @@ static int push_scqe(ns_dev *card, vc_map *vc, scq_info *scq, ns_scqe *tbd,
1953 if (has_run++) break; 1874 if (has_run++) break;
1954 spin_unlock_irqrestore(&scq->lock, flags); 1875 spin_unlock_irqrestore(&scq->lock, flags);
1955 interruptible_sleep_on_timeout(&scq->scqfull_waitq, SCQFULL_TIMEOUT); 1876 interruptible_sleep_on_timeout(&scq->scqfull_waitq, SCQFULL_TIMEOUT);
1956 ns_grab_scq_lock(card, scq, flags); 1877 spin_lock_irqsave(&scq->lock, flags);
1957 } 1878 }
1958 1879
1959 if (!scq->full) 1880 if (!scq->full)
@@ -2090,7 +2011,7 @@ static void drain_scq(ns_dev *card, scq_info *scq, int pos)
2090 return; 2011 return;
2091 } 2012 }
2092 2013
2093 ns_grab_scq_lock(card, scq, flags); 2014 spin_lock_irqsave(&scq->lock, flags);
2094 i = (int) (scq->tail - scq->base); 2015 i = (int) (scq->tail - scq->base);
2095 if (++i == scq->num_entries) 2016 if (++i == scq->num_entries)
2096 i = 0; 2017 i = 0;
@@ -2898,7 +2819,7 @@ static int ns_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
2898 { 2819 {
2899 struct sk_buff *hb; 2820 struct sk_buff *hb;
2900 2821
2901 ns_grab_int_lock(card, flags); 2822 spin_lock_irqsave(&card->int_lock, flags);
2902 hb = skb_dequeue(&card->hbpool.queue); 2823 hb = skb_dequeue(&card->hbpool.queue);
2903 card->hbpool.count--; 2824 card->hbpool.count--;
2904 spin_unlock_irqrestore(&card->int_lock, flags); 2825 spin_unlock_irqrestore(&card->int_lock, flags);
@@ -2917,7 +2838,7 @@ static int ns_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
2917 if (hb == NULL) 2838 if (hb == NULL)
2918 return -ENOMEM; 2839 return -ENOMEM;
2919 NS_SKB_CB(hb)->buf_type = BUF_NONE; 2840 NS_SKB_CB(hb)->buf_type = BUF_NONE;
2920 ns_grab_int_lock(card, flags); 2841 spin_lock_irqsave(&card->int_lock, flags);
2921 skb_queue_tail(&card->hbpool.queue, hb); 2842 skb_queue_tail(&card->hbpool.queue, hb);
2922 card->hbpool.count++; 2843 card->hbpool.count++;
2923 spin_unlock_irqrestore(&card->int_lock, flags); 2844 spin_unlock_irqrestore(&card->int_lock, flags);
@@ -2929,7 +2850,7 @@ static int ns_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
2929 { 2850 {
2930 struct sk_buff *iovb; 2851 struct sk_buff *iovb;
2931 2852
2932 ns_grab_int_lock(card, flags); 2853 spin_lock_irqsave(&card->int_lock, flags);
2933 iovb = skb_dequeue(&card->iovpool.queue); 2854 iovb = skb_dequeue(&card->iovpool.queue);
2934 card->iovpool.count--; 2855 card->iovpool.count--;
2935 spin_unlock_irqrestore(&card->int_lock, flags); 2856 spin_unlock_irqrestore(&card->int_lock, flags);
@@ -2948,7 +2869,7 @@ static int ns_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
2948 if (iovb == NULL) 2869 if (iovb == NULL)
2949 return -ENOMEM; 2870 return -ENOMEM;
2950 NS_SKB_CB(iovb)->buf_type = BUF_NONE; 2871 NS_SKB_CB(iovb)->buf_type = BUF_NONE;
2951 ns_grab_int_lock(card, flags); 2872 spin_lock_irqsave(&card->int_lock, flags);
2952 skb_queue_tail(&card->iovpool.queue, iovb); 2873 skb_queue_tail(&card->iovpool.queue, iovb);
2953 card->iovpool.count++; 2874 card->iovpool.count++;
2954 spin_unlock_irqrestore(&card->int_lock, flags); 2875 spin_unlock_irqrestore(&card->int_lock, flags);
@@ -2995,7 +2916,7 @@ static void ns_poll(unsigned long arg)
2995 /* Probably it isn't worth spinning */ 2916 /* Probably it isn't worth spinning */
2996 continue; 2917 continue;
2997 } 2918 }
2998 ns_grab_int_lock(card, flags); 2919 spin_lock_irqsave(&card->int_lock, flags);
2999 2920
3000 stat_w = 0; 2921 stat_w = 0;
3001 stat_r = readl(card->membase + STAT); 2922 stat_r = readl(card->membase + STAT);
@@ -3062,7 +2983,7 @@ static void ns_phy_put(struct atm_dev *dev, unsigned char value,
3062 unsigned long flags; 2983 unsigned long flags;
3063 2984
3064 card = dev->dev_data; 2985 card = dev->dev_data;
3065 ns_grab_res_lock(card, flags); 2986 spin_lock_irqsave(&card->res_lock, flags);
3066 while(CMD_BUSY(card)); 2987 while(CMD_BUSY(card));
3067 writel((unsigned long) value, card->membase + DR0); 2988 writel((unsigned long) value, card->membase + DR0);
3068 writel(NS_CMD_WRITE_UTILITY | 0x00000200 | (addr & 0x000000FF), 2989 writel(NS_CMD_WRITE_UTILITY | 0x00000200 | (addr & 0x000000FF),
@@ -3079,7 +3000,7 @@ static unsigned char ns_phy_get(struct atm_dev *dev, unsigned long addr)
3079 unsigned long data; 3000 unsigned long data;
3080 3001
3081 card = dev->dev_data; 3002 card = dev->dev_data;
3082 ns_grab_res_lock(card, flags); 3003 spin_lock_irqsave(&card->res_lock, flags);
3083 while(CMD_BUSY(card)); 3004 while(CMD_BUSY(card));
3084 writel(NS_CMD_READ_UTILITY | 0x00000200 | (addr & 0x000000FF), 3005 writel(NS_CMD_READ_UTILITY | 0x00000200 | (addr & 0x000000FF),
3085 card->membase + CMD); 3006 card->membase + CMD);
diff --git a/drivers/atm/nicstar.h b/drivers/atm/nicstar.h
index 5997bcb45b59..6010e3daa6a2 100644
--- a/drivers/atm/nicstar.h
+++ b/drivers/atm/nicstar.h
@@ -28,8 +28,6 @@
28 28
29/* Options ********************************************************************/ 29/* Options ********************************************************************/
30 30
31#undef NS_DEBUG_SPINLOCKS
32
33#define NS_MAX_CARDS 4 /* Maximum number of NICStAR based cards 31#define NS_MAX_CARDS 4 /* Maximum number of NICStAR based cards
34 controlled by the device driver. Must 32 controlled by the device driver. Must
35 be <= 5 */ 33 be <= 5 */
@@ -721,10 +719,6 @@ typedef struct scq_info
721 wait_queue_head_t scqfull_waitq; 719 wait_queue_head_t scqfull_waitq;
722 volatile char full; /* SCQ full indicator */ 720 volatile char full; /* SCQ full indicator */
723 spinlock_t lock; /* SCQ spinlock */ 721 spinlock_t lock; /* SCQ spinlock */
724#ifdef NS_DEBUG_SPINLOCKS
725 volatile long has_lock;
726 volatile int cpu_lock;
727#endif /* NS_DEBUG_SPINLOCKS */
728} scq_info; 722} scq_info;
729 723
730 724
@@ -810,12 +804,6 @@ typedef struct ns_dev
810 unsigned intcnt; /* Interrupt counter */ 804 unsigned intcnt; /* Interrupt counter */
811 spinlock_t int_lock; /* Interrupt lock */ 805 spinlock_t int_lock; /* Interrupt lock */
812 spinlock_t res_lock; /* Card resource lock */ 806 spinlock_t res_lock; /* Card resource lock */
813#ifdef NS_DEBUG_SPINLOCKS
814 volatile long has_int_lock;
815 volatile int cpu_int;
816 volatile long has_res_lock;
817 volatile int cpu_res;
818#endif /* NS_DEBUG_SPINLOCKS */
819} ns_dev; 807} ns_dev;
820 808
821 809
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 0737fe5392a3..9248e0927d08 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -20,7 +20,7 @@
20#include <linux/notifier.h> 20#include <linux/notifier.h>
21#include <linux/genhd.h> 21#include <linux/genhd.h>
22#include <linux/kallsyms.h> 22#include <linux/kallsyms.h>
23#include <asm/semaphore.h> 23#include <linux/semaphore.h>
24 24
25#include "base.h" 25#include "base.h"
26#include "power/power.h" 26#include "power/power.h"
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 3e417a97681d..6fe417429977 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -103,6 +103,51 @@ static SYSDEV_ATTR(crash_notes, 0400, show_crash_notes, NULL);
103#endif 103#endif
104 104
105/* 105/*
106 * Print cpu online, possible, present, and system maps
107 */
108static ssize_t print_cpus_map(char *buf, cpumask_t *map)
109{
110 int n = cpulist_scnprintf(buf, PAGE_SIZE-2, *map);
111
112 buf[n++] = '\n';
113 buf[n] = '\0';
114 return n;
115}
116
117#define print_cpus_func(type) \
118static ssize_t print_cpus_##type(struct sysdev_class *class, char *buf) \
119{ \
120 return print_cpus_map(buf, &cpu_##type##_map); \
121} \
122struct sysdev_class_attribute attr_##type##_map = \
123 _SYSDEV_CLASS_ATTR(type, 0444, print_cpus_##type, NULL)
124
125print_cpus_func(online);
126print_cpus_func(possible);
127print_cpus_func(present);
128
129struct sysdev_class_attribute *cpu_state_attr[] = {
130 &attr_online_map,
131 &attr_possible_map,
132 &attr_present_map,
133};
134
135static int cpu_states_init(void)
136{
137 int i;
138 int err = 0;
139
140 for (i = 0; i < ARRAY_SIZE(cpu_state_attr); i++) {
141 int ret;
142 ret = sysdev_class_create_file(&cpu_sysdev_class,
143 cpu_state_attr[i]);
144 if (!err)
145 err = ret;
146 }
147 return err;
148}
149
150/*
106 * register_cpu - Setup a sysfs device for a CPU. 151 * register_cpu - Setup a sysfs device for a CPU.
107 * @cpu - cpu->hotpluggable field set to 1 will generate a control file in 152 * @cpu - cpu->hotpluggable field set to 1 will generate a control file in
108 * sysfs for this CPU. 153 * sysfs for this CPU.
@@ -147,6 +192,9 @@ int __init cpu_dev_init(void)
147 int err; 192 int err;
148 193
149 err = sysdev_class_register(&cpu_sysdev_class); 194 err = sysdev_class_register(&cpu_sysdev_class);
195 if (!err)
196 err = cpu_states_init();
197
150#if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT) 198#if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT)
151 if (!err) 199 if (!err)
152 err = sched_create_sysfs_power_savings_entries(&cpu_sysdev_class); 200 err = sched_create_sysfs_power_savings_entries(&cpu_sysdev_class);
diff --git a/drivers/base/node.c b/drivers/base/node.c
index e59861f18ce5..12fde2d03d69 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -19,21 +19,34 @@ static struct sysdev_class node_class = {
19}; 19};
20 20
21 21
22static ssize_t node_read_cpumap(struct sys_device * dev, char * buf) 22static ssize_t node_read_cpumap(struct sys_device *dev, int type, char *buf)
23{ 23{
24 struct node *node_dev = to_node(dev); 24 struct node *node_dev = to_node(dev);
25 cpumask_t mask = node_to_cpumask(node_dev->sysdev.id); 25 node_to_cpumask_ptr(mask, node_dev->sysdev.id);
26 int len; 26 int len;
27 27
28 /* 2004/06/03: buf currently PAGE_SIZE, need > 1 char per 4 bits. */ 28 /* 2008/04/07: buf currently PAGE_SIZE, need 9 chars per 32 bits. */
29 BUILD_BUG_ON(MAX_NUMNODES/4 > PAGE_SIZE/2); 29 BUILD_BUG_ON((NR_CPUS/32 * 9) > (PAGE_SIZE-1));
30 30
31 len = cpumask_scnprintf(buf, PAGE_SIZE-1, mask); 31 len = type?
32 len += sprintf(buf + len, "\n"); 32 cpulist_scnprintf(buf, PAGE_SIZE-2, *mask):
33 cpumask_scnprintf(buf, PAGE_SIZE-2, *mask);
34 buf[len++] = '\n';
35 buf[len] = '\0';
33 return len; 36 return len;
34} 37}
35 38
36static SYSDEV_ATTR(cpumap, S_IRUGO, node_read_cpumap, NULL); 39static inline ssize_t node_read_cpumask(struct sys_device *dev, char *buf)
40{
41 return node_read_cpumap(dev, 0, buf);
42}
43static inline ssize_t node_read_cpulist(struct sys_device *dev, char *buf)
44{
45 return node_read_cpumap(dev, 1, buf);
46}
47
48static SYSDEV_ATTR(cpumap, S_IRUGO, node_read_cpumask, NULL);
49static SYSDEV_ATTR(cpulist, S_IRUGO, node_read_cpulist, NULL);
37 50
38#define K(x) ((x) << (PAGE_SHIFT - 10)) 51#define K(x) ((x) << (PAGE_SHIFT - 10))
39static ssize_t node_read_meminfo(struct sys_device * dev, char * buf) 52static ssize_t node_read_meminfo(struct sys_device * dev, char * buf)
@@ -149,6 +162,7 @@ int register_node(struct node *node, int num, struct node *parent)
149 162
150 if (!error){ 163 if (!error){
151 sysdev_create_file(&node->sysdev, &attr_cpumap); 164 sysdev_create_file(&node->sysdev, &attr_cpumap);
165 sysdev_create_file(&node->sysdev, &attr_cpulist);
152 sysdev_create_file(&node->sysdev, &attr_meminfo); 166 sysdev_create_file(&node->sysdev, &attr_meminfo);
153 sysdev_create_file(&node->sysdev, &attr_numastat); 167 sysdev_create_file(&node->sysdev, &attr_numastat);
154 sysdev_create_file(&node->sysdev, &attr_distance); 168 sysdev_create_file(&node->sysdev, &attr_distance);
@@ -166,6 +180,7 @@ int register_node(struct node *node, int num, struct node *parent)
166void unregister_node(struct node *node) 180void unregister_node(struct node *node)
167{ 181{
168 sysdev_remove_file(&node->sysdev, &attr_cpumap); 182 sysdev_remove_file(&node->sysdev, &attr_cpumap);
183 sysdev_remove_file(&node->sysdev, &attr_cpulist);
169 sysdev_remove_file(&node->sysdev, &attr_meminfo); 184 sysdev_remove_file(&node->sysdev, &attr_meminfo);
170 sysdev_remove_file(&node->sysdev, &attr_numastat); 185 sysdev_remove_file(&node->sysdev, &attr_numastat);
171 sysdev_remove_file(&node->sysdev, &attr_distance); 186 sysdev_remove_file(&node->sysdev, &attr_distance);
diff --git a/drivers/base/topology.c b/drivers/base/topology.c
index e1d3ad4db2f0..fdf4044d2e74 100644
--- a/drivers/base/topology.c
+++ b/drivers/base/topology.c
@@ -40,15 +40,38 @@ static ssize_t show_##name(struct sys_device *dev, char *buf) \
40 return sprintf(buf, "%d\n", topology_##name(cpu)); \ 40 return sprintf(buf, "%d\n", topology_##name(cpu)); \
41} 41}
42 42
43#define define_siblings_show_func(name) \ 43static ssize_t show_cpumap(int type, cpumask_t *mask, char *buf)
44static ssize_t show_##name(struct sys_device *dev, char *buf) \ 44{
45 ptrdiff_t len = PTR_ALIGN(buf + PAGE_SIZE - 1, PAGE_SIZE) - buf;
46 int n = 0;
47
48 if (len > 1) {
49 n = type?
50 cpulist_scnprintf(buf, len-2, *mask):
51 cpumask_scnprintf(buf, len-2, *mask);
52 buf[n++] = '\n';
53 buf[n] = '\0';
54 }
55 return n;
56}
57
58#define define_siblings_show_map(name) \
59static inline ssize_t show_##name(struct sys_device *dev, char *buf) \
45{ \ 60{ \
46 ssize_t len = -1; \
47 unsigned int cpu = dev->id; \ 61 unsigned int cpu = dev->id; \
48 len = cpumask_scnprintf(buf, NR_CPUS+1, topology_##name(cpu)); \ 62 return show_cpumap(0, &(topology_##name(cpu)), buf); \
49 return (len + sprintf(buf + len, "\n")); \
50} 63}
51 64
65#define define_siblings_show_list(name) \
66static inline ssize_t show_##name##_list(struct sys_device *dev, char *buf) \
67{ \
68 unsigned int cpu = dev->id; \
69 return show_cpumap(1, &(topology_##name(cpu)), buf); \
70}
71
72#define define_siblings_show_func(name) \
73 define_siblings_show_map(name); define_siblings_show_list(name)
74
52#ifdef topology_physical_package_id 75#ifdef topology_physical_package_id
53define_id_show_func(physical_package_id); 76define_id_show_func(physical_package_id);
54define_one_ro(physical_package_id); 77define_one_ro(physical_package_id);
@@ -68,7 +91,9 @@ define_one_ro(core_id);
68#ifdef topology_thread_siblings 91#ifdef topology_thread_siblings
69define_siblings_show_func(thread_siblings); 92define_siblings_show_func(thread_siblings);
70define_one_ro(thread_siblings); 93define_one_ro(thread_siblings);
71#define ref_thread_siblings_attr &attr_thread_siblings.attr, 94define_one_ro(thread_siblings_list);
95#define ref_thread_siblings_attr \
96 &attr_thread_siblings.attr, &attr_thread_siblings_list.attr,
72#else 97#else
73#define ref_thread_siblings_attr 98#define ref_thread_siblings_attr
74#endif 99#endif
@@ -76,7 +101,9 @@ define_one_ro(thread_siblings);
76#ifdef topology_core_siblings 101#ifdef topology_core_siblings
77define_siblings_show_func(core_siblings); 102define_siblings_show_func(core_siblings);
78define_one_ro(core_siblings); 103define_one_ro(core_siblings);
79#define ref_core_siblings_attr &attr_core_siblings.attr, 104define_one_ro(core_siblings_list);
105#define ref_core_siblings_attr \
106 &attr_core_siblings.attr, &attr_core_siblings_list.attr,
80#else 107#else
81#define ref_core_siblings_attr 108#define ref_core_siblings_attr
82#endif 109#endif
diff --git a/drivers/block/cryptoloop.c b/drivers/block/cryptoloop.c
index 241167878edf..8b6bb764b0a3 100644
--- a/drivers/block/cryptoloop.c
+++ b/drivers/block/cryptoloop.c
@@ -27,7 +27,6 @@
27#include <linux/blkdev.h> 27#include <linux/blkdev.h>
28#include <linux/loop.h> 28#include <linux/loop.h>
29#include <linux/scatterlist.h> 29#include <linux/scatterlist.h>
30#include <asm/semaphore.h>
31#include <asm/uaccess.h> 30#include <asm/uaccess.h>
32 31
33MODULE_LICENSE("GPL"); 32MODULE_LICENSE("GPL");
diff --git a/drivers/bluetooth/hci_usb.c b/drivers/bluetooth/hci_usb.c
index 8b884f87d8b7..192522ebb771 100644
--- a/drivers/bluetooth/hci_usb.c
+++ b/drivers/bluetooth/hci_usb.c
@@ -62,13 +62,13 @@
62#define URB_ZERO_PACKET 0 62#define URB_ZERO_PACKET 0
63#endif 63#endif
64 64
65static int ignore = 0; 65static int ignore;
66static int ignore_dga = 0; 66static int ignore_dga;
67static int ignore_csr = 0; 67static int ignore_csr;
68static int ignore_sniffer = 0; 68static int ignore_sniffer;
69static int disable_scofix = 0; 69static int disable_scofix;
70static int force_scofix = 0; 70static int force_scofix;
71static int reset = 0; 71static int reset;
72 72
73#ifdef CONFIG_BT_HCIUSB_SCO 73#ifdef CONFIG_BT_HCIUSB_SCO
74static int isoc = 2; 74static int isoc = 2;
@@ -265,7 +265,7 @@ static int hci_usb_intr_rx_submit(struct hci_usb *husb)
265 BT_ERR("%s intr rx submit failed urb %p err %d", 265 BT_ERR("%s intr rx submit failed urb %p err %d",
266 husb->hdev->name, urb, err); 266 husb->hdev->name, urb, err);
267 _urb_unlink(_urb); 267 _urb_unlink(_urb);
268 _urb_free(_urb); 268 kfree(_urb);
269 kfree(buf); 269 kfree(buf);
270 } 270 }
271 return err; 271 return err;
@@ -302,7 +302,7 @@ static int hci_usb_bulk_rx_submit(struct hci_usb *husb)
302 BT_ERR("%s bulk rx submit failed urb %p err %d", 302 BT_ERR("%s bulk rx submit failed urb %p err %d",
303 husb->hdev->name, urb, err); 303 husb->hdev->name, urb, err);
304 _urb_unlink(_urb); 304 _urb_unlink(_urb);
305 _urb_free(_urb); 305 kfree(_urb);
306 kfree(buf); 306 kfree(buf);
307 } 307 }
308 return err; 308 return err;
@@ -353,7 +353,7 @@ static int hci_usb_isoc_rx_submit(struct hci_usb *husb)
353 BT_ERR("%s isoc rx submit failed urb %p err %d", 353 BT_ERR("%s isoc rx submit failed urb %p err %d",
354 husb->hdev->name, urb, err); 354 husb->hdev->name, urb, err);
355 _urb_unlink(_urb); 355 _urb_unlink(_urb);
356 _urb_free(_urb); 356 kfree(_urb);
357 kfree(buf); 357 kfree(buf);
358 } 358 }
359 return err; 359 return err;
@@ -431,7 +431,7 @@ static void hci_usb_unlink_urbs(struct hci_usb *husb)
431 husb->hdev->name, _urb, _urb->type, urb); 431 husb->hdev->name, _urb, _urb->type, urb);
432 kfree(urb->setup_packet); 432 kfree(urb->setup_packet);
433 kfree(urb->transfer_buffer); 433 kfree(urb->transfer_buffer);
434 _urb_free(_urb); 434 kfree(_urb);
435 } 435 }
436 } 436 }
437} 437}
@@ -490,7 +490,7 @@ static inline int hci_usb_send_ctrl(struct hci_usb *husb, struct sk_buff *skb)
490 490
491 dr = kmalloc(sizeof(*dr), GFP_ATOMIC); 491 dr = kmalloc(sizeof(*dr), GFP_ATOMIC);
492 if (!dr) { 492 if (!dr) {
493 _urb_free(_urb); 493 kfree(_urb);
494 return -ENOMEM; 494 return -ENOMEM;
495 } 495 }
496 } else 496 } else
diff --git a/drivers/bluetooth/hci_usb.h b/drivers/bluetooth/hci_usb.h
index 56cd3a92ceca..414080a4e8ff 100644
--- a/drivers/bluetooth/hci_usb.h
+++ b/drivers/bluetooth/hci_usb.h
@@ -60,11 +60,6 @@ struct _urb {
60 struct urb urb; 60 struct urb urb;
61}; 61};
62 62
63static inline void _urb_free(struct _urb *_urb)
64{
65 kfree(_urb);
66}
67
68static inline void _urb_queue_init(struct _urb_queue *q) 63static inline void _urb_queue_init(struct _urb_queue *q)
69{ 64{
70 INIT_LIST_HEAD(&q->head); 65 INIT_LIST_HEAD(&q->head);
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 47c6be84fc84..a87b89db08e9 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -706,7 +706,7 @@ config NVRAM
706 706
707config RTC 707config RTC
708 tristate "Enhanced Real Time Clock Support" 708 tristate "Enhanced Real Time Clock Support"
709 depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 709 depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390 && !AVR32
710 ---help--- 710 ---help---
711 If you say Y here and create a character special file /dev/rtc with 711 If you say Y here and create a character special file /dev/rtc with
712 major number 10 and minor number 135 using mknod ("man mknod"), you 712 major number 10 and minor number 135 using mknod ("man mknod"), you
@@ -776,7 +776,7 @@ config SGI_IP27_RTC
776 776
777config GEN_RTC 777config GEN_RTC
778 tristate "Generic /dev/rtc emulation" 778 tristate "Generic /dev/rtc emulation"
779 depends on RTC!=y && !IA64 && !ARM && !M32R && !MIPS && !SPARC && !FRV && !S390 && !SUPERH 779 depends on RTC!=y && !IA64 && !ARM && !M32R && !MIPS && !SPARC && !FRV && !S390 && !SUPERH && !AVR32
780 ---help--- 780 ---help---
781 If you say Y here and create a character special file /dev/rtc with 781 If you say Y here and create a character special file /dev/rtc with
782 major number 10 and minor number 135 using mknod ("man mknod"), you 782 major number 10 and minor number 135 using mknod ("man mknod"), you
diff --git a/drivers/char/generic_serial.c b/drivers/char/generic_serial.c
index 8facf3e25c49..7ed7da1d99cf 100644
--- a/drivers/char/generic_serial.c
+++ b/drivers/char/generic_serial.c
@@ -28,7 +28,6 @@
28#include <linux/interrupt.h> 28#include <linux/interrupt.h>
29#include <linux/tty_flip.h> 29#include <linux/tty_flip.h>
30#include <linux/delay.h> 30#include <linux/delay.h>
31#include <asm/semaphore.h>
32#include <asm/uaccess.h> 31#include <asm/uaccess.h>
33 32
34#define DEBUG 33#define DEBUG
diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c
index 4dbd3425e928..9769bf8279a6 100644
--- a/drivers/char/keyboard.c
+++ b/drivers/char/keyboard.c
@@ -1033,7 +1033,8 @@ DECLARE_TASKLET_DISABLED(keyboard_tasklet, kbd_bh, 0);
1033#if defined(CONFIG_X86) || defined(CONFIG_IA64) || defined(CONFIG_ALPHA) ||\ 1033#if defined(CONFIG_X86) || defined(CONFIG_IA64) || defined(CONFIG_ALPHA) ||\
1034 defined(CONFIG_MIPS) || defined(CONFIG_PPC) || defined(CONFIG_SPARC) ||\ 1034 defined(CONFIG_MIPS) || defined(CONFIG_PPC) || defined(CONFIG_SPARC) ||\
1035 defined(CONFIG_PARISC) || defined(CONFIG_SUPERH) ||\ 1035 defined(CONFIG_PARISC) || defined(CONFIG_SUPERH) ||\
1036 (defined(CONFIG_ARM) && defined(CONFIG_KEYBOARD_ATKBD) && !defined(CONFIG_ARCH_RPC)) 1036 (defined(CONFIG_ARM) && defined(CONFIG_KEYBOARD_ATKBD) && !defined(CONFIG_ARCH_RPC)) ||\
1037 defined(CONFIG_AVR32)
1037 1038
1038#define HW_RAW(dev) (test_bit(EV_MSC, dev->evbit) && test_bit(MSC_RAW, dev->mscbit) &&\ 1039#define HW_RAW(dev) (test_bit(EV_MSC, dev->evbit) && test_bit(MSC_RAW, dev->mscbit) &&\
1039 ((dev)->id.bustype == BUS_I8042) && ((dev)->id.vendor == 0x0001) && ((dev)->id.product == 0x0001)) 1040 ((dev)->id.bustype == BUS_I8042) && ((dev)->id.vendor == 0x0001) && ((dev)->id.product == 0x0001))
diff --git a/drivers/char/rio/rioboot.c b/drivers/char/rio/rioboot.c
index eca2b95343e2..d956dd316005 100644
--- a/drivers/char/rio/rioboot.c
+++ b/drivers/char/rio/rioboot.c
@@ -35,7 +35,6 @@
35#include <linux/termios.h> 35#include <linux/termios.h>
36#include <linux/serial.h> 36#include <linux/serial.h>
37#include <linux/vmalloc.h> 37#include <linux/vmalloc.h>
38#include <asm/semaphore.h>
39#include <linux/generic_serial.h> 38#include <linux/generic_serial.h>
40#include <linux/errno.h> 39#include <linux/errno.h>
41#include <linux/interrupt.h> 40#include <linux/interrupt.h>
diff --git a/drivers/char/rio/riocmd.c b/drivers/char/rio/riocmd.c
index 7321d002c34f..bf36959fc121 100644
--- a/drivers/char/rio/riocmd.c
+++ b/drivers/char/rio/riocmd.c
@@ -41,7 +41,6 @@ static char *_riocmd_c_sccs_ = "@(#)riocmd.c 1.2";
41#include <asm/io.h> 41#include <asm/io.h>
42#include <asm/system.h> 42#include <asm/system.h>
43#include <asm/string.h> 43#include <asm/string.h>
44#include <asm/semaphore.h>
45#include <asm/uaccess.h> 44#include <asm/uaccess.h>
46 45
47#include <linux/termios.h> 46#include <linux/termios.h>
diff --git a/drivers/char/rio/rioctrl.c b/drivers/char/rio/rioctrl.c
index 7ce77619707c..d8eb2bcbe015 100644
--- a/drivers/char/rio/rioctrl.c
+++ b/drivers/char/rio/rioctrl.c
@@ -40,7 +40,6 @@ static char *_rioctrl_c_sccs_ = "@(#)rioctrl.c 1.3";
40#include <asm/io.h> 40#include <asm/io.h>
41#include <asm/system.h> 41#include <asm/system.h>
42#include <asm/string.h> 42#include <asm/string.h>
43#include <asm/semaphore.h>
44#include <asm/uaccess.h> 43#include <asm/uaccess.h>
45 44
46#include <linux/termios.h> 45#include <linux/termios.h>
diff --git a/drivers/char/rio/rioinit.c b/drivers/char/rio/rioinit.c
index 0794844369d6..add1718295ef 100644
--- a/drivers/char/rio/rioinit.c
+++ b/drivers/char/rio/rioinit.c
@@ -40,7 +40,6 @@ static char *_rioinit_c_sccs_ = "@(#)rioinit.c 1.3";
40#include <asm/io.h> 40#include <asm/io.h>
41#include <asm/system.h> 41#include <asm/system.h>
42#include <asm/string.h> 42#include <asm/string.h>
43#include <asm/semaphore.h>
44#include <asm/uaccess.h> 43#include <asm/uaccess.h>
45 44
46#include <linux/termios.h> 45#include <linux/termios.h>
diff --git a/drivers/char/rio/riointr.c b/drivers/char/rio/riointr.c
index ebc76342712c..4734e26e1ccd 100644
--- a/drivers/char/rio/riointr.c
+++ b/drivers/char/rio/riointr.c
@@ -42,7 +42,6 @@ static char *_riointr_c_sccs_ = "@(#)riointr.c 1.2";
42#include <asm/io.h> 42#include <asm/io.h>
43#include <asm/system.h> 43#include <asm/system.h>
44#include <asm/string.h> 44#include <asm/string.h>
45#include <asm/semaphore.h>
46#include <asm/uaccess.h> 45#include <asm/uaccess.h>
47 46
48#include <linux/termios.h> 47#include <linux/termios.h>
diff --git a/drivers/char/rio/rioparam.c b/drivers/char/rio/rioparam.c
index bb498d24adcc..da276ed57b3f 100644
--- a/drivers/char/rio/rioparam.c
+++ b/drivers/char/rio/rioparam.c
@@ -41,7 +41,6 @@ static char *_rioparam_c_sccs_ = "@(#)rioparam.c 1.3";
41#include <asm/io.h> 41#include <asm/io.h>
42#include <asm/system.h> 42#include <asm/system.h>
43#include <asm/string.h> 43#include <asm/string.h>
44#include <asm/semaphore.h>
45#include <asm/uaccess.h> 44#include <asm/uaccess.h>
46 45
47#include <linux/termios.h> 46#include <linux/termios.h>
diff --git a/drivers/char/rio/rioroute.c b/drivers/char/rio/rioroute.c
index a99f3d9d7d65..85091ff74d96 100644
--- a/drivers/char/rio/rioroute.c
+++ b/drivers/char/rio/rioroute.c
@@ -39,7 +39,6 @@ static char *_rioroute_c_sccs_ = "@(#)rioroute.c 1.3";
39#include <asm/io.h> 39#include <asm/io.h>
40#include <asm/system.h> 40#include <asm/system.h>
41#include <asm/string.h> 41#include <asm/string.h>
42#include <asm/semaphore.h>
43#include <asm/uaccess.h> 42#include <asm/uaccess.h>
44 43
45#include <linux/termios.h> 44#include <linux/termios.h>
diff --git a/drivers/char/rio/riotable.c b/drivers/char/rio/riotable.c
index 9b52892a501f..2b24488e95f2 100644
--- a/drivers/char/rio/riotable.c
+++ b/drivers/char/rio/riotable.c
@@ -42,7 +42,6 @@ static char *_riotable_c_sccs_ = "@(#)riotable.c 1.2";
42#include <asm/io.h> 42#include <asm/io.h>
43#include <asm/system.h> 43#include <asm/system.h>
44#include <asm/string.h> 44#include <asm/string.h>
45#include <asm/semaphore.h>
46#include <asm/uaccess.h> 45#include <asm/uaccess.h>
47 46
48#include <linux/termios.h> 47#include <linux/termios.h>
diff --git a/drivers/char/rio/riotty.c b/drivers/char/rio/riotty.c
index cfa54361473f..1cb8580a161d 100644
--- a/drivers/char/rio/riotty.c
+++ b/drivers/char/rio/riotty.c
@@ -44,7 +44,6 @@ static char *_riotty_c_sccs_ = "@(#)riotty.c 1.3";
44#include <asm/io.h> 44#include <asm/io.h>
45#include <asm/system.h> 45#include <asm/system.h>
46#include <asm/string.h> 46#include <asm/string.h>
47#include <asm/semaphore.h>
48#include <asm/uaccess.h> 47#include <asm/uaccess.h>
49 48
50#include <linux/termios.h> 49#include <linux/termios.h>
diff --git a/drivers/char/snsc.h b/drivers/char/snsc.h
index 8a98169b60c1..4be62eda9fbc 100644
--- a/drivers/char/snsc.h
+++ b/drivers/char/snsc.h
@@ -22,8 +22,8 @@
22#include <linux/kobject.h> 22#include <linux/kobject.h>
23#include <linux/fs.h> 23#include <linux/fs.h>
24#include <linux/cdev.h> 24#include <linux/cdev.h>
25#include <linux/semaphore.h>
25#include <asm/sn/types.h> 26#include <asm/sn/types.h>
26#include <asm/semaphore.h>
27 27
28#define CHUNKSIZE 127 28#define CHUNKSIZE 127
29 29
diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
index a52225470225..1525882190fd 100644
--- a/drivers/clocksource/Makefile
+++ b/drivers/clocksource/Makefile
@@ -1,3 +1,4 @@
1obj-$(CONFIG_ATMEL_TCB_CLKSRC) += tcb_clksrc.o
1obj-$(CONFIG_X86_CYCLONE_TIMER) += cyclone.o 2obj-$(CONFIG_X86_CYCLONE_TIMER) += cyclone.o
2obj-$(CONFIG_X86_PM_TIMER) += acpi_pm.o 3obj-$(CONFIG_X86_PM_TIMER) += acpi_pm.o
3obj-$(CONFIG_SCx200HR_TIMER) += scx200_hrt.o 4obj-$(CONFIG_SCx200HR_TIMER) += scx200_hrt.o
diff --git a/drivers/clocksource/tcb_clksrc.c b/drivers/clocksource/tcb_clksrc.c
new file mode 100644
index 000000000000..f450588e5858
--- /dev/null
+++ b/drivers/clocksource/tcb_clksrc.c
@@ -0,0 +1,302 @@
1#include <linux/init.h>
2#include <linux/clocksource.h>
3#include <linux/clockchips.h>
4#include <linux/interrupt.h>
5#include <linux/irq.h>
6
7#include <linux/clk.h>
8#include <linux/err.h>
9#include <linux/ioport.h>
10#include <linux/io.h>
11#include <linux/platform_device.h>
12#include <linux/atmel_tc.h>
13
14
15/*
16 * We're configured to use a specific TC block, one that's not hooked
17 * up to external hardware, to provide a time solution:
18 *
19 * - Two channels combine to create a free-running 32 bit counter
20 * with a base rate of 5+ MHz, packaged as a clocksource (with
21 * resolution better than 200 nsec).
22 *
23 * - The third channel may be used to provide a 16-bit clockevent
24 * source, used in either periodic or oneshot mode. This runs
25 * at 32 KiHZ, and can handle delays of up to two seconds.
26 *
27 * A boot clocksource and clockevent source are also currently needed,
28 * unless the relevant platforms (ARM/AT91, AVR32/AT32) are changed so
29 * this code can be used when init_timers() is called, well before most
30 * devices are set up. (Some low end AT91 parts, which can run uClinux,
31 * have only the timers in one TC block... they currently don't support
32 * the tclib code, because of that initialization issue.)
33 *
34 * REVISIT behavior during system suspend states... we should disable
35 * all clocks and save the power. Easily done for clockevent devices,
36 * but clocksources won't necessarily get the needed notifications.
37 * For deeper system sleep states, this will be mandatory...
38 */
39
40static void __iomem *tcaddr;
41
42static cycle_t tc_get_cycles(void)
43{
44 unsigned long flags;
45 u32 lower, upper;
46
47 raw_local_irq_save(flags);
48 do {
49 upper = __raw_readl(tcaddr + ATMEL_TC_REG(1, CV));
50 lower = __raw_readl(tcaddr + ATMEL_TC_REG(0, CV));
51 } while (upper != __raw_readl(tcaddr + ATMEL_TC_REG(1, CV)));
52
53 raw_local_irq_restore(flags);
54 return (upper << 16) | lower;
55}
56
57static struct clocksource clksrc = {
58 .name = "tcb_clksrc",
59 .rating = 200,
60 .read = tc_get_cycles,
61 .mask = CLOCKSOURCE_MASK(32),
62 .shift = 18,
63 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
64};
65
66#ifdef CONFIG_GENERIC_CLOCKEVENTS
67
68struct tc_clkevt_device {
69 struct clock_event_device clkevt;
70 struct clk *clk;
71 void __iomem *regs;
72};
73
74static struct tc_clkevt_device *to_tc_clkevt(struct clock_event_device *clkevt)
75{
76 return container_of(clkevt, struct tc_clkevt_device, clkevt);
77}
78
79/* For now, we always use the 32K clock ... this optimizes for NO_HZ,
80 * because using one of the divided clocks would usually mean the
81 * tick rate can never be less than several dozen Hz (vs 0.5 Hz).
82 *
83 * A divided clock could be good for high resolution timers, since
84 * 30.5 usec resolution can seem "low".
85 */
86static u32 timer_clock;
87
88static void tc_mode(enum clock_event_mode m, struct clock_event_device *d)
89{
90 struct tc_clkevt_device *tcd = to_tc_clkevt(d);
91 void __iomem *regs = tcd->regs;
92
93 if (tcd->clkevt.mode == CLOCK_EVT_MODE_PERIODIC
94 || tcd->clkevt.mode == CLOCK_EVT_MODE_ONESHOT) {
95 __raw_writel(0xff, regs + ATMEL_TC_REG(2, IDR));
96 __raw_writel(ATMEL_TC_CLKDIS, regs + ATMEL_TC_REG(2, CCR));
97 clk_disable(tcd->clk);
98 }
99
100 switch (m) {
101
102 /* By not making the gentime core emulate periodic mode on top
103 * of oneshot, we get lower overhead and improved accuracy.
104 */
105 case CLOCK_EVT_MODE_PERIODIC:
106 clk_enable(tcd->clk);
107
108 /* slow clock, count up to RC, then irq and restart */
109 __raw_writel(timer_clock
110 | ATMEL_TC_WAVE | ATMEL_TC_WAVESEL_UP_AUTO,
111 regs + ATMEL_TC_REG(2, CMR));
112 __raw_writel((32768 + HZ/2) / HZ, tcaddr + ATMEL_TC_REG(2, RC));
113
114 /* Enable clock and interrupts on RC compare */
115 __raw_writel(ATMEL_TC_CPCS, regs + ATMEL_TC_REG(2, IER));
116
117 /* go go gadget! */
118 __raw_writel(ATMEL_TC_CLKEN | ATMEL_TC_SWTRG,
119 regs + ATMEL_TC_REG(2, CCR));
120 break;
121
122 case CLOCK_EVT_MODE_ONESHOT:
123 clk_enable(tcd->clk);
124
125 /* slow clock, count up to RC, then irq and stop */
126 __raw_writel(timer_clock | ATMEL_TC_CPCSTOP
127 | ATMEL_TC_WAVE | ATMEL_TC_WAVESEL_UP_AUTO,
128 regs + ATMEL_TC_REG(2, CMR));
129 __raw_writel(ATMEL_TC_CPCS, regs + ATMEL_TC_REG(2, IER));
130
131 /* set_next_event() configures and starts the timer */
132 break;
133
134 default:
135 break;
136 }
137}
138
139static int tc_next_event(unsigned long delta, struct clock_event_device *d)
140{
141 __raw_writel(delta, tcaddr + ATMEL_TC_REG(2, RC));
142
143 /* go go gadget! */
144 __raw_writel(ATMEL_TC_CLKEN | ATMEL_TC_SWTRG,
145 tcaddr + ATMEL_TC_REG(2, CCR));
146 return 0;
147}
148
149static struct tc_clkevt_device clkevt = {
150 .clkevt = {
151 .name = "tc_clkevt",
152 .features = CLOCK_EVT_FEAT_PERIODIC
153 | CLOCK_EVT_FEAT_ONESHOT,
154 .shift = 32,
155 /* Should be lower than at91rm9200's system timer */
156 .rating = 125,
157 .cpumask = CPU_MASK_CPU0,
158 .set_next_event = tc_next_event,
159 .set_mode = tc_mode,
160 },
161};
162
163static irqreturn_t ch2_irq(int irq, void *handle)
164{
165 struct tc_clkevt_device *dev = handle;
166 unsigned int sr;
167
168 sr = __raw_readl(dev->regs + ATMEL_TC_REG(2, SR));
169 if (sr & ATMEL_TC_CPCS) {
170 dev->clkevt.event_handler(&dev->clkevt);
171 return IRQ_HANDLED;
172 }
173
174 return IRQ_NONE;
175}
176
177static struct irqaction tc_irqaction = {
178 .name = "tc_clkevt",
179 .flags = IRQF_TIMER | IRQF_DISABLED,
180 .handler = ch2_irq,
181};
182
183static void __init setup_clkevents(struct atmel_tc *tc, int clk32k_divisor_idx)
184{
185 struct clk *t2_clk = tc->clk[2];
186 int irq = tc->irq[2];
187
188 clkevt.regs = tc->regs;
189 clkevt.clk = t2_clk;
190 tc_irqaction.dev_id = &clkevt;
191
192 timer_clock = clk32k_divisor_idx;
193
194 clkevt.clkevt.mult = div_sc(32768, NSEC_PER_SEC, clkevt.clkevt.shift);
195 clkevt.clkevt.max_delta_ns
196 = clockevent_delta2ns(0xffff, &clkevt.clkevt);
197 clkevt.clkevt.min_delta_ns = clockevent_delta2ns(1, &clkevt.clkevt) + 1;
198
199 setup_irq(irq, &tc_irqaction);
200
201 clockevents_register_device(&clkevt.clkevt);
202}
203
204#else /* !CONFIG_GENERIC_CLOCKEVENTS */
205
206static void __init setup_clkevents(struct atmel_tc *tc, int clk32k_divisor_idx)
207{
208 /* NOTHING */
209}
210
211#endif
212
213static int __init tcb_clksrc_init(void)
214{
215 static char bootinfo[] __initdata
216 = KERN_DEBUG "%s: tc%d at %d.%03d MHz\n";
217
218 struct platform_device *pdev;
219 struct atmel_tc *tc;
220 struct clk *t0_clk;
221 u32 rate, divided_rate = 0;
222 int best_divisor_idx = -1;
223 int clk32k_divisor_idx = -1;
224 int i;
225
226 tc = atmel_tc_alloc(CONFIG_ATMEL_TCB_CLKSRC_BLOCK, clksrc.name);
227 if (!tc) {
228 pr_debug("can't alloc TC for clocksource\n");
229 return -ENODEV;
230 }
231 tcaddr = tc->regs;
232 pdev = tc->pdev;
233
234 t0_clk = tc->clk[0];
235 clk_enable(t0_clk);
236
237 /* How fast will we be counting? Pick something over 5 MHz. */
238 rate = (u32) clk_get_rate(t0_clk);
239 for (i = 0; i < 5; i++) {
240 unsigned divisor = atmel_tc_divisors[i];
241 unsigned tmp;
242
243 /* remember 32 KiHz clock for later */
244 if (!divisor) {
245 clk32k_divisor_idx = i;
246 continue;
247 }
248
249 tmp = rate / divisor;
250 pr_debug("TC: %u / %-3u [%d] --> %u\n", rate, divisor, i, tmp);
251 if (best_divisor_idx > 0) {
252 if (tmp < 5 * 1000 * 1000)
253 continue;
254 }
255 divided_rate = tmp;
256 best_divisor_idx = i;
257 }
258
259 clksrc.mult = clocksource_hz2mult(divided_rate, clksrc.shift);
260
261 printk(bootinfo, clksrc.name, CONFIG_ATMEL_TCB_CLKSRC_BLOCK,
262 divided_rate / 1000000,
263 ((divided_rate + 500000) % 1000000) / 1000);
264
265 /* tclib will give us three clocks no matter what the
266 * underlying platform supports.
267 */
268 clk_enable(tc->clk[1]);
269
270 /* channel 0: waveform mode, input mclk/8, clock TIOA0 on overflow */
271 __raw_writel(best_divisor_idx /* likely divide-by-8 */
272 | ATMEL_TC_WAVE
273 | ATMEL_TC_WAVESEL_UP /* free-run */
274 | ATMEL_TC_ACPA_SET /* TIOA0 rises at 0 */
275 | ATMEL_TC_ACPC_CLEAR, /* (duty cycle 50%) */
276 tcaddr + ATMEL_TC_REG(0, CMR));
277 __raw_writel(0x0000, tcaddr + ATMEL_TC_REG(0, RA));
278 __raw_writel(0x8000, tcaddr + ATMEL_TC_REG(0, RC));
279 __raw_writel(0xff, tcaddr + ATMEL_TC_REG(0, IDR)); /* no irqs */
280 __raw_writel(ATMEL_TC_CLKEN, tcaddr + ATMEL_TC_REG(0, CCR));
281
282 /* channel 1: waveform mode, input TIOA0 */
283 __raw_writel(ATMEL_TC_XC1 /* input: TIOA0 */
284 | ATMEL_TC_WAVE
285 | ATMEL_TC_WAVESEL_UP, /* free-run */
286 tcaddr + ATMEL_TC_REG(1, CMR));
287 __raw_writel(0xff, tcaddr + ATMEL_TC_REG(1, IDR)); /* no irqs */
288 __raw_writel(ATMEL_TC_CLKEN, tcaddr + ATMEL_TC_REG(1, CCR));
289
290 /* chain channel 0 to channel 1, then reset all the timers */
291 __raw_writel(ATMEL_TC_TC1XC1S_TIOA0, tcaddr + ATMEL_TC_BMR);
292 __raw_writel(ATMEL_TC_SYNC, tcaddr + ATMEL_TC_BCR);
293
294 /* and away we go! */
295 clocksource_register(&clksrc);
296
297 /* channel 2: periodic and oneshot timer support */
298 setup_clkevents(tc, clk32k_divisor_idx);
299
300 return 0;
301}
302arch_initcall(tcb_clksrc_init);
diff --git a/drivers/firewire/fw-device.c b/drivers/firewire/fw-device.c
index 2d01bc1b9752..d9c8daf7ae7d 100644
--- a/drivers/firewire/fw-device.c
+++ b/drivers/firewire/fw-device.c
@@ -26,7 +26,8 @@
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/idr.h> 27#include <linux/idr.h>
28#include <linux/string.h> 28#include <linux/string.h>
29#include <asm/semaphore.h> 29#include <linux/rwsem.h>
30#include <linux/semaphore.h>
30#include <asm/system.h> 31#include <asm/system.h>
31#include <linux/ctype.h> 32#include <linux/ctype.h>
32#include "fw-transaction.h" 33#include "fw-transaction.h"
diff --git a/drivers/firewire/fw-transaction.c b/drivers/firewire/fw-transaction.c
index 3a59e9b783b0..ccf0e4cf108f 100644
--- a/drivers/firewire/fw-transaction.c
+++ b/drivers/firewire/fw-transaction.c
@@ -29,7 +29,6 @@
29#include <linux/list.h> 29#include <linux/list.h>
30#include <linux/kthread.h> 30#include <linux/kthread.h>
31#include <asm/uaccess.h> 31#include <asm/uaccess.h>
32#include <asm/semaphore.h>
33 32
34#include "fw-transaction.h" 33#include "fw-transaction.h"
35#include "fw-topology.h" 34#include "fw-topology.h"
diff --git a/drivers/firmware/dcdbas.c b/drivers/firmware/dcdbas.c
index 1636806ec55e..f235940719e7 100644
--- a/drivers/firmware/dcdbas.c
+++ b/drivers/firmware/dcdbas.c
@@ -35,7 +35,6 @@
35#include <linux/types.h> 35#include <linux/types.h>
36#include <linux/mutex.h> 36#include <linux/mutex.h>
37#include <asm/io.h> 37#include <asm/io.h>
38#include <asm/semaphore.h>
39 38
40#include "dcdbas.h" 39#include "dcdbas.h"
41 40
@@ -265,7 +264,7 @@ static int smi_request(struct smi_cmd *smi_cmd)
265 264
266 /* SMI requires CPU 0 */ 265 /* SMI requires CPU 0 */
267 old_mask = current->cpus_allowed; 266 old_mask = current->cpus_allowed;
268 set_cpus_allowed(current, cpumask_of_cpu(0)); 267 set_cpus_allowed_ptr(current, &cpumask_of_cpu(0));
269 if (smp_processor_id() != 0) { 268 if (smp_processor_id() != 0) {
270 dev_dbg(&dcdbas_pdev->dev, "%s: failed to get CPU 0\n", 269 dev_dbg(&dcdbas_pdev->dev, "%s: failed to get CPU 0\n",
271 __FUNCTION__); 270 __FUNCTION__);
@@ -285,7 +284,7 @@ static int smi_request(struct smi_cmd *smi_cmd)
285 ); 284 );
286 285
287out: 286out:
288 set_cpus_allowed(current, old_mask); 287 set_cpus_allowed_ptr(current, &old_mask);
289 return ret; 288 return ret;
290} 289}
291 290
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 5fa9c3c67e0c..b04c99580d0d 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -645,7 +645,7 @@ config I2C_PCA_ISA
645 645
646config I2C_MV64XXX 646config I2C_MV64XXX
647 tristate "Marvell mv64xxx I2C Controller" 647 tristate "Marvell mv64xxx I2C Controller"
648 depends on (MV64X60 || ARCH_ORION) && EXPERIMENTAL 648 depends on (MV64X60 || PLAT_ORION) && EXPERIMENTAL
649 help 649 help
650 If you say yes to this option, support will be included for the 650 If you say yes to this option, support will be included for the
651 built-in I2C interface on the Marvell 64xxx line of host bridges. 651 built-in I2C interface on the Marvell 64xxx line of host bridges.
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index 2d2087ad708f..6fd2d6a84eff 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -39,6 +39,7 @@
39#include <asm/io.h> 39#include <asm/io.h>
40#include <asm/arch/i2c.h> 40#include <asm/arch/i2c.h>
41#include <asm/arch/pxa-regs.h> 41#include <asm/arch/pxa-regs.h>
42#include <asm/arch/pxa2xx-gpio.h>
42 43
43struct pxa_i2c { 44struct pxa_i2c {
44 spinlock_t lock; 45 spinlock_t lock;
diff --git a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig
index b21593f93586..2da2edfa68ec 100644
--- a/drivers/i2c/chips/Kconfig
+++ b/drivers/i2c/chips/Kconfig
@@ -93,6 +93,7 @@ config ISP1301_OMAP
93 93
94config TPS65010 94config TPS65010
95 tristate "TPS6501x Power Management chips" 95 tristate "TPS6501x Power Management chips"
96 depends on HAVE_GPIO_LIB
96 default y if MACH_OMAP_H2 || MACH_OMAP_H3 || MACH_OMAP_OSK 97 default y if MACH_OMAP_H2 || MACH_OMAP_H3 || MACH_OMAP_OSK
97 help 98 help
98 If you say yes here you get support for the TPS6501x series of 99 If you say yes here you get support for the TPS6501x series of
diff --git a/drivers/i2c/chips/tps65010.c b/drivers/i2c/chips/tps65010.c
index 4154a9108859..b67f69c2e7f3 100644
--- a/drivers/i2c/chips/tps65010.c
+++ b/drivers/i2c/chips/tps65010.c
@@ -30,9 +30,13 @@
30#include <linux/debugfs.h> 30#include <linux/debugfs.h>
31#include <linux/seq_file.h> 31#include <linux/seq_file.h>
32#include <linux/mutex.h> 32#include <linux/mutex.h>
33#include <linux/platform_device.h>
33 34
34#include <linux/i2c/tps65010.h> 35#include <linux/i2c/tps65010.h>
35 36
37#include <asm/gpio.h>
38
39
36/*-------------------------------------------------------------------------*/ 40/*-------------------------------------------------------------------------*/
37 41
38#define DRIVER_VERSION "2 May 2005" 42#define DRIVER_VERSION "2 May 2005"
@@ -84,7 +88,9 @@ struct tps65010 {
84 u8 chgstatus, regstatus, chgconf; 88 u8 chgstatus, regstatus, chgconf;
85 u8 nmask1, nmask2; 89 u8 nmask1, nmask2;
86 90
87 /* not currently tracking GPIO state */ 91 u8 outmask;
92 struct gpio_chip chip;
93 struct platform_device *leds;
88}; 94};
89 95
90#define POWER_POLL_DELAY msecs_to_jiffies(5000) 96#define POWER_POLL_DELAY msecs_to_jiffies(5000)
@@ -449,12 +455,72 @@ static irqreturn_t tps65010_irq(int irq, void *_tps)
449 455
450/*-------------------------------------------------------------------------*/ 456/*-------------------------------------------------------------------------*/
451 457
458/* offsets 0..3 == GPIO1..GPIO4
459 * offsets 4..5 == LED1/nPG, LED2 (we set one of the non-BLINK modes)
460 */
461static void
462tps65010_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
463{
464 if (offset < 4)
465 tps65010_set_gpio_out_value(offset + 1, value);
466 else
467 tps65010_set_led(offset - 3, value ? ON : OFF);
468}
469
470static int
471tps65010_output(struct gpio_chip *chip, unsigned offset, int value)
472{
473 /* GPIOs may be input-only */
474 if (offset < 4) {
475 struct tps65010 *tps;
476
477 tps = container_of(chip, struct tps65010, chip);
478 if (!(tps->outmask & (1 << offset)))
479 return -EINVAL;
480 tps65010_set_gpio_out_value(offset + 1, value);
481 } else
482 tps65010_set_led(offset - 3, value ? ON : OFF);
483
484 return 0;
485}
486
487static int tps65010_gpio_get(struct gpio_chip *chip, unsigned offset)
488{
489 int value;
490 struct tps65010 *tps;
491
492 tps = container_of(chip, struct tps65010, chip);
493
494 if (offset < 4) {
495 value = i2c_smbus_read_byte_data(tps->client, TPS_DEFGPIO);
496 if (value < 0)
497 return 0;
498 if (value & (1 << (offset + 4))) /* output */
499 return !(value & (1 << offset));
500 else /* input */
501 return (value & (1 << offset));
502 }
503
504 /* REVISIT we *could* report LED1/nPG and LED2 state ... */
505 return 0;
506}
507
508
509/*-------------------------------------------------------------------------*/
510
452static struct tps65010 *the_tps; 511static struct tps65010 *the_tps;
453 512
454static int __exit tps65010_remove(struct i2c_client *client) 513static int __exit tps65010_remove(struct i2c_client *client)
455{ 514{
456 struct tps65010 *tps = i2c_get_clientdata(client); 515 struct tps65010 *tps = i2c_get_clientdata(client);
516 struct tps65010_board *board = client->dev.platform_data;
457 517
518 if (board && board->teardown) {
519 int status = board->teardown(client, board->context);
520 if (status < 0)
521 dev_dbg(&client->dev, "board %s %s err %d\n",
522 "teardown", client->name, status);
523 }
458 if (client->irq > 0) 524 if (client->irq > 0)
459 free_irq(client->irq, tps); 525 free_irq(client->irq, tps);
460 cancel_delayed_work(&tps->work); 526 cancel_delayed_work(&tps->work);
@@ -469,6 +535,7 @@ static int tps65010_probe(struct i2c_client *client)
469{ 535{
470 struct tps65010 *tps; 536 struct tps65010 *tps;
471 int status; 537 int status;
538 struct tps65010_board *board = client->dev.platform_data;
472 539
473 if (the_tps) { 540 if (the_tps) {
474 dev_dbg(&client->dev, "only one tps6501x chip allowed\n"); 541 dev_dbg(&client->dev, "only one tps6501x chip allowed\n");
@@ -577,6 +644,38 @@ static int tps65010_probe(struct i2c_client *client)
577 644
578 tps->file = debugfs_create_file(DRIVER_NAME, S_IRUGO, NULL, 645 tps->file = debugfs_create_file(DRIVER_NAME, S_IRUGO, NULL,
579 tps, DEBUG_FOPS); 646 tps, DEBUG_FOPS);
647
648 /* optionally register GPIOs */
649 if (board && board->base > 0) {
650 tps->outmask = board->outmask;
651
652 tps->chip.label = client->name;
653
654 tps->chip.set = tps65010_gpio_set;
655 tps->chip.direction_output = tps65010_output;
656
657 /* NOTE: only partial support for inputs; nyet IRQs */
658 tps->chip.get = tps65010_gpio_get;
659
660 tps->chip.base = board->base;
661 tps->chip.ngpio = 6;
662 tps->chip.can_sleep = 1;
663
664 status = gpiochip_add(&tps->chip);
665 if (status < 0)
666 dev_err(&client->dev, "can't add gpiochip, err %d\n",
667 status);
668 else if (board->setup) {
669 status = board->setup(client, board->context);
670 if (status < 0) {
671 dev_dbg(&client->dev,
672 "board %s %s err %d\n",
673 "setup", client->name, status);
674 status = 0;
675 }
676 }
677 }
678
580 return 0; 679 return 0;
581fail1: 680fail1:
582 kfree(tps); 681 kfree(tps);
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 8b645c6b2cb5..e186df657119 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -35,8 +35,8 @@
35#include <linux/completion.h> 35#include <linux/completion.h>
36#include <linux/hardirq.h> 36#include <linux/hardirq.h>
37#include <linux/irqflags.h> 37#include <linux/irqflags.h>
38#include <linux/semaphore.h>
38#include <asm/uaccess.h> 39#include <asm/uaccess.h>
39#include <asm/semaphore.h>
40 40
41#include "i2c-core.h" 41#include "i2c-core.h"
42 42
diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c
index 70afa3786f3f..29d833e71cbf 100644
--- a/drivers/ieee1394/nodemgr.c
+++ b/drivers/ieee1394/nodemgr.c
@@ -18,8 +18,8 @@
18#include <linux/moduleparam.h> 18#include <linux/moduleparam.h>
19#include <linux/mutex.h> 19#include <linux/mutex.h>
20#include <linux/freezer.h> 20#include <linux/freezer.h>
21#include <linux/semaphore.h>
21#include <asm/atomic.h> 22#include <asm/atomic.h>
22#include <asm/semaphore.h>
23 23
24#include "csr.h" 24#include "csr.h"
25#include "highlevel.h" 25#include "highlevel.h"
diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
index 9a9d3446c6ed..3aa2db54eae4 100644
--- a/drivers/infiniband/core/user_mad.c
+++ b/drivers/infiniband/core/user_mad.c
@@ -46,9 +46,9 @@
46#include <linux/mutex.h> 46#include <linux/mutex.h>
47#include <linux/kref.h> 47#include <linux/kref.h>
48#include <linux/compat.h> 48#include <linux/compat.h>
49#include <linux/semaphore.h>
49 50
50#include <asm/uaccess.h> 51#include <asm/uaccess.h>
51#include <asm/semaphore.h>
52 52
53#include <rdma/ib_mad.h> 53#include <rdma/ib_mad.h>
54#include <rdma/ib_user_mad.h> 54#include <rdma/ib_user_mad.h>
diff --git a/drivers/infiniband/hw/amso1100/c2.h b/drivers/infiniband/hw/amso1100/c2.h
index ed38ab8d9c0c..d12a24a84fd9 100644
--- a/drivers/infiniband/hw/amso1100/c2.h
+++ b/drivers/infiniband/hw/amso1100/c2.h
@@ -40,7 +40,6 @@
40#include <linux/pci.h> 40#include <linux/pci.h>
41#include <linux/dma-mapping.h> 41#include <linux/dma-mapping.h>
42#include <linux/idr.h> 42#include <linux/idr.h>
43#include <asm/semaphore.h>
44 43
45#include "c2_provider.h" 44#include "c2_provider.h"
46#include "c2_mq.h" 45#include "c2_mq.h"
diff --git a/drivers/infiniband/hw/mthca/mthca_dev.h b/drivers/infiniband/hw/mthca/mthca_dev.h
index 0e842e023400..7bc32f8e377e 100644
--- a/drivers/infiniband/hw/mthca/mthca_dev.h
+++ b/drivers/infiniband/hw/mthca/mthca_dev.h
@@ -46,8 +46,7 @@
46#include <linux/timer.h> 46#include <linux/timer.h>
47#include <linux/mutex.h> 47#include <linux/mutex.h>
48#include <linux/list.h> 48#include <linux/list.h>
49 49#include <linux/semaphore.h>
50#include <asm/semaphore.h>
51 50
52#include "mthca_provider.h" 51#include "mthca_provider.h"
53#include "mthca_doorbell.h" 52#include "mthca_doorbell.h"
diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
index 1626124a156d..cdf2e9ad62f7 100644
--- a/drivers/infiniband/hw/nes/nes.h
+++ b/drivers/infiniband/hw/nes/nes.h
@@ -43,7 +43,6 @@
43#include <linux/dma-mapping.h> 43#include <linux/dma-mapping.h>
44#include <linux/workqueue.h> 44#include <linux/workqueue.h>
45#include <linux/slab.h> 45#include <linux/slab.h>
46#include <asm/semaphore.h>
47#include <linux/version.h> 46#include <linux/version.h>
48#include <asm/io.h> 47#include <asm/io.h>
49#include <linux/crc32c.h> 48#include <linux/crc32c.h>
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index 8ea709be3306..efd70a974591 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -314,4 +314,13 @@ config KEYBOARD_BFIN
314 To compile this driver as a module, choose M here: the 314 To compile this driver as a module, choose M here: the
315 module will be called bf54x-keys. 315 module will be called bf54x-keys.
316 316
317config KEYBOARD_SH_KEYSC
318 tristate "SuperH KEYSC keypad support"
319 depends on SUPERH
320 help
321 Say Y here if you want to use a keypad attached to the KEYSC block
322 on SuperH processors such as sh7722 and sh7343.
323
324 To compile this driver as a module, choose M here: the
325 module will be called sh_keysc.
317endif 326endif
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index e741f4031012..0edc8f285d1c 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -26,3 +26,4 @@ obj-$(CONFIG_KEYBOARD_HP6XX) += jornada680_kbd.o
26obj-$(CONFIG_KEYBOARD_HP7XX) += jornada720_kbd.o 26obj-$(CONFIG_KEYBOARD_HP7XX) += jornada720_kbd.o
27obj-$(CONFIG_KEYBOARD_MAPLE) += maple_keyb.o 27obj-$(CONFIG_KEYBOARD_MAPLE) += maple_keyb.o
28obj-$(CONFIG_KEYBOARD_BFIN) += bf54x-keys.o 28obj-$(CONFIG_KEYBOARD_BFIN) += bf54x-keys.o
29obj-$(CONFIG_KEYBOARD_SH_KEYSC) += sh_keysc.o
diff --git a/drivers/input/keyboard/corgikbd.c b/drivers/input/keyboard/corgikbd.c
index 790fed368aae..5d6cc7f1dc94 100644
--- a/drivers/input/keyboard/corgikbd.c
+++ b/drivers/input/keyboard/corgikbd.c
@@ -23,6 +23,7 @@
23#include <asm/arch/corgi.h> 23#include <asm/arch/corgi.h>
24#include <asm/arch/hardware.h> 24#include <asm/arch/hardware.h>
25#include <asm/arch/pxa-regs.h> 25#include <asm/arch/pxa-regs.h>
26#include <asm/arch/pxa2xx-gpio.h>
26#include <asm/hardware/scoop.h> 27#include <asm/hardware/scoop.h>
27 28
28#define KB_ROWS 8 29#define KB_ROWS 8
diff --git a/drivers/input/keyboard/sh_keysc.c b/drivers/input/keyboard/sh_keysc.c
new file mode 100644
index 000000000000..8486abc457ed
--- /dev/null
+++ b/drivers/input/keyboard/sh_keysc.c
@@ -0,0 +1,280 @@
1/*
2 * SuperH KEYSC Keypad Driver
3 *
4 * Copyright (C) 2008 Magnus Damm
5 *
6 * Based on gpio_keys.c, Copyright 2005 Phil Blundell
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/kernel.h>
14#include <linux/module.h>
15#include <linux/init.h>
16#include <linux/interrupt.h>
17#include <linux/irq.h>
18#include <linux/delay.h>
19#include <linux/platform_device.h>
20#include <linux/input.h>
21#include <linux/io.h>
22#include <asm/sh_keysc.h>
23
24#define KYCR1_OFFS 0x00
25#define KYCR2_OFFS 0x04
26#define KYINDR_OFFS 0x08
27#define KYOUTDR_OFFS 0x0c
28
29#define KYCR2_IRQ_LEVEL 0x10
30#define KYCR2_IRQ_DISABLED 0x00
31
32static const struct {
33 unsigned char kymd, keyout, keyin;
34} sh_keysc_mode[] = {
35 [SH_KEYSC_MODE_1] = { 0, 6, 5 },
36 [SH_KEYSC_MODE_2] = { 1, 5, 6 },
37 [SH_KEYSC_MODE_3] = { 2, 4, 7 },
38};
39
40struct sh_keysc_priv {
41 void __iomem *iomem_base;
42 unsigned long last_keys;
43 struct input_dev *input;
44 struct sh_keysc_info pdata;
45};
46
47static irqreturn_t sh_keysc_isr(int irq, void *dev_id)
48{
49 struct platform_device *pdev = dev_id;
50 struct sh_keysc_priv *priv = platform_get_drvdata(pdev);
51 struct sh_keysc_info *pdata = &priv->pdata;
52 unsigned long keys, keys1, keys0, mask;
53 unsigned char keyin_set, tmp;
54 int i, k;
55
56 dev_dbg(&pdev->dev, "isr!\n");
57
58 keys1 = ~0;
59 keys0 = 0;
60
61 do {
62 keys = 0;
63 keyin_set = 0;
64
65 iowrite16(KYCR2_IRQ_DISABLED, priv->iomem_base + KYCR2_OFFS);
66
67 for (i = 0; i < sh_keysc_mode[pdata->mode].keyout; i++) {
68 iowrite16(0xfff ^ (3 << (i * 2)),
69 priv->iomem_base + KYOUTDR_OFFS);
70 udelay(pdata->delay);
71 tmp = ioread16(priv->iomem_base + KYINDR_OFFS);
72 keys |= tmp << (sh_keysc_mode[pdata->mode].keyin * i);
73 tmp ^= (1 << sh_keysc_mode[pdata->mode].keyin) - 1;
74 keyin_set |= tmp;
75 }
76
77 iowrite16(0, priv->iomem_base + KYOUTDR_OFFS);
78 iowrite16(KYCR2_IRQ_LEVEL | (keyin_set << 8),
79 priv->iomem_base + KYCR2_OFFS);
80
81 keys ^= ~0;
82 keys &= (1 << (sh_keysc_mode[pdata->mode].keyin *
83 sh_keysc_mode[pdata->mode].keyout)) - 1;
84 keys1 &= keys;
85 keys0 |= keys;
86
87 dev_dbg(&pdev->dev, "keys 0x%08lx\n", keys);
88
89 } while (ioread16(priv->iomem_base + KYCR2_OFFS) & 0x01);
90
91 dev_dbg(&pdev->dev, "last_keys 0x%08lx keys0 0x%08lx keys1 0x%08lx\n",
92 priv->last_keys, keys0, keys1);
93
94 for (i = 0; i < SH_KEYSC_MAXKEYS; i++) {
95 k = pdata->keycodes[i];
96 if (!k)
97 continue;
98
99 mask = 1 << i;
100
101 if (!((priv->last_keys ^ keys0) & mask))
102 continue;
103
104 if ((keys1 | keys0) & mask) {
105 input_event(priv->input, EV_KEY, k, 1);
106 priv->last_keys |= mask;
107 }
108
109 if (!(keys1 & mask)) {
110 input_event(priv->input, EV_KEY, k, 0);
111 priv->last_keys &= ~mask;
112 }
113
114 }
115 input_sync(priv->input);
116
117 return IRQ_HANDLED;
118}
119
120#define res_size(res) ((res)->end - (res)->start + 1)
121
122static int __devinit sh_keysc_probe(struct platform_device *pdev)
123{
124 struct sh_keysc_priv *priv;
125 struct sh_keysc_info *pdata;
126 struct resource *res;
127 struct input_dev *input;
128 int i, k;
129 int irq, error;
130
131 if (!pdev->dev.platform_data) {
132 dev_err(&pdev->dev, "no platform data defined\n");
133 error = -EINVAL;
134 goto err0;
135 }
136
137 error = -ENXIO;
138 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
139 if (res == NULL) {
140 dev_err(&pdev->dev, "failed to get I/O memory\n");
141 goto err0;
142 }
143
144 irq = platform_get_irq(pdev, 0);
145 if (irq < 0) {
146 dev_err(&pdev->dev, "failed to get irq\n");
147 goto err0;
148 }
149
150 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
151 if (priv == NULL) {
152 dev_err(&pdev->dev, "failed to allocate driver data\n");
153 error = -ENOMEM;
154 goto err0;
155 }
156
157 platform_set_drvdata(pdev, priv);
158 memcpy(&priv->pdata, pdev->dev.platform_data, sizeof(priv->pdata));
159 pdata = &priv->pdata;
160
161 res = request_mem_region(res->start, res_size(res), pdev->name);
162 if (res == NULL) {
163 dev_err(&pdev->dev, "failed to request I/O memory\n");
164 error = -EBUSY;
165 goto err1;
166 }
167
168 priv->iomem_base = ioremap_nocache(res->start, res_size(res));
169 if (priv->iomem_base == NULL) {
170 dev_err(&pdev->dev, "failed to remap I/O memory\n");
171 error = -ENXIO;
172 goto err2;
173 }
174
175 priv->input = input_allocate_device();
176 if (!priv->input) {
177 dev_err(&pdev->dev, "failed to allocate input device\n");
178 error = -ENOMEM;
179 goto err3;
180 }
181
182 input = priv->input;
183 input->evbit[0] = BIT_MASK(EV_KEY);
184
185 input->name = pdev->name;
186 input->phys = "sh-keysc-keys/input0";
187 input->dev.parent = &pdev->dev;
188
189 input->id.bustype = BUS_HOST;
190 input->id.vendor = 0x0001;
191 input->id.product = 0x0001;
192 input->id.version = 0x0100;
193
194 error = request_irq(irq, sh_keysc_isr, 0, pdev->name, pdev);
195 if (error) {
196 dev_err(&pdev->dev, "failed to request IRQ\n");
197 goto err4;
198 }
199
200 for (i = 0; i < SH_KEYSC_MAXKEYS; i++) {
201 k = pdata->keycodes[i];
202 if (k)
203 input_set_capability(input, EV_KEY, k);
204 }
205
206 error = input_register_device(input);
207 if (error) {
208 dev_err(&pdev->dev, "failed to register input device\n");
209 goto err5;
210 }
211
212 iowrite16((sh_keysc_mode[pdata->mode].kymd << 8) |
213 pdata->scan_timing, priv->iomem_base + KYCR1_OFFS);
214 iowrite16(0, priv->iomem_base + KYOUTDR_OFFS);
215 iowrite16(KYCR2_IRQ_LEVEL, priv->iomem_base + KYCR2_OFFS);
216 return 0;
217 err5:
218 free_irq(irq, pdev);
219 err4:
220 input_free_device(input);
221 err3:
222 iounmap(priv->iomem_base);
223 err2:
224 release_mem_region(res->start, res_size(res));
225 err1:
226 platform_set_drvdata(pdev, NULL);
227 kfree(priv);
228 err0:
229 return error;
230}
231
232static int __devexit sh_keysc_remove(struct platform_device *pdev)
233{
234 struct sh_keysc_priv *priv = platform_get_drvdata(pdev);
235 struct resource *res;
236
237 iowrite16(KYCR2_IRQ_DISABLED, priv->iomem_base + KYCR2_OFFS);
238
239 input_unregister_device(priv->input);
240 free_irq(platform_get_irq(pdev, 0), pdev);
241 iounmap(priv->iomem_base);
242
243 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
244 release_mem_region(res->start, res_size(res));
245
246 platform_set_drvdata(pdev, NULL);
247 kfree(priv);
248 return 0;
249}
250
251
252#define sh_keysc_suspend NULL
253#define sh_keysc_resume NULL
254
255struct platform_driver sh_keysc_device_driver = {
256 .probe = sh_keysc_probe,
257 .remove = __devexit_p(sh_keysc_remove),
258 .suspend = sh_keysc_suspend,
259 .resume = sh_keysc_resume,
260 .driver = {
261 .name = "sh_keysc",
262 }
263};
264
265static int __init sh_keysc_init(void)
266{
267 return platform_driver_register(&sh_keysc_device_driver);
268}
269
270static void __exit sh_keysc_exit(void)
271{
272 platform_driver_unregister(&sh_keysc_device_driver);
273}
274
275module_init(sh_keysc_init);
276module_exit(sh_keysc_exit);
277
278MODULE_AUTHOR("Magnus Damm");
279MODULE_DESCRIPTION("SuperH KEYSC Keypad Driver");
280MODULE_LICENSE("GPL");
diff --git a/drivers/input/keyboard/spitzkbd.c b/drivers/input/keyboard/spitzkbd.c
index 1d59a2dc3c17..0be74bfc58fe 100644
--- a/drivers/input/keyboard/spitzkbd.c
+++ b/drivers/input/keyboard/spitzkbd.c
@@ -23,6 +23,7 @@
23#include <asm/arch/spitz.h> 23#include <asm/arch/spitz.h>
24#include <asm/arch/hardware.h> 24#include <asm/arch/hardware.h>
25#include <asm/arch/pxa-regs.h> 25#include <asm/arch/pxa-regs.h>
26#include <asm/arch/pxa2xx-gpio.h>
26 27
27#define KB_ROWS 7 28#define KB_ROWS 7
28#define KB_COLS 11 29#define KB_COLS 11
diff --git a/drivers/input/serio/hp_sdc_mlc.c b/drivers/input/serio/hp_sdc_mlc.c
index c45ea74d53e4..f1fd3b638a37 100644
--- a/drivers/input/serio/hp_sdc_mlc.c
+++ b/drivers/input/serio/hp_sdc_mlc.c
@@ -40,7 +40,7 @@
40#include <linux/module.h> 40#include <linux/module.h>
41#include <linux/init.h> 41#include <linux/init.h>
42#include <linux/string.h> 42#include <linux/string.h>
43#include <asm/semaphore.h> 43#include <linux/semaphore.h>
44 44
45#define PREFIX "HP SDC MLC: " 45#define PREFIX "HP SDC MLC: "
46 46
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 57a1c28bf122..39573b91c8de 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -28,13 +28,6 @@
28#include <linux/spi/ads7846.h> 28#include <linux/spi/ads7846.h>
29#include <asm/irq.h> 29#include <asm/irq.h>
30 30
31#ifdef CONFIG_ARM
32#include <asm/mach-types.h>
33#ifdef CONFIG_ARCH_OMAP
34#include <asm/arch/gpio.h>
35#endif
36#endif
37
38 31
39/* 32/*
40 * This code has been heavily tested on a Nokia 770, and lightly 33 * This code has been heavily tested on a Nokia 770, and lightly
@@ -1174,31 +1167,6 @@ static struct spi_driver ads7846_driver = {
1174 1167
1175static int __init ads7846_init(void) 1168static int __init ads7846_init(void)
1176{ 1169{
1177 /* grr, board-specific init should stay out of drivers!! */
1178
1179#ifdef CONFIG_ARCH_OMAP
1180 if (machine_is_omap_osk()) {
1181 /* GPIO4 = PENIRQ; GPIO6 = BUSY */
1182 omap_request_gpio(4);
1183 omap_set_gpio_direction(4, 1);
1184 omap_request_gpio(6);
1185 omap_set_gpio_direction(6, 1);
1186 }
1187 // also TI 1510 Innovator, bitbanging through FPGA
1188 // also Nokia 770
1189 // also Palm Tungsten T2
1190#endif
1191
1192 // PXA:
1193 // also Dell Axim X50
1194 // also HP iPaq H191x/H192x/H415x/H435x
1195 // also Intel Lubbock (additional to UCB1400; as temperature sensor)
1196 // also Sharp Zaurus C7xx, C8xx (corgi/sheperd/husky)
1197
1198 // Atmel at91sam9261-EK uses ads7843
1199
1200 // also various AMD Au1x00 devel boards
1201
1202 return spi_register_driver(&ads7846_driver); 1170 return spi_register_driver(&ads7846_driver);
1203} 1171}
1204module_init(ads7846_init); 1172module_init(ads7846_init);
@@ -1206,14 +1174,6 @@ module_init(ads7846_init);
1206static void __exit ads7846_exit(void) 1174static void __exit ads7846_exit(void)
1207{ 1175{
1208 spi_unregister_driver(&ads7846_driver); 1176 spi_unregister_driver(&ads7846_driver);
1209
1210#ifdef CONFIG_ARCH_OMAP
1211 if (machine_is_omap_osk()) {
1212 omap_free_gpio(4);
1213 omap_free_gpio(6);
1214 }
1215#endif
1216
1217} 1177}
1218module_exit(ads7846_exit); 1178module_exit(ads7846_exit);
1219 1179
diff --git a/drivers/input/touchscreen/corgi_ts.c b/drivers/input/touchscreen/corgi_ts.c
index 99d92f5c93d6..a22576779acd 100644
--- a/drivers/input/touchscreen/corgi_ts.c
+++ b/drivers/input/touchscreen/corgi_ts.c
@@ -22,6 +22,7 @@
22#include <asm/arch/sharpsl.h> 22#include <asm/arch/sharpsl.h>
23#include <asm/arch/hardware.h> 23#include <asm/arch/hardware.h>
24#include <asm/arch/pxa-regs.h> 24#include <asm/arch/pxa-regs.h>
25#include <asm/arch/pxa2xx-gpio.h>
25 26
26 27
27#define PWR_MODE_ACTIVE 0 28#define PWR_MODE_ACTIVE 0
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 859814f62cb0..a3a6199639f9 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -46,13 +46,6 @@ config LEDS_SPITZ
46 This option enables support for the LEDs on Sharp Zaurus 46 This option enables support for the LEDs on Sharp Zaurus
47 SL-Cxx00 series (C1000, C3000, C3100). 47 SL-Cxx00 series (C1000, C3000, C3100).
48 48
49config LEDS_TOSA
50 tristate "LED Support for the Sharp SL-6000 series"
51 depends on LEDS_CLASS && PXA_SHARPSL
52 help
53 This option enables support for the LEDs on Sharp Zaurus
54 SL-6000 series.
55
56config LEDS_S3C24XX 49config LEDS_S3C24XX
57 tristate "LED Support for Samsung S3C24XX GPIO LEDs" 50 tristate "LED Support for Samsung S3C24XX GPIO LEDs"
58 depends on LEDS_CLASS && ARCH_S3C2410 51 depends on LEDS_CLASS && ARCH_S3C2410
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index 84ced3b1a13d..e54f42da21a2 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -9,7 +9,6 @@ obj-$(CONFIG_LEDS_ATMEL_PWM) += leds-atmel-pwm.o
9obj-$(CONFIG_LEDS_CORGI) += leds-corgi.o 9obj-$(CONFIG_LEDS_CORGI) += leds-corgi.o
10obj-$(CONFIG_LEDS_LOCOMO) += leds-locomo.o 10obj-$(CONFIG_LEDS_LOCOMO) += leds-locomo.o
11obj-$(CONFIG_LEDS_SPITZ) += leds-spitz.o 11obj-$(CONFIG_LEDS_SPITZ) += leds-spitz.o
12obj-$(CONFIG_LEDS_TOSA) += leds-tosa.o
13obj-$(CONFIG_LEDS_S3C24XX) += leds-s3c24xx.o 12obj-$(CONFIG_LEDS_S3C24XX) += leds-s3c24xx.o
14obj-$(CONFIG_LEDS_AMS_DELTA) += leds-ams-delta.o 13obj-$(CONFIG_LEDS_AMS_DELTA) += leds-ams-delta.o
15obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o 14obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o
diff --git a/drivers/leds/leds-tosa.c b/drivers/leds/leds-tosa.c
deleted file mode 100644
index 7ebecc41a9be..000000000000
--- a/drivers/leds/leds-tosa.c
+++ /dev/null
@@ -1,132 +0,0 @@
1/*
2 * LED Triggers Core
3 *
4 * Copyright 2005 Dirk Opfer
5 *
6 * Author: Dirk Opfer <Dirk@Opfer-Online.de>
7 * based on spitz.c
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 */
14
15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/platform_device.h>
18#include <linux/leds.h>
19#include <asm/hardware/scoop.h>
20#include <asm/mach-types.h>
21#include <asm/arch/hardware.h>
22#include <asm/arch/pxa-regs.h>
23#include <asm/arch/tosa.h>
24
25static void tosaled_amber_set(struct led_classdev *led_cdev,
26 enum led_brightness value)
27{
28 if (value)
29 set_scoop_gpio(&tosascoop_jc_device.dev,
30 TOSA_SCOOP_JC_CHRG_ERR_LED);
31 else
32 reset_scoop_gpio(&tosascoop_jc_device.dev,
33 TOSA_SCOOP_JC_CHRG_ERR_LED);
34}
35
36static void tosaled_green_set(struct led_classdev *led_cdev,
37 enum led_brightness value)
38{
39 if (value)
40 set_scoop_gpio(&tosascoop_jc_device.dev,
41 TOSA_SCOOP_JC_NOTE_LED);
42 else
43 reset_scoop_gpio(&tosascoop_jc_device.dev,
44 TOSA_SCOOP_JC_NOTE_LED);
45}
46
47static struct led_classdev tosa_amber_led = {
48 .name = "tosa:amber:charge",
49 .default_trigger = "sharpsl-charge",
50 .brightness_set = tosaled_amber_set,
51};
52
53static struct led_classdev tosa_green_led = {
54 .name = "tosa:green:mail",
55 .default_trigger = "nand-disk",
56 .brightness_set = tosaled_green_set,
57};
58
59#ifdef CONFIG_PM
60static int tosaled_suspend(struct platform_device *dev, pm_message_t state)
61{
62#ifdef CONFIG_LEDS_TRIGGERS
63 if (tosa_amber_led.trigger && strcmp(tosa_amber_led.trigger->name,
64 "sharpsl-charge"))
65#endif
66 led_classdev_suspend(&tosa_amber_led);
67 led_classdev_suspend(&tosa_green_led);
68 return 0;
69}
70
71static int tosaled_resume(struct platform_device *dev)
72{
73 led_classdev_resume(&tosa_amber_led);
74 led_classdev_resume(&tosa_green_led);
75 return 0;
76}
77#else
78#define tosaled_suspend NULL
79#define tosaled_resume NULL
80#endif
81
82static int tosaled_probe(struct platform_device *pdev)
83{
84 int ret;
85
86 ret = led_classdev_register(&pdev->dev, &tosa_amber_led);
87 if (ret < 0)
88 return ret;
89
90 ret = led_classdev_register(&pdev->dev, &tosa_green_led);
91 if (ret < 0)
92 led_classdev_unregister(&tosa_amber_led);
93
94 return ret;
95}
96
97static int tosaled_remove(struct platform_device *pdev)
98{
99 led_classdev_unregister(&tosa_amber_led);
100 led_classdev_unregister(&tosa_green_led);
101
102 return 0;
103}
104
105static struct platform_driver tosaled_driver = {
106 .probe = tosaled_probe,
107 .remove = tosaled_remove,
108 .suspend = tosaled_suspend,
109 .resume = tosaled_resume,
110 .driver = {
111 .name = "tosa-led",
112 .owner = THIS_MODULE,
113 },
114};
115
116static int __init tosaled_init(void)
117{
118 return platform_driver_register(&tosaled_driver);
119}
120
121static void __exit tosaled_exit(void)
122{
123 platform_driver_unregister(&tosaled_driver);
124}
125
126module_init(tosaled_init);
127module_exit(tosaled_exit);
128
129MODULE_AUTHOR("Dirk Opfer <Dirk@Opfer-Online.de>");
130MODULE_DESCRIPTION("Tosa LED driver");
131MODULE_LICENSE("GPL");
132MODULE_ALIAS("platform:tosa-led");
diff --git a/drivers/lguest/lg.h b/drivers/lguest/lg.h
index 2337e1a06f02..005bd045d2eb 100644
--- a/drivers/lguest/lg.h
+++ b/drivers/lguest/lg.h
@@ -10,7 +10,6 @@
10#include <linux/wait.h> 10#include <linux/wait.h>
11#include <linux/hrtimer.h> 11#include <linux/hrtimer.h>
12#include <linux/err.h> 12#include <linux/err.h>
13#include <asm/semaphore.h>
14 13
15#include <asm/lguest.h> 14#include <asm/lguest.h>
16 15
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
index 28958101061f..20978205cd02 100644
--- a/drivers/macintosh/adb.c
+++ b/drivers/macintosh/adb.c
@@ -37,9 +37,9 @@
37#include <linux/device.h> 37#include <linux/device.h>
38#include <linux/kthread.h> 38#include <linux/kthread.h>
39#include <linux/platform_device.h> 39#include <linux/platform_device.h>
40#include <linux/semaphore.h>
40 41
41#include <asm/uaccess.h> 42#include <asm/uaccess.h>
42#include <asm/semaphore.h>
43#ifdef CONFIG_PPC 43#ifdef CONFIG_PPC
44#include <asm/prom.h> 44#include <asm/prom.h>
45#include <asm/machdep.h> 45#include <asm/machdep.h>
diff --git a/drivers/macintosh/windfarm_smu_sat.c b/drivers/macintosh/windfarm_smu_sat.c
index f449d775cdf4..797918d0e59c 100644
--- a/drivers/macintosh/windfarm_smu_sat.c
+++ b/drivers/macintosh/windfarm_smu_sat.c
@@ -13,7 +13,7 @@
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/wait.h> 14#include <linux/wait.h>
15#include <linux/i2c.h> 15#include <linux/i2c.h>
16#include <asm/semaphore.h> 16#include <linux/semaphore.h>
17#include <asm/prom.h> 17#include <asm/prom.h>
18#include <asm/smu.h> 18#include <asm/smu.h>
19#include <asm/pmac_low_i2c.h> 19#include <asm/pmac_low_i2c.h>
diff --git a/drivers/media/radio/radio-aimslab.c b/drivers/media/radio/radio-aimslab.c
index f0a67e93d7fd..c69bde39a233 100644
--- a/drivers/media/radio/radio-aimslab.c
+++ b/drivers/media/radio/radio-aimslab.c
@@ -36,7 +36,6 @@
36#include <asm/uaccess.h> /* copy to/from user */ 36#include <asm/uaccess.h> /* copy to/from user */
37#include <linux/videodev2.h> /* kernel radio structs */ 37#include <linux/videodev2.h> /* kernel radio structs */
38#include <media/v4l2-common.h> 38#include <media/v4l2-common.h>
39#include <asm/semaphore.h> /* Lock for the I/O */
40 39
41#include <linux/version.h> /* for KERNEL_VERSION MACRO */ 40#include <linux/version.h> /* for KERNEL_VERSION MACRO */
42#define RADIO_VERSION KERNEL_VERSION(0,0,2) 41#define RADIO_VERSION KERNEL_VERSION(0,0,2)
diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c
index 9851987b95fb..dabafdf71e60 100644
--- a/drivers/media/video/ir-kbd-i2c.c
+++ b/drivers/media/video/ir-kbd-i2c.c
@@ -40,7 +40,6 @@
40#include <linux/i2c.h> 40#include <linux/i2c.h>
41#include <linux/i2c-id.h> 41#include <linux/i2c-id.h>
42#include <linux/workqueue.h> 42#include <linux/workqueue.h>
43#include <asm/semaphore.h>
44 43
45#include <media/ir-common.h> 44#include <media/ir-common.h>
46#include <media/ir-kbd-i2c.h> 45#include <media/ir-kbd-i2c.h>
diff --git a/drivers/media/video/ov511.c b/drivers/media/video/ov511.c
index d55d5800efb4..6590058e8ff0 100644
--- a/drivers/media/video/ov511.c
+++ b/drivers/media/video/ov511.c
@@ -41,7 +41,6 @@
41#include <linux/slab.h> 41#include <linux/slab.h>
42#include <linux/ctype.h> 42#include <linux/ctype.h>
43#include <linux/pagemap.h> 43#include <linux/pagemap.h>
44#include <asm/semaphore.h>
45#include <asm/processor.h> 44#include <asm/processor.h>
46#include <linux/mm.h> 45#include <linux/mm.h>
47#include <linux/device.h> 46#include <linux/device.h>
diff --git a/drivers/media/video/pvrusb2/pvrusb2-context.c b/drivers/media/video/pvrusb2/pvrusb2-context.c
index 9d94aed2e12d..160437b21e6d 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-context.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-context.c
@@ -26,7 +26,6 @@
26#include <linux/errno.h> 26#include <linux/errno.h>
27#include <linux/string.h> 27#include <linux/string.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <asm/semaphore.h>
30 29
31 30
32static void pvr2_context_destroy(struct pvr2_context *mp) 31static void pvr2_context_destroy(struct pvr2_context *mp)
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index d6955fa39598..2404053a4d85 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -25,7 +25,6 @@
25#include <linux/firmware.h> 25#include <linux/firmware.h>
26#include <linux/videodev2.h> 26#include <linux/videodev2.h>
27#include <media/v4l2-common.h> 27#include <media/v4l2-common.h>
28#include <asm/semaphore.h>
29#include "pvrusb2.h" 28#include "pvrusb2.h"
30#include "pvrusb2-std.h" 29#include "pvrusb2-std.h"
31#include "pvrusb2-util.h" 30#include "pvrusb2-util.h"
diff --git a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
index 7a1cd878e31a..07f4eae18433 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
@@ -21,7 +21,6 @@
21 21
22#include <linux/string.h> 22#include <linux/string.h>
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <asm/semaphore.h>
25#include "pvrusb2-sysfs.h" 24#include "pvrusb2-sysfs.h"
26#include "pvrusb2-hdw.h" 25#include "pvrusb2-hdw.h"
27#include "pvrusb2-debug.h" 26#include "pvrusb2-debug.h"
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 0c886c882385..2566479937c9 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -22,6 +22,22 @@ config MFD_ASIC3
22 This driver supports the ASIC3 multifunction chip found on many 22 This driver supports the ASIC3 multifunction chip found on many
23 PDAs (mainly iPAQ and HTC based ones) 23 PDAs (mainly iPAQ and HTC based ones)
24 24
25config HTC_EGPIO
26 bool "HTC EGPIO support"
27 depends on GENERIC_HARDIRQS && HAVE_GPIO_LIB
28 help
29 This driver supports the CPLD egpio chip present on
30 several HTC phones. It provides basic support for input
31 pins, output pins, and irqs.
32
33config HTC_PASIC3
34 tristate "HTC PASIC3 LED/DS1WM chip support"
35 help
36 This core driver provides register access for the LED/DS1WM
37 chips labeled "AIC2" and "AIC3", found on HTC Blueangel and
38 HTC Magician devices, respectively. Actual functionality is
39 handled by the leds-pasic3 and ds1wm drivers.
40
25endmenu 41endmenu
26 42
27menu "Multimedia Capabilities Port drivers" 43menu "Multimedia Capabilities Port drivers"
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 521cd5cb68af..eef4e26807df 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -5,6 +5,9 @@
5obj-$(CONFIG_MFD_SM501) += sm501.o 5obj-$(CONFIG_MFD_SM501) += sm501.o
6obj-$(CONFIG_MFD_ASIC3) += asic3.o 6obj-$(CONFIG_MFD_ASIC3) += asic3.o
7 7
8obj-$(CONFIG_HTC_EGPIO) += htc-egpio.o
9obj-$(CONFIG_HTC_PASIC3) += htc-pasic3.o
10
8obj-$(CONFIG_MCP) += mcp-core.o 11obj-$(CONFIG_MCP) += mcp-core.o
9obj-$(CONFIG_MCP_SA11X0) += mcp-sa11x0.o 12obj-$(CONFIG_MCP_SA11X0) += mcp-sa11x0.o
10obj-$(CONFIG_MCP_UCB1200) += ucb1x00-core.o 13obj-$(CONFIG_MCP_UCB1200) += ucb1x00-core.o
diff --git a/drivers/mfd/htc-egpio.c b/drivers/mfd/htc-egpio.c
new file mode 100644
index 000000000000..8872cc077519
--- /dev/null
+++ b/drivers/mfd/htc-egpio.c
@@ -0,0 +1,440 @@
1/*
2 * Support for the GPIO/IRQ expander chips present on several HTC phones.
3 * These are implemented in CPLD chips present on the board.
4 *
5 * Copyright (c) 2007 Kevin O'Connor <kevin@koconnor.net>
6 * Copyright (c) 2007 Philipp Zabel <philipp.zabel@gmail.com>
7 *
8 * This file may be distributed under the terms of the GNU GPL license.
9 */
10
11#include <linux/kernel.h>
12#include <linux/errno.h>
13#include <linux/interrupt.h>
14#include <linux/irq.h>
15#include <linux/io.h>
16#include <linux/spinlock.h>
17#include <linux/platform_device.h>
18#include <linux/module.h>
19#include <linux/mfd/htc-egpio.h>
20
21struct egpio_chip {
22 int reg_start;
23 int cached_values;
24 unsigned long is_out;
25 struct device *dev;
26 struct gpio_chip chip;
27};
28
29struct egpio_info {
30 spinlock_t lock;
31
32 /* iomem info */
33 void __iomem *base_addr;
34 int bus_shift; /* byte shift */
35 int reg_shift; /* bit shift */
36 int reg_mask;
37
38 /* irq info */
39 int ack_register;
40 int ack_write;
41 u16 irqs_enabled;
42 uint irq_start;
43 int nirqs;
44 uint chained_irq;
45
46 /* egpio info */
47 struct egpio_chip *chip;
48 int nchips;
49};
50
51static inline void egpio_writew(u16 value, struct egpio_info *ei, int reg)
52{
53 writew(value, ei->base_addr + (reg << ei->bus_shift));
54}
55
56static inline u16 egpio_readw(struct egpio_info *ei, int reg)
57{
58 return readw(ei->base_addr + (reg << ei->bus_shift));
59}
60
61/*
62 * IRQs
63 */
64
65static inline void ack_irqs(struct egpio_info *ei)
66{
67 egpio_writew(ei->ack_write, ei, ei->ack_register);
68 pr_debug("EGPIO ack - write %x to base+%x\n",
69 ei->ack_write, ei->ack_register << ei->bus_shift);
70}
71
72static void egpio_ack(unsigned int irq)
73{
74}
75
76/* There does not appear to be a way to proactively mask interrupts
77 * on the egpio chip itself. So, we simply ignore interrupts that
78 * aren't desired. */
79static void egpio_mask(unsigned int irq)
80{
81 struct egpio_info *ei = get_irq_chip_data(irq);
82 ei->irqs_enabled &= ~(1 << (irq - ei->irq_start));
83 pr_debug("EGPIO mask %d %04x\n", irq, ei->irqs_enabled);
84}
85static void egpio_unmask(unsigned int irq)
86{
87 struct egpio_info *ei = get_irq_chip_data(irq);
88 ei->irqs_enabled |= 1 << (irq - ei->irq_start);
89 pr_debug("EGPIO unmask %d %04x\n", irq, ei->irqs_enabled);
90}
91
92static struct irq_chip egpio_muxed_chip = {
93 .name = "htc-egpio",
94 .ack = egpio_ack,
95 .mask = egpio_mask,
96 .unmask = egpio_unmask,
97};
98
99static void egpio_handler(unsigned int irq, struct irq_desc *desc)
100{
101 struct egpio_info *ei = get_irq_data(irq);
102 int irqpin;
103
104 /* Read current pins. */
105 unsigned long readval = egpio_readw(ei, ei->ack_register);
106 pr_debug("IRQ reg: %x\n", (unsigned int)readval);
107 /* Ack/unmask interrupts. */
108 ack_irqs(ei);
109 /* Process all set pins. */
110 readval &= ei->irqs_enabled;
111 for_each_bit(irqpin, &readval, ei->nirqs) {
112 /* Run irq handler */
113 pr_debug("got IRQ %d\n", irqpin);
114 irq = ei->irq_start + irqpin;
115 desc = &irq_desc[irq];
116 desc->handle_irq(irq, desc);
117 }
118}
119
120int htc_egpio_get_wakeup_irq(struct device *dev)
121{
122 struct egpio_info *ei = dev_get_drvdata(dev);
123
124 /* Read current pins. */
125 u16 readval = egpio_readw(ei, ei->ack_register);
126 /* Ack/unmask interrupts. */
127 ack_irqs(ei);
128 /* Return first set pin. */
129 readval &= ei->irqs_enabled;
130 return ei->irq_start + ffs(readval) - 1;
131}
132EXPORT_SYMBOL(htc_egpio_get_wakeup_irq);
133
134static inline int egpio_pos(struct egpio_info *ei, int bit)
135{
136 return bit >> ei->reg_shift;
137}
138
139static inline int egpio_bit(struct egpio_info *ei, int bit)
140{
141 return 1 << (bit & ((1 << ei->reg_shift)-1));
142}
143
144/*
145 * Input pins
146 */
147
148static int egpio_get(struct gpio_chip *chip, unsigned offset)
149{
150 struct egpio_chip *egpio;
151 struct egpio_info *ei;
152 unsigned bit;
153 int reg;
154 int value;
155
156 pr_debug("egpio_get_value(%d)\n", chip->base + offset);
157
158 egpio = container_of(chip, struct egpio_chip, chip);
159 ei = dev_get_drvdata(egpio->dev);
160 bit = egpio_bit(ei, offset);
161 reg = egpio->reg_start + egpio_pos(ei, offset);
162
163 value = egpio_readw(ei, reg);
164 pr_debug("readw(%p + %x) = %x\n",
165 ei->base_addr, reg << ei->bus_shift, value);
166 return value & bit;
167}
168
169static int egpio_direction_input(struct gpio_chip *chip, unsigned offset)
170{
171 struct egpio_chip *egpio;
172
173 egpio = container_of(chip, struct egpio_chip, chip);
174 return test_bit(offset, &egpio->is_out) ? -EINVAL : 0;
175}
176
177
178/*
179 * Output pins
180 */
181
182static void egpio_set(struct gpio_chip *chip, unsigned offset, int value)
183{
184 unsigned long flag;
185 struct egpio_chip *egpio;
186 struct egpio_info *ei;
187 unsigned bit;
188 int pos;
189 int reg;
190 int shift;
191
192 pr_debug("egpio_set(%s, %d(%d), %d)\n",
193 chip->label, offset, offset+chip->base, value);
194
195 egpio = container_of(chip, struct egpio_chip, chip);
196 ei = dev_get_drvdata(egpio->dev);
197 bit = egpio_bit(ei, offset);
198 pos = egpio_pos(ei, offset);
199 reg = egpio->reg_start + pos;
200 shift = pos << ei->reg_shift;
201
202 pr_debug("egpio %s: reg %d = 0x%04x\n", value ? "set" : "clear",
203 reg, (egpio->cached_values >> shift) & ei->reg_mask);
204
205 spin_lock_irqsave(&ei->lock, flag);
206 if (value)
207 egpio->cached_values |= (1 << offset);
208 else
209 egpio->cached_values &= ~(1 << offset);
210 egpio_writew((egpio->cached_values >> shift) & ei->reg_mask, ei, reg);
211 spin_unlock_irqrestore(&ei->lock, flag);
212}
213
214static int egpio_direction_output(struct gpio_chip *chip,
215 unsigned offset, int value)
216{
217 struct egpio_chip *egpio;
218
219 egpio = container_of(chip, struct egpio_chip, chip);
220 if (test_bit(offset, &egpio->is_out)) {
221 egpio_set(chip, offset, value);
222 return 0;
223 } else {
224 return -EINVAL;
225 }
226}
227
228static void egpio_write_cache(struct egpio_info *ei)
229{
230 int i;
231 struct egpio_chip *egpio;
232 int shift;
233
234 for (i = 0; i < ei->nchips; i++) {
235 egpio = &(ei->chip[i]);
236 if (!egpio->is_out)
237 continue;
238
239 for (shift = 0; shift < egpio->chip.ngpio;
240 shift += (1<<ei->reg_shift)) {
241
242 int reg = egpio->reg_start + egpio_pos(ei, shift);
243
244 if (!((egpio->is_out >> shift) & ei->reg_mask))
245 continue;
246
247 pr_debug("EGPIO: setting %x to %x, was %x\n", reg,
248 (egpio->cached_values >> shift) & ei->reg_mask,
249 egpio_readw(ei, reg));
250
251 egpio_writew((egpio->cached_values >> shift)
252 & ei->reg_mask, ei, reg);
253 }
254 }
255}
256
257
258/*
259 * Setup
260 */
261
262static int __init egpio_probe(struct platform_device *pdev)
263{
264 struct htc_egpio_platform_data *pdata = pdev->dev.platform_data;
265 struct resource *res;
266 struct egpio_info *ei;
267 struct gpio_chip *chip;
268 unsigned int irq, irq_end;
269 int i;
270 int ret;
271
272 /* Initialize ei data structure. */
273 ei = kzalloc(sizeof(*ei), GFP_KERNEL);
274 if (!ei)
275 return -ENOMEM;
276
277 spin_lock_init(&ei->lock);
278
279 /* Find chained irq */
280 ret = -EINVAL;
281 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
282 if (res)
283 ei->chained_irq = res->start;
284
285 /* Map egpio chip into virtual address space. */
286 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
287 if (!res)
288 goto fail;
289 ei->base_addr = ioremap_nocache(res->start, res->end - res->start);
290 if (!ei->base_addr)
291 goto fail;
292 pr_debug("EGPIO phys=%08x virt=%p\n", res->start, ei->base_addr);
293
294 if ((pdata->bus_width != 16) && (pdata->bus_width != 32))
295 goto fail;
296 ei->bus_shift = fls(pdata->bus_width - 1) - 3;
297 pr_debug("bus_shift = %d\n", ei->bus_shift);
298
299 if ((pdata->reg_width != 8) && (pdata->reg_width != 16))
300 goto fail;
301 ei->reg_shift = fls(pdata->reg_width - 1);
302 pr_debug("reg_shift = %d\n", ei->reg_shift);
303
304 ei->reg_mask = (1 << pdata->reg_width) - 1;
305
306 platform_set_drvdata(pdev, ei);
307
308 ei->nchips = pdata->num_chips;
309 ei->chip = kzalloc(sizeof(struct egpio_chip) * ei->nchips, GFP_KERNEL);
310 if (!ei) {
311 ret = -ENOMEM;
312 goto fail;
313 }
314 for (i = 0; i < ei->nchips; i++) {
315 ei->chip[i].reg_start = pdata->chip[i].reg_start;
316 ei->chip[i].cached_values = pdata->chip[i].initial_values;
317 ei->chip[i].is_out = pdata->chip[i].direction;
318 ei->chip[i].dev = &(pdev->dev);
319 chip = &(ei->chip[i].chip);
320 chip->label = "htc-egpio";
321 chip->get = egpio_get;
322 chip->set = egpio_set;
323 chip->direction_input = egpio_direction_input;
324 chip->direction_output = egpio_direction_output;
325 chip->base = pdata->chip[i].gpio_base;
326 chip->ngpio = pdata->chip[i].num_gpios;
327
328 gpiochip_add(chip);
329 }
330
331 /* Set initial pin values */
332 egpio_write_cache(ei);
333
334 ei->irq_start = pdata->irq_base;
335 ei->nirqs = pdata->num_irqs;
336 ei->ack_register = pdata->ack_register;
337
338 if (ei->chained_irq) {
339 /* Setup irq handlers */
340 ei->ack_write = 0xFFFF;
341 if (pdata->invert_acks)
342 ei->ack_write = 0;
343 irq_end = ei->irq_start + ei->nirqs;
344 for (irq = ei->irq_start; irq < irq_end; irq++) {
345 set_irq_chip(irq, &egpio_muxed_chip);
346 set_irq_chip_data(irq, ei);
347 set_irq_handler(irq, handle_simple_irq);
348 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
349 }
350 set_irq_type(ei->chained_irq, IRQ_TYPE_EDGE_RISING);
351 set_irq_data(ei->chained_irq, ei);
352 set_irq_chained_handler(ei->chained_irq, egpio_handler);
353 ack_irqs(ei);
354
355 device_init_wakeup(&pdev->dev, 1);
356 }
357
358 return 0;
359
360fail:
361 printk(KERN_ERR "EGPIO failed to setup\n");
362 kfree(ei);
363 return ret;
364}
365
366static int __exit egpio_remove(struct platform_device *pdev)
367{
368 struct egpio_info *ei = platform_get_drvdata(pdev);
369 unsigned int irq, irq_end;
370
371 if (ei->chained_irq) {
372 irq_end = ei->irq_start + ei->nirqs;
373 for (irq = ei->irq_start; irq < irq_end; irq++) {
374 set_irq_chip(irq, NULL);
375 set_irq_handler(irq, NULL);
376 set_irq_flags(irq, 0);
377 }
378 set_irq_chained_handler(ei->chained_irq, NULL);
379 device_init_wakeup(&pdev->dev, 0);
380 }
381 iounmap(ei->base_addr);
382 kfree(ei->chip);
383 kfree(ei);
384
385 return 0;
386}
387
388#ifdef CONFIG_PM
389static int egpio_suspend(struct platform_device *pdev, pm_message_t state)
390{
391 struct egpio_info *ei = platform_get_drvdata(pdev);
392
393 if (ei->chained_irq && device_may_wakeup(&pdev->dev))
394 enable_irq_wake(ei->chained_irq);
395 return 0;
396}
397
398static int egpio_resume(struct platform_device *pdev)
399{
400 struct egpio_info *ei = platform_get_drvdata(pdev);
401
402 if (ei->chained_irq && device_may_wakeup(&pdev->dev))
403 disable_irq_wake(ei->chained_irq);
404
405 /* Update registers from the cache, in case
406 the CPLD was powered off during suspend */
407 egpio_write_cache(ei);
408 return 0;
409}
410#else
411#define egpio_suspend NULL
412#define egpio_resume NULL
413#endif
414
415
416static struct platform_driver egpio_driver = {
417 .driver = {
418 .name = "htc-egpio",
419 },
420 .remove = __exit_p(egpio_remove),
421 .suspend = egpio_suspend,
422 .resume = egpio_resume,
423};
424
425static int __init egpio_init(void)
426{
427 return platform_driver_probe(&egpio_driver, egpio_probe);
428}
429
430static void __exit egpio_exit(void)
431{
432 platform_driver_unregister(&egpio_driver);
433}
434
435/* start early for dependencies */
436subsys_initcall(egpio_init);
437module_exit(egpio_exit)
438
439MODULE_LICENSE("GPL");
440MODULE_AUTHOR("Kevin O'Connor <kevin@koconnor.net>");
diff --git a/drivers/mfd/htc-pasic3.c b/drivers/mfd/htc-pasic3.c
new file mode 100644
index 000000000000..af66f4f28300
--- /dev/null
+++ b/drivers/mfd/htc-pasic3.c
@@ -0,0 +1,265 @@
1/*
2 * Core driver for HTC PASIC3 LED/DS1WM chip.
3 *
4 * Copyright (C) 2006 Philipp Zabel <philipp.zabel@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 */
10
11#include <linux/init.h>
12#include <linux/module.h>
13#include <linux/platform_device.h>
14
15#include <linux/ds1wm.h>
16#include <linux/gpio.h>
17#include <linux/io.h>
18#include <linux/irq.h>
19#include <linux/interrupt.h>
20#include <linux/mfd/htc-pasic3.h>
21
22#include <asm/arch/pxa-regs.h>
23
24struct pasic3_data {
25 void __iomem *mapping;
26 unsigned int bus_shift;
27 struct platform_device *ds1wm_pdev;
28 struct platform_device *led_pdev;
29};
30
31#define REG_ADDR 5
32#define REG_DATA 6
33#define NUM_REGS 7
34
35#define READ_MODE 0x80
36
37/*
38 * write to a secondary register on the PASIC3
39 */
40void pasic3_write_register(struct device *dev, u32 reg, u8 val)
41{
42 struct pasic3_data *asic = dev->driver_data;
43 int bus_shift = asic->bus_shift;
44 void __iomem *addr = asic->mapping + (REG_ADDR << bus_shift);
45 void __iomem *data = asic->mapping + (REG_DATA << bus_shift);
46
47 __raw_writeb(~READ_MODE & reg, addr);
48 __raw_writeb(val, data);
49}
50EXPORT_SYMBOL(pasic3_write_register); /* for leds-pasic3 */
51
52/*
53 * read from a secondary register on the PASIC3
54 */
55u8 pasic3_read_register(struct device *dev, u32 reg)
56{
57 struct pasic3_data *asic = dev->driver_data;
58 int bus_shift = asic->bus_shift;
59 void __iomem *addr = asic->mapping + (REG_ADDR << bus_shift);
60 void __iomem *data = asic->mapping + (REG_DATA << bus_shift);
61
62 __raw_writeb(READ_MODE | reg, addr);
63 return __raw_readb(data);
64}
65EXPORT_SYMBOL(pasic3_read_register); /* for leds-pasic3 */
66
67/*
68 * LEDs
69 */
70
71static int led_device_add(struct device *pasic3_dev,
72 const struct pasic3_leds_machinfo *pdata)
73{
74 struct pasic3_data *asic = pasic3_dev->driver_data;
75 struct platform_device *pdev;
76 int ret;
77
78 pdev = platform_device_alloc("pasic3-led", -1);
79 if (!pdev) {
80 dev_dbg(pasic3_dev, "failed to allocate LED platform device\n");
81 return -ENOMEM;
82 }
83
84 ret = platform_device_add_data(pdev, pdata,
85 sizeof(struct pasic3_leds_machinfo));
86 if (ret < 0) {
87 dev_dbg(pasic3_dev, "failed to add LED platform data\n");
88 goto exit_pdev_put;
89 }
90
91 pdev->dev.parent = pasic3_dev;
92 ret = platform_device_add(pdev);
93 if (ret < 0) {
94 dev_dbg(pasic3_dev, "failed to add LED platform device\n");
95 goto exit_pdev_put;
96 }
97
98 asic->led_pdev = pdev;
99 return 0;
100
101exit_pdev_put:
102 platform_device_put(pdev);
103 return ret;
104}
105
106/*
107 * DS1WM
108 */
109
110static void ds1wm_enable(struct platform_device *pdev)
111{
112 struct device *dev = pdev->dev.parent;
113 int c;
114
115 c = pasic3_read_register(dev, 0x28);
116 pasic3_write_register(dev, 0x28, c & 0x7f);
117
118 dev_dbg(dev, "DS1WM OWM_EN low (active) %02x\n", c & 0x7f);
119}
120
121static void ds1wm_disable(struct platform_device *pdev)
122{
123 struct device *dev = pdev->dev.parent;
124 int c;
125
126 c = pasic3_read_register(dev, 0x28);
127 pasic3_write_register(dev, 0x28, c | 0x80);
128
129 dev_dbg(dev, "DS1WM OWM_EN high (inactive) %02x\n", c | 0x80);
130}
131
132static struct ds1wm_platform_data ds1wm_pdata = {
133 .bus_shift = 2,
134 .enable = ds1wm_enable,
135 .disable = ds1wm_disable,
136};
137
138static int ds1wm_device_add(struct device *pasic3_dev, int bus_shift)
139{
140 struct pasic3_data *asic = pasic3_dev->driver_data;
141 struct platform_device *pdev;
142 int ret;
143
144 pdev = platform_device_alloc("ds1wm", -1);
145 if (!pdev) {
146 dev_dbg(pasic3_dev, "failed to allocate DS1WM platform device\n");
147 return -ENOMEM;
148 }
149
150 ret = platform_device_add_resources(pdev, pdev->resource,
151 pdev->num_resources);
152 if (ret < 0) {
153 dev_dbg(pasic3_dev, "failed to add DS1WM resources\n");
154 goto exit_pdev_put;
155 }
156
157 ds1wm_pdata.bus_shift = asic->bus_shift;
158 ret = platform_device_add_data(pdev, &ds1wm_pdata,
159 sizeof(struct ds1wm_platform_data));
160 if (ret < 0) {
161 dev_dbg(pasic3_dev, "failed to add DS1WM platform data\n");
162 goto exit_pdev_put;
163 }
164
165 pdev->dev.parent = pasic3_dev;
166 ret = platform_device_add(pdev);
167 if (ret < 0) {
168 dev_dbg(pasic3_dev, "failed to add DS1WM platform device\n");
169 goto exit_pdev_put;
170 }
171
172 asic->ds1wm_pdev = pdev;
173 return 0;
174
175exit_pdev_put:
176 platform_device_put(pdev);
177 return ret;
178}
179
180static int __init pasic3_probe(struct platform_device *pdev)
181{
182 struct pasic3_platform_data *pdata = pdev->dev.platform_data;
183 struct device *dev = &pdev->dev;
184 struct pasic3_data *asic;
185 struct resource *r;
186 int ret;
187
188 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
189 if (!r)
190 return -ENXIO;
191
192 if (!request_mem_region(r->start, r->end - r->start + 1, "pasic3"))
193 return -EBUSY;
194
195 asic = kzalloc(sizeof(struct pasic3_data), GFP_KERNEL);
196 if (!asic)
197 return -ENOMEM;
198
199 platform_set_drvdata(pdev, asic);
200
201 if (pdata && pdata->bus_shift)
202 asic->bus_shift = pdata->bus_shift;
203 else
204 asic->bus_shift = 2;
205
206 asic->mapping = ioremap(r->start, r->end - r->start + 1);
207 if (!asic->mapping) {
208 dev_err(dev, "couldn't ioremap PASIC3\n");
209 kfree(asic);
210 return -ENOMEM;
211 }
212
213 ret = ds1wm_device_add(dev, asic->bus_shift);
214 if (ret < 0)
215 dev_warn(dev, "failed to register DS1WM\n");
216
217 if (pdata->led_pdata) {
218 ret = led_device_add(dev, pdata->led_pdata);
219 if (ret < 0)
220 dev_warn(dev, "failed to register LED device\n");
221 }
222
223 return 0;
224}
225
226static int pasic3_remove(struct platform_device *pdev)
227{
228 struct pasic3_data *asic = platform_get_drvdata(pdev);
229 struct resource *r;
230
231 if (asic->led_pdev)
232 platform_device_unregister(asic->led_pdev);
233 if (asic->ds1wm_pdev)
234 platform_device_unregister(asic->ds1wm_pdev);
235
236 iounmap(asic->mapping);
237 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
238 release_mem_region(r->start, r->end - r->start + 1);
239 kfree(asic);
240 return 0;
241}
242
243static struct platform_driver pasic3_driver = {
244 .driver = {
245 .name = "pasic3",
246 },
247 .remove = pasic3_remove,
248};
249
250static int __init pasic3_base_init(void)
251{
252 return platform_driver_probe(&pasic3_driver, pasic3_probe);
253}
254
255static void __exit pasic3_base_exit(void)
256{
257 platform_driver_unregister(&pasic3_driver);
258}
259
260module_init(pasic3_base_init);
261module_exit(pasic3_base_exit);
262
263MODULE_AUTHOR("Philipp Zabel <philipp.zabel@gmail.com>");
264MODULE_DESCRIPTION("Core driver for HTC PASIC3");
265MODULE_LICENSE("GPL");
diff --git a/drivers/mfd/ucb1x00-ts.c b/drivers/mfd/ucb1x00-ts.c
index fdbaa776f249..5e859486eaf8 100644
--- a/drivers/mfd/ucb1x00-ts.c
+++ b/drivers/mfd/ucb1x00-ts.c
@@ -32,7 +32,6 @@
32#include <linux/kthread.h> 32#include <linux/kthread.h>
33 33
34#include <asm/dma.h> 34#include <asm/dma.h>
35#include <asm/semaphore.h>
36#include <asm/arch/collie.h> 35#include <asm/arch/collie.h>
37#include <asm/mach-types.h> 36#include <asm/mach-types.h>
38 37
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 962817e49fba..bb94ce78a6d0 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -22,6 +22,39 @@ config ATMEL_PWM
22 purposes including software controlled power-efficent backlights 22 purposes including software controlled power-efficent backlights
23 on LCD displays, motor control, and waveform generation. 23 on LCD displays, motor control, and waveform generation.
24 24
25config ATMEL_TCLIB
26 bool "Atmel AT32/AT91 Timer/Counter Library"
27 depends on (AVR32 || ARCH_AT91)
28 help
29 Select this if you want a library to allocate the Timer/Counter
30 blocks found on many Atmel processors. This facilitates using
31 these blocks by different drivers despite processor differences.
32
33config ATMEL_TCB_CLKSRC
34 bool "TC Block Clocksource"
35 depends on ATMEL_TCLIB && GENERIC_TIME
36 default y
37 help
38 Select this to get a high precision clocksource based on a
39 TC block with a 5+ MHz base clock rate. Two timer channels
40 are combined to make a single 32-bit timer.
41
42 When GENERIC_CLOCKEVENTS is defined, the third timer channel
43 may be used as a clock event device supporting oneshot mode
44 (delays of up to two seconds) based on the 32 KiHz clock.
45
46config ATMEL_TCB_CLKSRC_BLOCK
47 int
48 depends on ATMEL_TCB_CLKSRC
49 prompt "TC Block" if ARCH_AT91RM9200 || ARCH_AT91SAM9260 || CPU_AT32AP700X
50 default 0
51 range 0 1
52 help
53 Some chips provide more than one TC block, so you have the
54 choice of which one to use for the clock framework. The other
55 TC can be used for other purposes, such as PWM generation and
56 interval timing.
57
25config IBM_ASM 58config IBM_ASM
26 tristate "Device driver for IBM RSA service processor" 59 tristate "Device driver for IBM RSA service processor"
27 depends on X86 && PCI && INPUT && EXPERIMENTAL 60 depends on X86 && PCI && INPUT && EXPERIMENTAL
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index bbc69fdd1b9d..4581b2533111 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -10,6 +10,7 @@ obj-$(CONFIG_ACER_WMI) += acer-wmi.o
10obj-$(CONFIG_ASUS_LAPTOP) += asus-laptop.o 10obj-$(CONFIG_ASUS_LAPTOP) += asus-laptop.o
11obj-$(CONFIG_ATMEL_PWM) += atmel_pwm.o 11obj-$(CONFIG_ATMEL_PWM) += atmel_pwm.o
12obj-$(CONFIG_ATMEL_SSC) += atmel-ssc.o 12obj-$(CONFIG_ATMEL_SSC) += atmel-ssc.o
13obj-$(CONFIG_ATMEL_TCLIB) += atmel_tclib.o
13obj-$(CONFIG_TC1100_WMI) += tc1100-wmi.o 14obj-$(CONFIG_TC1100_WMI) += tc1100-wmi.o
14obj-$(CONFIG_LKDTM) += lkdtm.o 15obj-$(CONFIG_LKDTM) += lkdtm.o
15obj-$(CONFIG_TIFM_CORE) += tifm_core.o 16obj-$(CONFIG_TIFM_CORE) += tifm_core.o
diff --git a/drivers/misc/atmel_tclib.c b/drivers/misc/atmel_tclib.c
new file mode 100644
index 000000000000..05dc8a31f280
--- /dev/null
+++ b/drivers/misc/atmel_tclib.c
@@ -0,0 +1,161 @@
1#include <linux/atmel_tc.h>
2#include <linux/clk.h>
3#include <linux/err.h>
4#include <linux/init.h>
5#include <linux/io.h>
6#include <linux/ioport.h>
7#include <linux/kernel.h>
8#include <linux/platform_device.h>
9
10/* Number of bytes to reserve for the iomem resource */
11#define ATMEL_TC_IOMEM_SIZE 256
12
13
14/*
15 * This is a thin library to solve the problem of how to portably allocate
16 * one of the TC blocks. For simplicity, it doesn't currently expect to
17 * share individual timers between different drivers.
18 */
19
20#if defined(CONFIG_AVR32)
21/* AVR32 has these divide PBB */
22const u8 atmel_tc_divisors[5] = { 0, 4, 8, 16, 32, };
23EXPORT_SYMBOL(atmel_tc_divisors);
24
25#elif defined(CONFIG_ARCH_AT91)
26/* AT91 has these divide MCK */
27const u8 atmel_tc_divisors[5] = { 2, 8, 32, 128, 0, };
28EXPORT_SYMBOL(atmel_tc_divisors);
29
30#endif
31
32static DEFINE_SPINLOCK(tc_list_lock);
33static LIST_HEAD(tc_list);
34
35/**
36 * atmel_tc_alloc - allocate a specified TC block
37 * @block: which block to allocate
38 * @name: name to be associated with the iomem resource
39 *
40 * Caller allocates a block. If it is available, a pointer to a
41 * pre-initialized struct atmel_tc is returned. The caller can access
42 * the registers directly through the "regs" field.
43 */
44struct atmel_tc *atmel_tc_alloc(unsigned block, const char *name)
45{
46 struct atmel_tc *tc;
47 struct platform_device *pdev = NULL;
48 struct resource *r;
49
50 spin_lock(&tc_list_lock);
51 list_for_each_entry(tc, &tc_list, node) {
52 if (tc->pdev->id == block) {
53 pdev = tc->pdev;
54 break;
55 }
56 }
57
58 if (!pdev || tc->iomem)
59 goto fail;
60
61 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
62 r = request_mem_region(r->start, ATMEL_TC_IOMEM_SIZE, name);
63 if (!r)
64 goto fail;
65
66 tc->regs = ioremap(r->start, ATMEL_TC_IOMEM_SIZE);
67 if (!tc->regs)
68 goto fail_ioremap;
69
70 tc->iomem = r;
71
72out:
73 spin_unlock(&tc_list_lock);
74 return tc;
75
76fail_ioremap:
77 release_resource(r);
78fail:
79 tc = NULL;
80 goto out;
81}
82EXPORT_SYMBOL_GPL(atmel_tc_alloc);
83
84/**
85 * atmel_tc_free - release a specified TC block
86 * @tc: Timer/counter block that was returned by atmel_tc_alloc()
87 *
88 * This reverses the effect of atmel_tc_alloc(), unmapping the I/O
89 * registers, invalidating the resource returned by that routine and
90 * making the TC available to other drivers.
91 */
92void atmel_tc_free(struct atmel_tc *tc)
93{
94 spin_lock(&tc_list_lock);
95 if (tc->regs) {
96 iounmap(tc->regs);
97 release_resource(tc->iomem);
98 tc->regs = NULL;
99 tc->iomem = NULL;
100 }
101 spin_unlock(&tc_list_lock);
102}
103EXPORT_SYMBOL_GPL(atmel_tc_free);
104
105static int __init tc_probe(struct platform_device *pdev)
106{
107 struct atmel_tc *tc;
108 struct clk *clk;
109 int irq;
110
111 if (!platform_get_resource(pdev, IORESOURCE_MEM, 0))
112 return -EINVAL;
113
114 irq = platform_get_irq(pdev, 0);
115 if (irq < 0)
116 return -EINVAL;
117
118 tc = kzalloc(sizeof(struct atmel_tc), GFP_KERNEL);
119 if (!tc)
120 return -ENOMEM;
121
122 tc->pdev = pdev;
123
124 clk = clk_get(&pdev->dev, "t0_clk");
125 if (IS_ERR(clk)) {
126 kfree(tc);
127 return -EINVAL;
128 }
129
130 tc->clk[0] = clk;
131 tc->clk[1] = clk_get(&pdev->dev, "t1_clk");
132 if (IS_ERR(tc->clk[1]))
133 tc->clk[1] = clk;
134 tc->clk[2] = clk_get(&pdev->dev, "t2_clk");
135 if (IS_ERR(tc->clk[2]))
136 tc->clk[2] = clk;
137
138 tc->irq[0] = irq;
139 tc->irq[1] = platform_get_irq(pdev, 1);
140 if (tc->irq[1] < 0)
141 tc->irq[1] = irq;
142 tc->irq[2] = platform_get_irq(pdev, 2);
143 if (tc->irq[2] < 0)
144 tc->irq[2] = irq;
145
146 spin_lock(&tc_list_lock);
147 list_add_tail(&tc->node, &tc_list);
148 spin_unlock(&tc_list_lock);
149
150 return 0;
151}
152
153static struct platform_driver tc_driver = {
154 .driver.name = "atmel_tcb",
155};
156
157static int __init tc_init(void)
158{
159 return platform_driver_probe(&tc_driver, tc_probe);
160}
161arch_initcall(tc_init);
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 4a3c6759492b..959fb86cda01 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -314,7 +314,7 @@ config MTD_ALAUDA
314 314
315config MTD_NAND_ORION 315config MTD_NAND_ORION
316 tristate "NAND Flash support for Marvell Orion SoC" 316 tristate "NAND Flash support for Marvell Orion SoC"
317 depends on ARCH_ORION && MTD_NAND 317 depends on PLAT_ORION && MTD_NAND
318 help 318 help
319 This enables the NAND flash controller on Orion machines. 319 This enables the NAND flash controller on Orion machines.
320 320
diff --git a/drivers/mtd/nand/orion_nand.c b/drivers/mtd/nand/orion_nand.c
index 9162cca0182b..ec5ad28b237e 100644
--- a/drivers/mtd/nand/orion_nand.c
+++ b/drivers/mtd/nand/orion_nand.c
@@ -18,8 +18,8 @@
18#include <linux/mtd/partitions.h> 18#include <linux/mtd/partitions.h>
19#include <asm/io.h> 19#include <asm/io.h>
20#include <asm/sizes.h> 20#include <asm/sizes.h>
21#include <asm/arch/platform.h>
22#include <asm/arch/hardware.h> 21#include <asm/arch/hardware.h>
22#include <asm/plat-orion/orion_nand.h>
23 23
24#ifdef CONFIG_MTD_CMDLINE_PARTS 24#ifdef CONFIG_MTD_CMDLINE_PARTS
25static const char *part_probes[] = { "cmdlinepart", NULL }; 25static const char *part_probes[] = { "cmdlinepart", NULL };
diff --git a/drivers/net/3c527.c b/drivers/net/3c527.c
index b72b89d53ec8..fae295b6809c 100644
--- a/drivers/net/3c527.c
+++ b/drivers/net/3c527.c
@@ -103,8 +103,8 @@ DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " Richard Procter <rnp@paradise.net.
103#include <linux/ethtool.h> 103#include <linux/ethtool.h>
104#include <linux/completion.h> 104#include <linux/completion.h>
105#include <linux/bitops.h> 105#include <linux/bitops.h>
106#include <linux/semaphore.h>
106 107
107#include <asm/semaphore.h>
108#include <asm/uaccess.h> 108#include <asm/uaccess.h>
109#include <asm/system.h> 109#include <asm/system.h>
110#include <asm/io.h> 110#include <asm/io.h>
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 45c3a208d93f..2399a3796f6e 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -2335,7 +2335,7 @@ config UGETH_TX_ON_DEMAND
2335 2335
2336config MV643XX_ETH 2336config MV643XX_ETH
2337 tristate "Marvell Discovery (643XX) and Orion ethernet support" 2337 tristate "Marvell Discovery (643XX) and Orion ethernet support"
2338 depends on MV64360 || MV64X60 || (PPC_MULTIPLATFORM && PPC32) || ARCH_ORION 2338 depends on MV64360 || MV64X60 || (PPC_MULTIPLATFORM && PPC32) || PLAT_ORION
2339 select MII 2339 select MII
2340 help 2340 help
2341 This driver supports the gigabit ethernet MACs in the 2341 This driver supports the gigabit ethernet MACs in the
diff --git a/drivers/net/appletalk/cops.c b/drivers/net/appletalk/cops.c
index 65b901ebfd62..82e9a5bd0dd2 100644
--- a/drivers/net/appletalk/cops.c
+++ b/drivers/net/appletalk/cops.c
@@ -69,6 +69,7 @@ static const char *version =
69#include <linux/atalk.h> 69#include <linux/atalk.h>
70#include <linux/spinlock.h> 70#include <linux/spinlock.h>
71#include <linux/bitops.h> 71#include <linux/bitops.h>
72#include <linux/jiffies.h>
72 73
73#include <asm/system.h> 74#include <asm/system.h>
74#include <asm/io.h> 75#include <asm/io.h>
@@ -503,7 +504,7 @@ static void cops_reset(struct net_device *dev, int sleep)
503 long snap=jiffies; 504 long snap=jiffies;
504 505
505 /* Let card finish initializing, about 1/3 second */ 506 /* Let card finish initializing, about 1/3 second */
506 while(jiffies-snap<HZ/3) 507 while (time_before(jiffies, snap + HZ/3))
507 schedule(); 508 schedule();
508 } 509 }
509 else 510 else
diff --git a/drivers/net/arm/at91_ether.c b/drivers/net/arm/at91_ether.c
index 0ae0d83e5d22..978e20a1791b 100644
--- a/drivers/net/arm/at91_ether.c
+++ b/drivers/net/arm/at91_ether.c
@@ -1043,7 +1043,9 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add
1043 } else if (machine_is_csb337()) { 1043 } else if (machine_is_csb337()) {
1044 /* mix link activity status into LED2 link state */ 1044 /* mix link activity status into LED2 link state */
1045 write_phy(phy_address, MII_LEDCTRL_REG, 0x0d22); 1045 write_phy(phy_address, MII_LEDCTRL_REG, 0x0d22);
1046 } 1046 } else if (machine_is_ecbat91())
1047 write_phy(phy_address, MII_LEDCTRL_REG, 0x156A);
1048
1047 disable_mdi(); 1049 disable_mdi();
1048 spin_unlock_irq(&lp->lock); 1050 spin_unlock_irq(&lp->lock);
1049 1051
diff --git a/drivers/net/cxgb3/adapter.h b/drivers/net/cxgb3/adapter.h
index eb305a0895fc..4fdb13f8447b 100644
--- a/drivers/net/cxgb3/adapter.h
+++ b/drivers/net/cxgb3/adapter.h
@@ -43,7 +43,6 @@
43#include <linux/mutex.h> 43#include <linux/mutex.h>
44#include <linux/bitops.h> 44#include <linux/bitops.h>
45#include "t3cdev.h" 45#include "t3cdev.h"
46#include <asm/semaphore.h>
47#include <asm/io.h> 46#include <asm/io.h>
48 47
49struct vlan_group; 48struct vlan_group;
diff --git a/drivers/net/cxgb3/t3cdev.h b/drivers/net/cxgb3/t3cdev.h
index 77fcc1a4984e..a18c8a140424 100644
--- a/drivers/net/cxgb3/t3cdev.h
+++ b/drivers/net/cxgb3/t3cdev.h
@@ -34,7 +34,6 @@
34 34
35#include <linux/list.h> 35#include <linux/list.h>
36#include <asm/atomic.h> 36#include <asm/atomic.h>
37#include <asm/semaphore.h>
38#include <linux/netdevice.h> 37#include <linux/netdevice.h>
39#include <linux/proc_fs.h> 38#include <linux/proc_fs.h>
40#include <linux/skbuff.h> 39#include <linux/skbuff.h>
diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
index 0a9b75139e0f..1da55dd2a5a0 100644
--- a/drivers/net/hamradio/6pack.c
+++ b/drivers/net/hamradio/6pack.c
@@ -33,7 +33,7 @@
33#include <linux/init.h> 33#include <linux/init.h>
34#include <linux/ip.h> 34#include <linux/ip.h>
35#include <linux/tcp.h> 35#include <linux/tcp.h>
36#include <asm/semaphore.h> 36#include <linux/semaphore.h>
37#include <asm/atomic.h> 37#include <asm/atomic.h>
38 38
39#define SIXPACK_VERSION "Revision: 0.3.0" 39#define SIXPACK_VERSION "Revision: 0.3.0"
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c
index bb31e09899fc..ce4fc2ec2fe4 100644
--- a/drivers/net/ibmveth.c
+++ b/drivers/net/ibmveth.c
@@ -49,7 +49,6 @@
49#include <linux/in.h> 49#include <linux/in.h>
50#include <linux/ip.h> 50#include <linux/ip.h>
51#include <net/net_namespace.h> 51#include <net/net_namespace.h>
52#include <asm/semaphore.h>
53#include <asm/hvcall.h> 52#include <asm/hvcall.h>
54#include <asm/atomic.h> 53#include <asm/atomic.h>
55#include <asm/vio.h> 54#include <asm/vio.h>
diff --git a/drivers/net/irda/pxaficp_ir.c b/drivers/net/irda/pxaficp_ir.c
index 8c09344f58dc..8db71ab20456 100644
--- a/drivers/net/irda/pxaficp_ir.c
+++ b/drivers/net/irda/pxaficp_ir.c
@@ -36,6 +36,7 @@
36#include <asm/hardware.h> 36#include <asm/hardware.h>
37#include <asm/arch/irda.h> 37#include <asm/arch/irda.h>
38#include <asm/arch/pxa-regs.h> 38#include <asm/arch/pxa-regs.h>
39#include <asm/arch/pxa2xx-gpio.h>
39 40
40#ifdef CONFIG_MACH_MAINSTONE 41#ifdef CONFIG_MACH_MAINSTONE
41#include <asm/arch/mainstone.h> 42#include <asm/arch/mainstone.h>
@@ -831,6 +832,11 @@ static int pxa_irda_probe(struct platform_device *pdev)
831 if (err) 832 if (err)
832 goto err_mem_5; 833 goto err_mem_5;
833 834
835 if (si->pdata->startup)
836 err = si->pdata->startup(si->dev);
837 if (err)
838 goto err_startup;
839
834 dev->hard_start_xmit = pxa_irda_hard_xmit; 840 dev->hard_start_xmit = pxa_irda_hard_xmit;
835 dev->open = pxa_irda_start; 841 dev->open = pxa_irda_start;
836 dev->stop = pxa_irda_stop; 842 dev->stop = pxa_irda_stop;
@@ -856,6 +862,9 @@ static int pxa_irda_probe(struct platform_device *pdev)
856 dev_set_drvdata(&pdev->dev, dev); 862 dev_set_drvdata(&pdev->dev, dev);
857 863
858 if (err) { 864 if (err) {
865 if (si->pdata->shutdown)
866 si->pdata->shutdown(si->dev);
867err_startup:
859 kfree(si->tx_buff.head); 868 kfree(si->tx_buff.head);
860err_mem_5: 869err_mem_5:
861 kfree(si->rx_buff.head); 870 kfree(si->rx_buff.head);
@@ -881,6 +890,8 @@ static int pxa_irda_remove(struct platform_device *_dev)
881 if (dev) { 890 if (dev) {
882 struct pxa_irda *si = netdev_priv(dev); 891 struct pxa_irda *si = netdev_priv(dev);
883 unregister_netdev(dev); 892 unregister_netdev(dev);
893 if (si->pdata->shutdown)
894 si->pdata->shutdown(si->dev);
884 kfree(si->tx_buff.head); 895 kfree(si->tx_buff.head);
885 kfree(si->rx_buff.head); 896 kfree(si->rx_buff.head);
886 clk_put(si->fir_clk); 897 clk_put(si->fir_clk);
diff --git a/drivers/net/netxen/netxen_nic_hdr.h b/drivers/net/netxen/netxen_nic_hdr.h
index 160f605e58db..24d027e29c45 100644
--- a/drivers/net/netxen/netxen_nic_hdr.h
+++ b/drivers/net/netxen/netxen_nic_hdr.h
@@ -34,7 +34,6 @@
34#include <linux/kernel.h> 34#include <linux/kernel.h>
35#include <linux/version.h> 35#include <linux/version.h>
36 36
37#include <asm/semaphore.h>
38#include <linux/spinlock.h> 37#include <linux/spinlock.h>
39#include <asm/irq.h> 38#include <asm/irq.h>
40#include <linux/init.h> 39#include <linux/init.h>
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 96043c5746d0..bc4c62b8e81a 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -64,8 +64,8 @@
64 64
65#define DRV_MODULE_NAME "tg3" 65#define DRV_MODULE_NAME "tg3"
66#define PFX DRV_MODULE_NAME ": " 66#define PFX DRV_MODULE_NAME ": "
67#define DRV_MODULE_VERSION "3.90" 67#define DRV_MODULE_VERSION "3.91"
68#define DRV_MODULE_RELDATE "April 12, 2008" 68#define DRV_MODULE_RELDATE "April 18, 2008"
69 69
70#define TG3_DEF_MAC_MODE 0 70#define TG3_DEF_MAC_MODE 0
71#define TG3_DEF_RX_MODE 0 71#define TG3_DEF_RX_MODE 0
@@ -4135,11 +4135,21 @@ static int tigon3_dma_hwbug_workaround(struct tg3 *tp, struct sk_buff *skb,
4135 u32 last_plus_one, u32 *start, 4135 u32 last_plus_one, u32 *start,
4136 u32 base_flags, u32 mss) 4136 u32 base_flags, u32 mss)
4137{ 4137{
4138 struct sk_buff *new_skb = skb_copy(skb, GFP_ATOMIC); 4138 struct sk_buff *new_skb;
4139 dma_addr_t new_addr = 0; 4139 dma_addr_t new_addr = 0;
4140 u32 entry = *start; 4140 u32 entry = *start;
4141 int i, ret = 0; 4141 int i, ret = 0;
4142 4142
4143 if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5701)
4144 new_skb = skb_copy(skb, GFP_ATOMIC);
4145 else {
4146 int more_headroom = 4 - ((unsigned long)skb->data & 3);
4147
4148 new_skb = skb_copy_expand(skb,
4149 skb_headroom(skb) + more_headroom,
4150 skb_tailroom(skb), GFP_ATOMIC);
4151 }
4152
4143 if (!new_skb) { 4153 if (!new_skb) {
4144 ret = -1; 4154 ret = -1;
4145 } else { 4155 } else {
@@ -4462,7 +4472,9 @@ static int tg3_start_xmit_dma_bug(struct sk_buff *skb, struct net_device *dev)
4462 4472
4463 would_hit_hwbug = 0; 4473 would_hit_hwbug = 0;
4464 4474
4465 if (tg3_4g_overflow_test(mapping, len)) 4475 if (tp->tg3_flags3 & TG3_FLG3_5701_DMA_BUG)
4476 would_hit_hwbug = 1;
4477 else if (tg3_4g_overflow_test(mapping, len))
4466 would_hit_hwbug = 1; 4478 would_hit_hwbug = 1;
4467 4479
4468 tg3_set_txd(tp, entry, mapping, len, base_flags, 4480 tg3_set_txd(tp, entry, mapping, len, base_flags,
@@ -11339,6 +11351,38 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
11339 } 11351 }
11340 } 11352 }
11341 11353
11354 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701)) {
11355 static struct tg3_dev_id {
11356 u32 vendor;
11357 u32 device;
11358 } bridge_chipsets[] = {
11359 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PXH_0 },
11360 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PXH_1 },
11361 { },
11362 };
11363 struct tg3_dev_id *pci_id = &bridge_chipsets[0];
11364 struct pci_dev *bridge = NULL;
11365
11366 while (pci_id->vendor != 0) {
11367 bridge = pci_get_device(pci_id->vendor,
11368 pci_id->device,
11369 bridge);
11370 if (!bridge) {
11371 pci_id++;
11372 continue;
11373 }
11374 if (bridge->subordinate &&
11375 (bridge->subordinate->number <=
11376 tp->pdev->bus->number) &&
11377 (bridge->subordinate->subordinate >=
11378 tp->pdev->bus->number)) {
11379 tp->tg3_flags3 |= TG3_FLG3_5701_DMA_BUG;
11380 pci_dev_put(bridge);
11381 break;
11382 }
11383 }
11384 }
11385
11342 /* The EPB bridge inside 5714, 5715, and 5780 cannot support 11386 /* The EPB bridge inside 5714, 5715, and 5780 cannot support
11343 * DMA addresses > 40-bit. This bridge may have other additional 11387 * DMA addresses > 40-bit. This bridge may have other additional
11344 * 57xx devices behind it in some 4-port NIC designs for example. 11388 * 57xx devices behind it in some 4-port NIC designs for example.
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h
index c1075a73d66c..c688c3ac5035 100644
--- a/drivers/net/tg3.h
+++ b/drivers/net/tg3.h
@@ -2476,6 +2476,7 @@ struct tg3 {
2476#define TG3_FLG3_NO_NVRAM_ADDR_TRANS 0x00000001 2476#define TG3_FLG3_NO_NVRAM_ADDR_TRANS 0x00000001
2477#define TG3_FLG3_ENABLE_APE 0x00000002 2477#define TG3_FLG3_ENABLE_APE 0x00000002
2478#define TG3_FLG3_5761_5784_AX_FIXES 0x00000004 2478#define TG3_FLG3_5761_5784_AX_FIXES 0x00000004
2479#define TG3_FLG3_5701_DMA_BUG 0x00000008
2479 2480
2480 struct timer_list timer; 2481 struct timer_list timer;
2481 u16 timer_counter; 2482 u16 timer_counter;
diff --git a/drivers/net/usb/kaweth.c b/drivers/net/usb/kaweth.c
index 569ad8bfd383..0dcfc0310264 100644
--- a/drivers/net/usb/kaweth.c
+++ b/drivers/net/usb/kaweth.c
@@ -58,7 +58,6 @@
58#include <linux/dma-mapping.h> 58#include <linux/dma-mapping.h>
59#include <linux/wait.h> 59#include <linux/wait.h>
60#include <asm/uaccess.h> 60#include <asm/uaccess.h>
61#include <asm/semaphore.h>
62#include <asm/byteorder.h> 61#include <asm/byteorder.h>
63 62
64#undef DEBUG 63#undef DEBUG
diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
index 0f16f2606f29..9a30e1df311d 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
@@ -239,28 +239,34 @@ static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf,
239 "ps_status: %u\n", station->ps_status); 239 "ps_status: %u\n", station->ps_status);
240 pos += scnprintf(buf + pos, bufsz - pos, "tid data:\n"); 240 pos += scnprintf(buf + pos, bufsz - pos, "tid data:\n");
241 pos += scnprintf(buf + pos, bufsz - pos, 241 pos += scnprintf(buf + pos, bufsz - pos,
242 "seq_num\t\ttxq_id\t"); 242 "seq_num\t\ttxq_id");
243#ifdef CONFIG_IWL4965_HT
243 pos += scnprintf(buf + pos, bufsz - pos, 244 pos += scnprintf(buf + pos, bufsz - pos,
244 "frame_count\twait_for_ba\t"); 245 "\tframe_count\twait_for_ba\t");
245 pos += scnprintf(buf + pos, bufsz - pos, 246 pos += scnprintf(buf + pos, bufsz - pos,
246 "start_idx\tbitmap0\t"); 247 "start_idx\tbitmap0\t");
247 pos += scnprintf(buf + pos, bufsz - pos, 248 pos += scnprintf(buf + pos, bufsz - pos,
248 "bitmap1\trate_n_flags\n"); 249 "bitmap1\trate_n_flags");
250#endif
251 pos += scnprintf(buf + pos, bufsz - pos, "\n");
249 252
250 for (j = 0; j < MAX_TID_COUNT; j++) { 253 for (j = 0; j < MAX_TID_COUNT; j++) {
251 pos += scnprintf(buf + pos, bufsz - pos, 254 pos += scnprintf(buf + pos, bufsz - pos,
252 "[%d]:\t\t%u\t", j, 255 "[%d]:\t\t%u", j,
253 station->tid[j].seq_number); 256 station->tid[j].seq_number);
257#ifdef CONFIG_IWL4965_HT
254 pos += scnprintf(buf + pos, bufsz - pos, 258 pos += scnprintf(buf + pos, bufsz - pos,
255 "%u\t\t%u\t\t%u\t\t", 259 "\t%u\t\t%u\t\t%u\t\t",
256 station->tid[j].agg.txq_id, 260 station->tid[j].agg.txq_id,
257 station->tid[j].agg.frame_count, 261 station->tid[j].agg.frame_count,
258 station->tid[j].agg.wait_for_ba); 262 station->tid[j].agg.wait_for_ba);
259 pos += scnprintf(buf + pos, bufsz - pos, 263 pos += scnprintf(buf + pos, bufsz - pos,
260 "%u\t%llu\t%u\n", 264 "%u\t%llu\t%u",
261 station->tid[j].agg.start_idx, 265 station->tid[j].agg.start_idx,
262 (unsigned long long)station->tid[j].agg.bitmap, 266 (unsigned long long)station->tid[j].agg.bitmap,
263 station->tid[j].agg.rate_n_flags); 267 station->tid[j].agg.rate_n_flags);
268#endif
269 pos += scnprintf(buf + pos, bufsz - pos, "\n");
264 } 270 }
265 pos += scnprintf(buf + pos, bufsz - pos, "\n"); 271 pos += scnprintf(buf + pos, bufsz - pos, "\n");
266 } 272 }
diff --git a/drivers/parport/Kconfig b/drivers/parport/Kconfig
index b7bcdcc5c724..209b4a464bcf 100644
--- a/drivers/parport/Kconfig
+++ b/drivers/parport/Kconfig
@@ -36,7 +36,7 @@ if PARPORT
36config PARPORT_PC 36config PARPORT_PC
37 tristate "PC-style hardware" 37 tristate "PC-style hardware"
38 depends on (!SPARC64 || PCI) && !SPARC32 && !M32R && !FRV && \ 38 depends on (!SPARC64 || PCI) && !SPARC32 && !M32R && !FRV && \
39 (!M68K || ISA) && !MN10300 39 (!M68K || ISA) && !MN10300 && !AVR32
40 ---help--- 40 ---help---
41 You should say Y here if you have a PC-style parallel port. All 41 You should say Y here if you have a PC-style parallel port. All
42 IBM PC compatible computers and some Alphas have PC-style 42 IBM PC compatible computers and some Alphas have PC-style
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index e571c72e6753..e8d94fafc280 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -182,15 +182,18 @@ static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev,
182 struct mempolicy *oldpol; 182 struct mempolicy *oldpol;
183 cpumask_t oldmask = current->cpus_allowed; 183 cpumask_t oldmask = current->cpus_allowed;
184 int node = pcibus_to_node(dev->bus); 184 int node = pcibus_to_node(dev->bus);
185 if (node >= 0 && node_online(node)) 185
186 set_cpus_allowed(current, node_to_cpumask(node)); 186 if (node >= 0) {
187 node_to_cpumask_ptr(nodecpumask, node);
188 set_cpus_allowed_ptr(current, nodecpumask);
189 }
187 /* And set default memory allocation policy */ 190 /* And set default memory allocation policy */
188 oldpol = current->mempolicy; 191 oldpol = current->mempolicy;
189 current->mempolicy = NULL; /* fall back to system default policy */ 192 current->mempolicy = NULL; /* fall back to system default policy */
190#endif 193#endif
191 error = drv->probe(dev, id); 194 error = drv->probe(dev, id);
192#ifdef CONFIG_NUMA 195#ifdef CONFIG_NUMA
193 set_cpus_allowed(current, oldmask); 196 set_cpus_allowed_ptr(current, &oldmask);
194 current->mempolicy = oldpol; 197 current->mempolicy = oldpol;
195#endif 198#endif
196 return error; 199 return error;
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 8dcf1458aa2f..8d9d648daeba 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -73,8 +73,23 @@ static ssize_t local_cpus_show(struct device *dev,
73 73
74 mask = pcibus_to_cpumask(to_pci_dev(dev)->bus); 74 mask = pcibus_to_cpumask(to_pci_dev(dev)->bus);
75 len = cpumask_scnprintf(buf, PAGE_SIZE-2, mask); 75 len = cpumask_scnprintf(buf, PAGE_SIZE-2, mask);
76 strcat(buf,"\n"); 76 buf[len++] = '\n';
77 return 1+len; 77 buf[len] = '\0';
78 return len;
79}
80
81
82static ssize_t local_cpulist_show(struct device *dev,
83 struct device_attribute *attr, char *buf)
84{
85 cpumask_t mask;
86 int len;
87
88 mask = pcibus_to_cpumask(to_pci_dev(dev)->bus);
89 len = cpulist_scnprintf(buf, PAGE_SIZE-2, mask);
90 buf[len++] = '\n';
91 buf[len] = '\0';
92 return len;
78} 93}
79 94
80/* show resources */ 95/* show resources */
@@ -201,6 +216,7 @@ struct device_attribute pci_dev_attrs[] = {
201 __ATTR_RO(class), 216 __ATTR_RO(class),
202 __ATTR_RO(irq), 217 __ATTR_RO(irq),
203 __ATTR_RO(local_cpus), 218 __ATTR_RO(local_cpus),
219 __ATTR_RO(local_cpulist),
204 __ATTR_RO(modalias), 220 __ATTR_RO(modalias),
205#ifdef CONFIG_NUMA 221#ifdef CONFIG_NUMA
206 __ATTR_RO(numa_node), 222 __ATTR_RO(numa_node),
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 2db2e4bb0d1e..4b3011a23eff 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -82,6 +82,7 @@ void pci_remove_legacy_files(struct pci_bus *bus) { return; }
82 * PCI Bus Class Devices 82 * PCI Bus Class Devices
83 */ 83 */
84static ssize_t pci_bus_show_cpuaffinity(struct device *dev, 84static ssize_t pci_bus_show_cpuaffinity(struct device *dev,
85 int type,
85 struct device_attribute *attr, 86 struct device_attribute *attr,
86 char *buf) 87 char *buf)
87{ 88{
@@ -89,12 +90,30 @@ static ssize_t pci_bus_show_cpuaffinity(struct device *dev,
89 cpumask_t cpumask; 90 cpumask_t cpumask;
90 91
91 cpumask = pcibus_to_cpumask(to_pci_bus(dev)); 92 cpumask = pcibus_to_cpumask(to_pci_bus(dev));
92 ret = cpumask_scnprintf(buf, PAGE_SIZE, cpumask); 93 ret = type?
93 if (ret < PAGE_SIZE) 94 cpulist_scnprintf(buf, PAGE_SIZE-2, cpumask):
94 buf[ret++] = '\n'; 95 cpumask_scnprintf(buf, PAGE_SIZE-2, cpumask);
96 buf[ret++] = '\n';
97 buf[ret] = '\0';
95 return ret; 98 return ret;
96} 99}
97DEVICE_ATTR(cpuaffinity, S_IRUGO, pci_bus_show_cpuaffinity, NULL); 100
101static ssize_t inline pci_bus_show_cpumaskaffinity(struct device *dev,
102 struct device_attribute *attr,
103 char *buf)
104{
105 return pci_bus_show_cpuaffinity(dev, 0, attr, buf);
106}
107
108static ssize_t inline pci_bus_show_cpulistaffinity(struct device *dev,
109 struct device_attribute *attr,
110 char *buf)
111{
112 return pci_bus_show_cpuaffinity(dev, 1, attr, buf);
113}
114
115DEVICE_ATTR(cpuaffinity, S_IRUGO, pci_bus_show_cpumaskaffinity, NULL);
116DEVICE_ATTR(cpulistaffinity, S_IRUGO, pci_bus_show_cpulistaffinity, NULL);
98 117
99/* 118/*
100 * PCI Bus Class 119 * PCI Bus Class
diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig
index 8b22281b087f..ed8c06904807 100644
--- a/drivers/pcmcia/Kconfig
+++ b/drivers/pcmcia/Kconfig
@@ -200,6 +200,7 @@ config PCMCIA_AU1X00
200config PCMCIA_SA1100 200config PCMCIA_SA1100
201 tristate "SA1100 support" 201 tristate "SA1100 support"
202 depends on ARM && ARCH_SA1100 && PCMCIA 202 depends on ARM && ARCH_SA1100 && PCMCIA
203 depends on ARCH_LUBBOCK || MACH_MAINSTONE || PXA_SHARPSL || MACH_ARMCORE
203 help 204 help
204 Say Y here to include support for SA11x0-based PCMCIA or CF 205 Say Y here to include support for SA11x0-based PCMCIA or CF
205 sockets, found on HP iPAQs, Yopy, and other StrongARM(R)/ 206 sockets, found on HP iPAQs, Yopy, and other StrongARM(R)/
diff --git a/drivers/pcmcia/pxa2xx_cm_x270.c b/drivers/pcmcia/pxa2xx_cm_x270.c
index fbf2f3a6984c..e7ab060ff118 100644
--- a/drivers/pcmcia/pxa2xx_cm_x270.c
+++ b/drivers/pcmcia/pxa2xx_cm_x270.c
@@ -20,6 +20,7 @@
20#include <asm/hardware.h> 20#include <asm/hardware.h>
21 21
22#include <asm/arch/pxa-regs.h> 22#include <asm/arch/pxa-regs.h>
23#include <asm/arch/pxa2xx-gpio.h>
23#include <asm/arch/cm-x270.h> 24#include <asm/arch/cm-x270.h>
24 25
25#include "soc_common.h" 26#include "soc_common.h"
diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c
index 9e9caa5d7f5f..c594b34c6767 100644
--- a/drivers/rtc/rtc-sh.c
+++ b/drivers/rtc/rtc-sh.c
@@ -1,8 +1,9 @@
1/* 1/*
2 * SuperH On-Chip RTC Support 2 * SuperH On-Chip RTC Support
3 * 3 *
4 * Copyright (C) 2006, 2007 Paul Mundt 4 * Copyright (C) 2006, 2007, 2008 Paul Mundt
5 * Copyright (C) 2006 Jamie Lenehan 5 * Copyright (C) 2006 Jamie Lenehan
6 * Copyright (C) 2008 Angelo Castello
6 * 7 *
7 * Based on the old arch/sh/kernel/cpu/rtc.c by: 8 * Based on the old arch/sh/kernel/cpu/rtc.c by:
8 * 9 *
@@ -26,7 +27,7 @@
26#include <asm/rtc.h> 27#include <asm/rtc.h>
27 28
28#define DRV_NAME "sh-rtc" 29#define DRV_NAME "sh-rtc"
29#define DRV_VERSION "0.1.6" 30#define DRV_VERSION "0.2.0"
30 31
31#define RTC_REG(r) ((r) * rtc_reg_size) 32#define RTC_REG(r) ((r) * rtc_reg_size)
32 33
@@ -63,6 +64,13 @@
63/* ALARM Bits - or with BCD encoded value */ 64/* ALARM Bits - or with BCD encoded value */
64#define AR_ENB 0x80 /* Enable for alarm cmp */ 65#define AR_ENB 0x80 /* Enable for alarm cmp */
65 66
67/* Period Bits */
68#define PF_HP 0x100 /* Enable Half Period to support 8,32,128Hz */
69#define PF_COUNT 0x200 /* Half periodic counter */
70#define PF_OXS 0x400 /* Periodic One x Second */
71#define PF_KOU 0x800 /* Kernel or User periodic request 1=kernel */
72#define PF_MASK 0xf00
73
66/* RCR1 Bits */ 74/* RCR1 Bits */
67#define RCR1_CF 0x80 /* Carry Flag */ 75#define RCR1_CF 0x80 /* Carry Flag */
68#define RCR1_CIE 0x10 /* Carry Interrupt Enable */ 76#define RCR1_CIE 0x10 /* Carry Interrupt Enable */
@@ -84,33 +92,24 @@ struct sh_rtc {
84 unsigned int alarm_irq, periodic_irq, carry_irq; 92 unsigned int alarm_irq, periodic_irq, carry_irq;
85 struct rtc_device *rtc_dev; 93 struct rtc_device *rtc_dev;
86 spinlock_t lock; 94 spinlock_t lock;
87 int rearm_aie;
88 unsigned long capabilities; /* See asm-sh/rtc.h for cap bits */ 95 unsigned long capabilities; /* See asm-sh/rtc.h for cap bits */
96 unsigned short periodic_freq;
89}; 97};
90 98
91static irqreturn_t sh_rtc_interrupt(int irq, void *dev_id) 99static irqreturn_t sh_rtc_interrupt(int irq, void *dev_id)
92{ 100{
93 struct platform_device *pdev = to_platform_device(dev_id); 101 struct sh_rtc *rtc = dev_id;
94 struct sh_rtc *rtc = platform_get_drvdata(pdev); 102 unsigned int tmp;
95 unsigned int tmp, events = 0;
96 103
97 spin_lock(&rtc->lock); 104 spin_lock(&rtc->lock);
98 105
99 tmp = readb(rtc->regbase + RCR1); 106 tmp = readb(rtc->regbase + RCR1);
100 tmp &= ~RCR1_CF; 107 tmp &= ~RCR1_CF;
101
102 if (rtc->rearm_aie) {
103 if (tmp & RCR1_AF)
104 tmp &= ~RCR1_AF; /* try to clear AF again */
105 else {
106 tmp |= RCR1_AIE; /* AF has cleared, rearm IRQ */
107 rtc->rearm_aie = 0;
108 }
109 }
110
111 writeb(tmp, rtc->regbase + RCR1); 108 writeb(tmp, rtc->regbase + RCR1);
112 109
113 rtc_update_irq(rtc->rtc_dev, 1, events); 110 /* Users have requested One x Second IRQ */
111 if (rtc->periodic_freq & PF_OXS)
112 rtc_update_irq(rtc->rtc_dev, 1, RTC_UF | RTC_IRQF);
114 113
115 spin_unlock(&rtc->lock); 114 spin_unlock(&rtc->lock);
116 115
@@ -119,47 +118,48 @@ static irqreturn_t sh_rtc_interrupt(int irq, void *dev_id)
119 118
120static irqreturn_t sh_rtc_alarm(int irq, void *dev_id) 119static irqreturn_t sh_rtc_alarm(int irq, void *dev_id)
121{ 120{
122 struct platform_device *pdev = to_platform_device(dev_id); 121 struct sh_rtc *rtc = dev_id;
123 struct sh_rtc *rtc = platform_get_drvdata(pdev); 122 unsigned int tmp;
124 unsigned int tmp, events = 0;
125 123
126 spin_lock(&rtc->lock); 124 spin_lock(&rtc->lock);
127 125
128 tmp = readb(rtc->regbase + RCR1); 126 tmp = readb(rtc->regbase + RCR1);
129 127 tmp &= ~(RCR1_AF | RCR1_AIE);
130 /*
131 * If AF is set then the alarm has triggered. If we clear AF while
132 * the alarm time still matches the RTC time then AF will
133 * immediately be set again, and if AIE is enabled then the alarm
134 * interrupt will immediately be retrigger. So we clear AIE here
135 * and use rtc->rearm_aie so that the carry interrupt will keep
136 * trying to clear AF and once it stays cleared it'll re-enable
137 * AIE.
138 */
139 if (tmp & RCR1_AF) {
140 events |= RTC_AF | RTC_IRQF;
141
142 tmp &= ~(RCR1_AF|RCR1_AIE);
143
144 writeb(tmp, rtc->regbase + RCR1); 128 writeb(tmp, rtc->regbase + RCR1);
145 129
146 rtc->rearm_aie = 1; 130 rtc_update_irq(rtc->rtc_dev, 1, RTC_AF | RTC_IRQF);
147
148 rtc_update_irq(rtc->rtc_dev, 1, events);
149 }
150 131
151 spin_unlock(&rtc->lock); 132 spin_unlock(&rtc->lock);
133
152 return IRQ_HANDLED; 134 return IRQ_HANDLED;
153} 135}
154 136
155static irqreturn_t sh_rtc_periodic(int irq, void *dev_id) 137static irqreturn_t sh_rtc_periodic(int irq, void *dev_id)
156{ 138{
157 struct platform_device *pdev = to_platform_device(dev_id); 139 struct sh_rtc *rtc = dev_id;
158 struct sh_rtc *rtc = platform_get_drvdata(pdev); 140 struct rtc_device *rtc_dev = rtc->rtc_dev;
141 unsigned int tmp;
159 142
160 spin_lock(&rtc->lock); 143 spin_lock(&rtc->lock);
161 144
162 rtc_update_irq(rtc->rtc_dev, 1, RTC_PF | RTC_IRQF); 145 tmp = readb(rtc->regbase + RCR2);
146 tmp &= ~RCR2_PEF;
147 writeb(tmp, rtc->regbase + RCR2);
148
149 /* Half period enabled than one skipped and the next notified */
150 if ((rtc->periodic_freq & PF_HP) && (rtc->periodic_freq & PF_COUNT))
151 rtc->periodic_freq &= ~PF_COUNT;
152 else {
153 if (rtc->periodic_freq & PF_HP)
154 rtc->periodic_freq |= PF_COUNT;
155 if (rtc->periodic_freq & PF_KOU) {
156 spin_lock(&rtc_dev->irq_task_lock);
157 if (rtc_dev->irq_task)
158 rtc_dev->irq_task->func(rtc_dev->irq_task->private_data);
159 spin_unlock(&rtc_dev->irq_task_lock);
160 } else
161 rtc_update_irq(rtc->rtc_dev, 1, RTC_PF | RTC_IRQF);
162 }
163 163
164 spin_unlock(&rtc->lock); 164 spin_unlock(&rtc->lock);
165 165
@@ -176,8 +176,8 @@ static inline void sh_rtc_setpie(struct device *dev, unsigned int enable)
176 tmp = readb(rtc->regbase + RCR2); 176 tmp = readb(rtc->regbase + RCR2);
177 177
178 if (enable) { 178 if (enable) {
179 tmp &= ~RCR2_PESMASK; 179 tmp &= ~RCR2_PEF; /* Clear PES bit */
180 tmp |= RCR2_PEF | (2 << 4); 180 tmp |= (rtc->periodic_freq & ~PF_HP); /* Set PES2-0 */
181 } else 181 } else
182 tmp &= ~(RCR2_PESMASK | RCR2_PEF); 182 tmp &= ~(RCR2_PESMASK | RCR2_PEF);
183 183
@@ -186,82 +186,81 @@ static inline void sh_rtc_setpie(struct device *dev, unsigned int enable)
186 spin_unlock_irq(&rtc->lock); 186 spin_unlock_irq(&rtc->lock);
187} 187}
188 188
189static inline void sh_rtc_setaie(struct device *dev, unsigned int enable) 189static inline int sh_rtc_setfreq(struct device *dev, unsigned int freq)
190{ 190{
191 struct sh_rtc *rtc = dev_get_drvdata(dev); 191 struct sh_rtc *rtc = dev_get_drvdata(dev);
192 unsigned int tmp; 192 int tmp, ret = 0;
193 193
194 spin_lock_irq(&rtc->lock); 194 spin_lock_irq(&rtc->lock);
195 tmp = rtc->periodic_freq & PF_MASK;
195 196
196 tmp = readb(rtc->regbase + RCR1); 197 switch (freq) {
197 198 case 0:
198 if (!enable) { 199 rtc->periodic_freq = 0x00;
199 tmp &= ~RCR1_AIE; 200 break;
200 rtc->rearm_aie = 0; 201 case 1:
201 } else if (rtc->rearm_aie == 0) 202 rtc->periodic_freq = 0x60;
202 tmp |= RCR1_AIE; 203 break;
204 case 2:
205 rtc->periodic_freq = 0x50;
206 break;
207 case 4:
208 rtc->periodic_freq = 0x40;
209 break;
210 case 8:
211 rtc->periodic_freq = 0x30 | PF_HP;
212 break;
213 case 16:
214 rtc->periodic_freq = 0x30;
215 break;
216 case 32:
217 rtc->periodic_freq = 0x20 | PF_HP;
218 break;
219 case 64:
220 rtc->periodic_freq = 0x20;
221 break;
222 case 128:
223 rtc->periodic_freq = 0x10 | PF_HP;
224 break;
225 case 256:
226 rtc->periodic_freq = 0x10;
227 break;
228 default:
229 ret = -ENOTSUPP;
230 }
203 231
204 writeb(tmp, rtc->regbase + RCR1); 232 if (ret == 0) {
233 rtc->periodic_freq |= tmp;
234 rtc->rtc_dev->irq_freq = freq;
235 }
205 236
206 spin_unlock_irq(&rtc->lock); 237 spin_unlock_irq(&rtc->lock);
238 return ret;
207} 239}
208 240
209static int sh_rtc_open(struct device *dev) 241static inline void sh_rtc_setaie(struct device *dev, unsigned int enable)
210{ 242{
211 struct sh_rtc *rtc = dev_get_drvdata(dev); 243 struct sh_rtc *rtc = dev_get_drvdata(dev);
212 unsigned int tmp; 244 unsigned int tmp;
213 int ret;
214
215 tmp = readb(rtc->regbase + RCR1);
216 tmp &= ~RCR1_CF;
217 tmp |= RCR1_CIE;
218 writeb(tmp, rtc->regbase + RCR1);
219 245
220 ret = request_irq(rtc->periodic_irq, sh_rtc_periodic, IRQF_DISABLED, 246 spin_lock_irq(&rtc->lock);
221 "sh-rtc period", dev);
222 if (unlikely(ret)) {
223 dev_err(dev, "request period IRQ failed with %d, IRQ %d\n",
224 ret, rtc->periodic_irq);
225 return ret;
226 }
227
228 ret = request_irq(rtc->carry_irq, sh_rtc_interrupt, IRQF_DISABLED,
229 "sh-rtc carry", dev);
230 if (unlikely(ret)) {
231 dev_err(dev, "request carry IRQ failed with %d, IRQ %d\n",
232 ret, rtc->carry_irq);
233 free_irq(rtc->periodic_irq, dev);
234 goto err_bad_carry;
235 }
236 247
237 ret = request_irq(rtc->alarm_irq, sh_rtc_alarm, IRQF_DISABLED, 248 tmp = readb(rtc->regbase + RCR1);
238 "sh-rtc alarm", dev);
239 if (unlikely(ret)) {
240 dev_err(dev, "request alarm IRQ failed with %d, IRQ %d\n",
241 ret, rtc->alarm_irq);
242 goto err_bad_alarm;
243 }
244 249
245 return 0; 250 if (!enable)
251 tmp &= ~RCR1_AIE;
252 else
253 tmp |= RCR1_AIE;
246 254
247err_bad_alarm: 255 writeb(tmp, rtc->regbase + RCR1);
248 free_irq(rtc->carry_irq, dev);
249err_bad_carry:
250 free_irq(rtc->periodic_irq, dev);
251 256
252 return ret; 257 spin_unlock_irq(&rtc->lock);
253} 258}
254 259
255static void sh_rtc_release(struct device *dev) 260static void sh_rtc_release(struct device *dev)
256{ 261{
257 struct sh_rtc *rtc = dev_get_drvdata(dev);
258
259 sh_rtc_setpie(dev, 0); 262 sh_rtc_setpie(dev, 0);
260 sh_rtc_setaie(dev, 0); 263 sh_rtc_setaie(dev, 0);
261
262 free_irq(rtc->periodic_irq, dev);
263 free_irq(rtc->carry_irq, dev);
264 free_irq(rtc->alarm_irq, dev);
265} 264}
266 265
267static int sh_rtc_proc(struct device *dev, struct seq_file *seq) 266static int sh_rtc_proc(struct device *dev, struct seq_file *seq)
@@ -270,31 +269,44 @@ static int sh_rtc_proc(struct device *dev, struct seq_file *seq)
270 unsigned int tmp; 269 unsigned int tmp;
271 270
272 tmp = readb(rtc->regbase + RCR1); 271 tmp = readb(rtc->regbase + RCR1);
273 seq_printf(seq, "carry_IRQ\t: %s\n", 272 seq_printf(seq, "carry_IRQ\t: %s\n", (tmp & RCR1_CIE) ? "yes" : "no");
274 (tmp & RCR1_CIE) ? "yes" : "no");
275 273
276 tmp = readb(rtc->regbase + RCR2); 274 tmp = readb(rtc->regbase + RCR2);
277 seq_printf(seq, "periodic_IRQ\t: %s\n", 275 seq_printf(seq, "periodic_IRQ\t: %s\n",
278 (tmp & RCR2_PEF) ? "yes" : "no"); 276 (tmp & RCR2_PESMASK) ? "yes" : "no");
279 277
280 return 0; 278 return 0;
281} 279}
282 280
283static int sh_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) 281static int sh_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
284{ 282{
285 unsigned int ret = -ENOIOCTLCMD; 283 struct sh_rtc *rtc = dev_get_drvdata(dev);
284 unsigned int ret = 0;
286 285
287 switch (cmd) { 286 switch (cmd) {
288 case RTC_PIE_OFF: 287 case RTC_PIE_OFF:
289 case RTC_PIE_ON: 288 case RTC_PIE_ON:
290 sh_rtc_setpie(dev, cmd == RTC_PIE_ON); 289 sh_rtc_setpie(dev, cmd == RTC_PIE_ON);
291 ret = 0;
292 break; 290 break;
293 case RTC_AIE_OFF: 291 case RTC_AIE_OFF:
294 case RTC_AIE_ON: 292 case RTC_AIE_ON:
295 sh_rtc_setaie(dev, cmd == RTC_AIE_ON); 293 sh_rtc_setaie(dev, cmd == RTC_AIE_ON);
296 ret = 0;
297 break; 294 break;
295 case RTC_UIE_OFF:
296 rtc->periodic_freq &= ~PF_OXS;
297 break;
298 case RTC_UIE_ON:
299 rtc->periodic_freq |= PF_OXS;
300 break;
301 case RTC_IRQP_READ:
302 ret = put_user(rtc->rtc_dev->irq_freq,
303 (unsigned long __user *)arg);
304 break;
305 case RTC_IRQP_SET:
306 ret = sh_rtc_setfreq(dev, arg);
307 break;
308 default:
309 ret = -ENOIOCTLCMD;
298 } 310 }
299 311
300 return ret; 312 return ret;
@@ -421,7 +433,7 @@ static int sh_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *wkalrm)
421{ 433{
422 struct platform_device *pdev = to_platform_device(dev); 434 struct platform_device *pdev = to_platform_device(dev);
423 struct sh_rtc *rtc = platform_get_drvdata(pdev); 435 struct sh_rtc *rtc = platform_get_drvdata(pdev);
424 struct rtc_time* tm = &wkalrm->time; 436 struct rtc_time *tm = &wkalrm->time;
425 437
426 spin_lock_irq(&rtc->lock); 438 spin_lock_irq(&rtc->lock);
427 439
@@ -452,7 +464,7 @@ static inline void sh_rtc_write_alarm_value(struct sh_rtc *rtc,
452 writeb(BIN2BCD(value) | AR_ENB, rtc->regbase + reg_off); 464 writeb(BIN2BCD(value) | AR_ENB, rtc->regbase + reg_off);
453} 465}
454 466
455static int sh_rtc_check_alarm(struct rtc_time* tm) 467static int sh_rtc_check_alarm(struct rtc_time *tm)
456{ 468{
457 /* 469 /*
458 * The original rtc says anything > 0xc0 is "don't care" or "match 470 * The original rtc says anything > 0xc0 is "don't care" or "match
@@ -503,11 +515,9 @@ static int sh_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *wkalrm)
503 515
504 /* disable alarm interrupt and clear the alarm flag */ 516 /* disable alarm interrupt and clear the alarm flag */
505 rcr1 = readb(rtc->regbase + RCR1); 517 rcr1 = readb(rtc->regbase + RCR1);
506 rcr1 &= ~(RCR1_AF|RCR1_AIE); 518 rcr1 &= ~(RCR1_AF | RCR1_AIE);
507 writeb(rcr1, rtc->regbase + RCR1); 519 writeb(rcr1, rtc->regbase + RCR1);
508 520
509 rtc->rearm_aie = 0;
510
511 /* set alarm time */ 521 /* set alarm time */
512 sh_rtc_write_alarm_value(rtc, tm->tm_sec, RSECAR); 522 sh_rtc_write_alarm_value(rtc, tm->tm_sec, RSECAR);
513 sh_rtc_write_alarm_value(rtc, tm->tm_min, RMINAR); 523 sh_rtc_write_alarm_value(rtc, tm->tm_min, RMINAR);
@@ -529,14 +539,34 @@ static int sh_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *wkalrm)
529 return 0; 539 return 0;
530} 540}
531 541
542static int sh_rtc_irq_set_state(struct device *dev, int enabled)
543{
544 struct platform_device *pdev = to_platform_device(dev);
545 struct sh_rtc *rtc = platform_get_drvdata(pdev);
546
547 if (enabled) {
548 rtc->periodic_freq |= PF_KOU;
549 return sh_rtc_ioctl(dev, RTC_PIE_ON, 0);
550 } else {
551 rtc->periodic_freq &= ~PF_KOU;
552 return sh_rtc_ioctl(dev, RTC_PIE_OFF, 0);
553 }
554}
555
556static int sh_rtc_irq_set_freq(struct device *dev, int freq)
557{
558 return sh_rtc_ioctl(dev, RTC_IRQP_SET, freq);
559}
560
532static struct rtc_class_ops sh_rtc_ops = { 561static struct rtc_class_ops sh_rtc_ops = {
533 .open = sh_rtc_open,
534 .release = sh_rtc_release, 562 .release = sh_rtc_release,
535 .ioctl = sh_rtc_ioctl, 563 .ioctl = sh_rtc_ioctl,
536 .read_time = sh_rtc_read_time, 564 .read_time = sh_rtc_read_time,
537 .set_time = sh_rtc_set_time, 565 .set_time = sh_rtc_set_time,
538 .read_alarm = sh_rtc_read_alarm, 566 .read_alarm = sh_rtc_read_alarm,
539 .set_alarm = sh_rtc_set_alarm, 567 .set_alarm = sh_rtc_set_alarm,
568 .irq_set_state = sh_rtc_irq_set_state,
569 .irq_set_freq = sh_rtc_irq_set_freq,
540 .proc = sh_rtc_proc, 570 .proc = sh_rtc_proc,
541}; 571};
542 572
@@ -544,6 +574,7 @@ static int __devinit sh_rtc_probe(struct platform_device *pdev)
544{ 574{
545 struct sh_rtc *rtc; 575 struct sh_rtc *rtc;
546 struct resource *res; 576 struct resource *res;
577 unsigned int tmp;
547 int ret = -ENOENT; 578 int ret = -ENOENT;
548 579
549 rtc = kzalloc(sizeof(struct sh_rtc), GFP_KERNEL); 580 rtc = kzalloc(sizeof(struct sh_rtc), GFP_KERNEL);
@@ -552,6 +583,7 @@ static int __devinit sh_rtc_probe(struct platform_device *pdev)
552 583
553 spin_lock_init(&rtc->lock); 584 spin_lock_init(&rtc->lock);
554 585
586 /* get periodic/carry/alarm irqs */
555 rtc->periodic_irq = platform_get_irq(pdev, 0); 587 rtc->periodic_irq = platform_get_irq(pdev, 0);
556 if (unlikely(rtc->periodic_irq < 0)) { 588 if (unlikely(rtc->periodic_irq < 0)) {
557 dev_err(&pdev->dev, "No IRQ for period\n"); 589 dev_err(&pdev->dev, "No IRQ for period\n");
@@ -608,8 +640,48 @@ static int __devinit sh_rtc_probe(struct platform_device *pdev)
608 rtc->capabilities |= pinfo->capabilities; 640 rtc->capabilities |= pinfo->capabilities;
609 } 641 }
610 642
643 rtc->rtc_dev->max_user_freq = 256;
644 rtc->rtc_dev->irq_freq = 1;
645 rtc->periodic_freq = 0x60;
646
611 platform_set_drvdata(pdev, rtc); 647 platform_set_drvdata(pdev, rtc);
612 648
649 /* register periodic/carry/alarm irqs */
650 ret = request_irq(rtc->periodic_irq, sh_rtc_periodic, IRQF_DISABLED,
651 "sh-rtc period", rtc);
652 if (unlikely(ret)) {
653 dev_err(&pdev->dev,
654 "request period IRQ failed with %d, IRQ %d\n", ret,
655 rtc->periodic_irq);
656 goto err_badmap;
657 }
658
659 ret = request_irq(rtc->carry_irq, sh_rtc_interrupt, IRQF_DISABLED,
660 "sh-rtc carry", rtc);
661 if (unlikely(ret)) {
662 dev_err(&pdev->dev,
663 "request carry IRQ failed with %d, IRQ %d\n", ret,
664 rtc->carry_irq);
665 free_irq(rtc->periodic_irq, rtc);
666 goto err_badmap;
667 }
668
669 ret = request_irq(rtc->alarm_irq, sh_rtc_alarm, IRQF_DISABLED,
670 "sh-rtc alarm", rtc);
671 if (unlikely(ret)) {
672 dev_err(&pdev->dev,
673 "request alarm IRQ failed with %d, IRQ %d\n", ret,
674 rtc->alarm_irq);
675 free_irq(rtc->carry_irq, rtc);
676 free_irq(rtc->periodic_irq, rtc);
677 goto err_badmap;
678 }
679
680 tmp = readb(rtc->regbase + RCR1);
681 tmp &= ~RCR1_CF;
682 tmp |= RCR1_CIE;
683 writeb(tmp, rtc->regbase + RCR1);
684
613 return 0; 685 return 0;
614 686
615err_badmap: 687err_badmap:
@@ -630,6 +702,10 @@ static int __devexit sh_rtc_remove(struct platform_device *pdev)
630 sh_rtc_setpie(&pdev->dev, 0); 702 sh_rtc_setpie(&pdev->dev, 0);
631 sh_rtc_setaie(&pdev->dev, 0); 703 sh_rtc_setaie(&pdev->dev, 0);
632 704
705 free_irq(rtc->carry_irq, rtc);
706 free_irq(rtc->periodic_irq, rtc);
707 free_irq(rtc->alarm_irq, rtc);
708
633 release_resource(rtc->res); 709 release_resource(rtc->res);
634 710
635 platform_set_drvdata(pdev, NULL); 711 platform_set_drvdata(pdev, NULL);
@@ -662,6 +738,8 @@ module_exit(sh_rtc_exit);
662 738
663MODULE_DESCRIPTION("SuperH on-chip RTC driver"); 739MODULE_DESCRIPTION("SuperH on-chip RTC driver");
664MODULE_VERSION(DRV_VERSION); 740MODULE_VERSION(DRV_VERSION);
665MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>, Jamie Lenehan <lenehan@twibble.org>"); 741MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>, "
742 "Jamie Lenehan <lenehan@twibble.org>, "
743 "Angelo Castello <angelo.castello@st.com>");
666MODULE_LICENSE("GPL"); 744MODULE_LICENSE("GPL");
667MODULE_ALIAS("platform:" DRV_NAME); 745MODULE_ALIAS("platform:" DRV_NAME);
diff --git a/drivers/s390/cio/ccwgroup.c b/drivers/s390/cio/ccwgroup.c
index 03914fa81174..fe1ad1722158 100644
--- a/drivers/s390/cio/ccwgroup.c
+++ b/drivers/s390/cio/ccwgroup.c
@@ -16,7 +16,6 @@
16#include <linux/ctype.h> 16#include <linux/ctype.h>
17#include <linux/dcache.h> 17#include <linux/dcache.h>
18 18
19#include <asm/semaphore.h>
20#include <asm/ccwdev.h> 19#include <asm/ccwdev.h>
21#include <asm/ccwgroup.h> 20#include <asm/ccwgroup.h>
22 21
diff --git a/drivers/s390/cio/qdio.c b/drivers/s390/cio/qdio.c
index c359386708e9..10aa1e780801 100644
--- a/drivers/s390/cio/qdio.c
+++ b/drivers/s390/cio/qdio.c
@@ -38,11 +38,11 @@
38#include <linux/proc_fs.h> 38#include <linux/proc_fs.h>
39#include <linux/timer.h> 39#include <linux/timer.h>
40#include <linux/mempool.h> 40#include <linux/mempool.h>
41#include <linux/semaphore.h>
41 42
42#include <asm/ccwdev.h> 43#include <asm/ccwdev.h>
43#include <asm/io.h> 44#include <asm/io.h>
44#include <asm/atomic.h> 45#include <asm/atomic.h>
45#include <asm/semaphore.h>
46#include <asm/timex.h> 46#include <asm/timex.h>
47 47
48#include <asm/debug.h> 48#include <asm/debug.h>
diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index 439fd8146657..460d4024c46c 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -31,7 +31,6 @@
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/completion.h> 32#include <linux/completion.h>
33#include <linux/blkdev.h> 33#include <linux/blkdev.h>
34#include <asm/semaphore.h>
35#include <asm/uaccess.h> 34#include <asm/uaccess.h>
36#include <linux/highmem.h> /* For flush_kernel_dcache_page */ 35#include <linux/highmem.h> /* For flush_kernel_dcache_page */
37 36
diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c
index abef05146d75..5fd83deab36c 100644
--- a/drivers/scsi/aacraid/commctrl.c
+++ b/drivers/scsi/aacraid/commctrl.c
@@ -39,7 +39,7 @@
39#include <linux/blkdev.h> 39#include <linux/blkdev.h>
40#include <linux/delay.h> /* ssleep prototype */ 40#include <linux/delay.h> /* ssleep prototype */
41#include <linux/kthread.h> 41#include <linux/kthread.h>
42#include <asm/semaphore.h> 42#include <linux/semaphore.h>
43#include <asm/uaccess.h> 43#include <asm/uaccess.h>
44 44
45#include "aacraid.h" 45#include "aacraid.h"
diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/comminit.c
index 89cc8b7b42a2..294a802450be 100644
--- a/drivers/scsi/aacraid/comminit.c
+++ b/drivers/scsi/aacraid/comminit.c
@@ -39,7 +39,6 @@
39#include <linux/completion.h> 39#include <linux/completion.h>
40#include <linux/mm.h> 40#include <linux/mm.h>
41#include <scsi/scsi_host.h> 41#include <scsi/scsi_host.h>
42#include <asm/semaphore.h>
43 42
44#include "aacraid.h" 43#include "aacraid.h"
45 44
diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c
index 23a8e9f8dcb4..ef67816a6fe5 100644
--- a/drivers/scsi/aacraid/commsup.c
+++ b/drivers/scsi/aacraid/commsup.c
@@ -41,11 +41,11 @@
41#include <linux/delay.h> 41#include <linux/delay.h>
42#include <linux/kthread.h> 42#include <linux/kthread.h>
43#include <linux/interrupt.h> 43#include <linux/interrupt.h>
44#include <linux/semaphore.h>
44#include <scsi/scsi.h> 45#include <scsi/scsi.h>
45#include <scsi/scsi_host.h> 46#include <scsi/scsi_host.h>
46#include <scsi/scsi_device.h> 47#include <scsi/scsi_device.h>
47#include <scsi/scsi_cmnd.h> 48#include <scsi/scsi_cmnd.h>
48#include <asm/semaphore.h>
49 49
50#include "aacraid.h" 50#include "aacraid.h"
51 51
diff --git a/drivers/scsi/aacraid/dpcsup.c b/drivers/scsi/aacraid/dpcsup.c
index d1163ded132b..933f208eedba 100644
--- a/drivers/scsi/aacraid/dpcsup.c
+++ b/drivers/scsi/aacraid/dpcsup.c
@@ -36,7 +36,7 @@
36#include <linux/slab.h> 36#include <linux/slab.h>
37#include <linux/completion.h> 37#include <linux/completion.h>
38#include <linux/blkdev.h> 38#include <linux/blkdev.h>
39#include <asm/semaphore.h> 39#include <linux/semaphore.h>
40 40
41#include "aacraid.h" 41#include "aacraid.h"
42 42
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
index c6391838b2cd..c109f63f8279 100644
--- a/drivers/scsi/aacraid/linit.c
+++ b/drivers/scsi/aacraid/linit.c
@@ -42,7 +42,6 @@
42#include <linux/syscalls.h> 42#include <linux/syscalls.h>
43#include <linux/delay.h> 43#include <linux/delay.h>
44#include <linux/kthread.h> 44#include <linux/kthread.h>
45#include <asm/semaphore.h>
46 45
47#include <scsi/scsi.h> 46#include <scsi/scsi.h>
48#include <scsi/scsi_cmnd.h> 47#include <scsi/scsi_cmnd.h>
diff --git a/drivers/scsi/aacraid/rx.c b/drivers/scsi/aacraid/rx.c
index 1f18b83e1e02..073208b0f622 100644
--- a/drivers/scsi/aacraid/rx.c
+++ b/drivers/scsi/aacraid/rx.c
@@ -39,7 +39,6 @@
39#include <linux/completion.h> 39#include <linux/completion.h>
40#include <linux/time.h> 40#include <linux/time.h>
41#include <linux/interrupt.h> 41#include <linux/interrupt.h>
42#include <asm/semaphore.h>
43 42
44#include <scsi/scsi_host.h> 43#include <scsi/scsi_host.h>
45 44
diff --git a/drivers/scsi/aacraid/sa.c b/drivers/scsi/aacraid/sa.c
index cfc3410ec073..fc1a55796a89 100644
--- a/drivers/scsi/aacraid/sa.c
+++ b/drivers/scsi/aacraid/sa.c
@@ -39,7 +39,6 @@
39#include <linux/completion.h> 39#include <linux/completion.h>
40#include <linux/time.h> 40#include <linux/time.h>
41#include <linux/interrupt.h> 41#include <linux/interrupt.h>
42#include <asm/semaphore.h>
43 42
44#include <scsi/scsi_host.h> 43#include <scsi/scsi_host.h>
45 44
diff --git a/drivers/scsi/dpt/dpti_i2o.h b/drivers/scsi/dpt/dpti_i2o.h
index 100b49baca7f..19406cea6d6a 100644
--- a/drivers/scsi/dpt/dpti_i2o.h
+++ b/drivers/scsi/dpt/dpti_i2o.h
@@ -21,7 +21,6 @@
21 21
22#include <linux/i2o-dev.h> 22#include <linux/i2o-dev.h>
23 23
24#include <asm/semaphore.h> /* Needed for MUTEX init macros */
25#include <linux/version.h> 24#include <linux/version.h>
26#include <linux/notifier.h> 25#include <linux/notifier.h>
27#include <asm/atomic.h> 26#include <asm/atomic.h>
diff --git a/drivers/scsi/megaraid/mega_common.h b/drivers/scsi/megaraid/mega_common.h
index fef9ac958754..f62ed468ada0 100644
--- a/drivers/scsi/megaraid/mega_common.h
+++ b/drivers/scsi/megaraid/mega_common.h
@@ -28,7 +28,6 @@
28#include <linux/list.h> 28#include <linux/list.h>
29#include <linux/moduleparam.h> 29#include <linux/moduleparam.h>
30#include <linux/dma-mapping.h> 30#include <linux/dma-mapping.h>
31#include <asm/semaphore.h>
32#include <scsi/scsi.h> 31#include <scsi/scsi.h>
33#include <scsi/scsi_cmnd.h> 32#include <scsi/scsi_cmnd.h>
34#include <scsi/scsi_device.h> 33#include <scsi/scsi_device.h>
diff --git a/drivers/scsi/megaraid/megaraid_ioctl.h b/drivers/scsi/megaraid/megaraid_ioctl.h
index 706fa05a187a..05f6e4ec3453 100644
--- a/drivers/scsi/megaraid/megaraid_ioctl.h
+++ b/drivers/scsi/megaraid/megaraid_ioctl.h
@@ -18,7 +18,7 @@
18#define _MEGARAID_IOCTL_H_ 18#define _MEGARAID_IOCTL_H_
19 19
20#include <linux/types.h> 20#include <linux/types.h>
21#include <asm/semaphore.h> 21#include <linux/semaphore.h>
22 22
23#include "mbox_defs.h" 23#include "mbox_defs.h"
24 24
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 094d95f0764c..299eccf6cabd 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -25,7 +25,7 @@
25#include <linux/firmware.h> 25#include <linux/firmware.h>
26#include <linux/aer.h> 26#include <linux/aer.h>
27#include <linux/mutex.h> 27#include <linux/mutex.h>
28#include <asm/semaphore.h> 28#include <linux/semaphore.h>
29 29
30#include <scsi/scsi.h> 30#include <scsi/scsi.h>
31#include <scsi/scsi_host.h> 31#include <scsi/scsi_host.h>
diff --git a/drivers/serial/imx.c b/drivers/serial/imx.c
index 16ba9ac7a566..5a375bf0ebf4 100644
--- a/drivers/serial/imx.c
+++ b/drivers/serial/imx.c
@@ -166,15 +166,6 @@
166#define SERIAL_IMX_MAJOR 204 166#define SERIAL_IMX_MAJOR 204
167#define MINOR_START 41 167#define MINOR_START 41
168 168
169#define NR_PORTS 2
170
171#define IMX_ISR_PASS_LIMIT 256
172
173/*
174 * This is the size of our serial port register set.
175 */
176#define UART_PORT_SIZE 0x100
177
178/* 169/*
179 * This determines how often we check the modem status signals 170 * This determines how often we check the modem status signals
180 * for any change. They generally aren't connected to an IRQ 171 * for any change. They generally aren't connected to an IRQ
@@ -358,66 +349,60 @@ static irqreturn_t imx_rxint(int irq, void *dev_id)
358 struct tty_struct *tty = sport->port.info->tty; 349 struct tty_struct *tty = sport->port.info->tty;
359 unsigned long flags, temp; 350 unsigned long flags, temp;
360 351
361 rx = readl(sport->port.membase + URXD0);
362 spin_lock_irqsave(&sport->port.lock,flags); 352 spin_lock_irqsave(&sport->port.lock,flags);
363 353
364 do { 354 while (readl(sport->port.membase + USR2) & USR2_RDR) {
365 flg = TTY_NORMAL; 355 flg = TTY_NORMAL;
366 sport->port.icount.rx++; 356 sport->port.icount.rx++;
367 357
358 rx = readl(sport->port.membase + URXD0);
359
368 temp = readl(sport->port.membase + USR2); 360 temp = readl(sport->port.membase + USR2);
369 if( temp & USR2_BRCD ) { 361 if (temp & USR2_BRCD) {
370 writel(temp | USR2_BRCD, sport->port.membase + USR2); 362 writel(temp | USR2_BRCD, sport->port.membase + USR2);
371 if(uart_handle_break(&sport->port)) 363 if (uart_handle_break(&sport->port))
372 goto ignore_char; 364 continue;
373 } 365 }
374 366
375 if (uart_handle_sysrq_char 367 if (uart_handle_sysrq_char
376 (&sport->port, (unsigned char)rx)) 368 (&sport->port, (unsigned char)rx))
377 goto ignore_char; 369 continue;
370
371 if (rx & (URXD_PRERR | URXD_OVRRUN | URXD_FRMERR) ) {
372 if (rx & URXD_PRERR)
373 sport->port.icount.parity++;
374 else if (rx & URXD_FRMERR)
375 sport->port.icount.frame++;
376 if (rx & URXD_OVRRUN)
377 sport->port.icount.overrun++;
378
379 if (rx & sport->port.ignore_status_mask) {
380 if (++ignored > 100)
381 goto out;
382 continue;
383 }
384
385 rx &= sport->port.read_status_mask;
386
387 if (rx & URXD_PRERR)
388 flg = TTY_PARITY;
389 else if (rx & URXD_FRMERR)
390 flg = TTY_FRAME;
391 if (rx & URXD_OVRRUN)
392 flg = TTY_OVERRUN;
378 393
379 if( rx & (URXD_PRERR | URXD_OVRRUN | URXD_FRMERR) ) 394#ifdef SUPPORT_SYSRQ
380 goto handle_error; 395 sport->port.sysrq = 0;
396#endif
397 }
381 398
382 error_return:
383 tty_insert_flip_char(tty, rx, flg); 399 tty_insert_flip_char(tty, rx, flg);
384 400 }
385 ignore_char:
386 rx = readl(sport->port.membase + URXD0);
387 } while(rx & URXD_CHARRDY);
388 401
389out: 402out:
390 spin_unlock_irqrestore(&sport->port.lock,flags); 403 spin_unlock_irqrestore(&sport->port.lock,flags);
391 tty_flip_buffer_push(tty); 404 tty_flip_buffer_push(tty);
392 return IRQ_HANDLED; 405 return IRQ_HANDLED;
393
394handle_error:
395 if (rx & URXD_PRERR)
396 sport->port.icount.parity++;
397 else if (rx & URXD_FRMERR)
398 sport->port.icount.frame++;
399 if (rx & URXD_OVRRUN)
400 sport->port.icount.overrun++;
401
402 if (rx & sport->port.ignore_status_mask) {
403 if (++ignored > 100)
404 goto out;
405 goto ignore_char;
406 }
407
408 rx &= sport->port.read_status_mask;
409
410 if (rx & URXD_PRERR)
411 flg = TTY_PARITY;
412 else if (rx & URXD_FRMERR)
413 flg = TTY_FRAME;
414 if (rx & URXD_OVRRUN)
415 flg = TTY_OVERRUN;
416
417#ifdef SUPPORT_SYSRQ
418 sport->port.sysrq = 0;
419#endif
420 goto error_return;
421} 406}
422 407
423/* 408/*
@@ -546,7 +531,7 @@ static int imx_startup(struct uart_port *port)
546 writel(USR1_RTSD, sport->port.membase + USR1); 531 writel(USR1_RTSD, sport->port.membase + USR1);
547 532
548 temp = readl(sport->port.membase + UCR1); 533 temp = readl(sport->port.membase + UCR1);
549 temp |= (UCR1_TXMPTYEN | UCR1_RRDYEN | UCR1_RTSDEN | UCR1_UARTEN); 534 temp |= UCR1_RRDYEN | UCR1_RTSDEN | UCR1_UARTEN;
550 writel(temp, sport->port.membase + UCR1); 535 writel(temp, sport->port.membase + UCR1);
551 536
552 temp = readl(sport->port.membase + UCR2); 537 temp = readl(sport->port.membase + UCR2);
@@ -731,9 +716,11 @@ static const char *imx_type(struct uart_port *port)
731 */ 716 */
732static void imx_release_port(struct uart_port *port) 717static void imx_release_port(struct uart_port *port)
733{ 718{
734 struct imx_port *sport = (struct imx_port *)port; 719 struct platform_device *pdev = to_platform_device(port->dev);
720 struct resource *mmres;
735 721
736 release_mem_region(sport->port.mapbase, UART_PORT_SIZE); 722 mmres = platform_get_resource(pdev, IORESOURCE_MEM, 0);
723 release_mem_region(mmres->start, mmres->end - mmres->start + 1);
737} 724}
738 725
739/* 726/*
@@ -741,10 +728,18 @@ static void imx_release_port(struct uart_port *port)
741 */ 728 */
742static int imx_request_port(struct uart_port *port) 729static int imx_request_port(struct uart_port *port)
743{ 730{
744 struct imx_port *sport = (struct imx_port *)port; 731 struct platform_device *pdev = to_platform_device(port->dev);
732 struct resource *mmres;
733 void *ret;
734
735 mmres = platform_get_resource(pdev, IORESOURCE_MEM, 0);
736 if (!mmres)
737 return -ENODEV;
738
739 ret = request_mem_region(mmres->start, mmres->end - mmres->start + 1,
740 "imx-uart");
745 741
746 return request_mem_region(sport->port.mapbase, UART_PORT_SIZE, 742 return ret ? 0 : -EBUSY;
747 "imx-uart") != NULL ? 0 : -EBUSY;
748} 743}
749 744
750/* 745/*
@@ -815,7 +810,7 @@ static struct imx_port imx_ports[] = {
815 .type = PORT_IMX, 810 .type = PORT_IMX,
816 .iotype = UPIO_MEM, 811 .iotype = UPIO_MEM,
817 .membase = (void *)IMX_UART1_BASE, 812 .membase = (void *)IMX_UART1_BASE,
818 .mapbase = IMX_UART1_BASE, /* FIXME */ 813 .mapbase = 0x00206000,
819 .irq = UART1_MINT_RX, 814 .irq = UART1_MINT_RX,
820 .uartclk = 16000000, 815 .uartclk = 16000000,
821 .fifosize = 32, 816 .fifosize = 32,
@@ -831,7 +826,7 @@ static struct imx_port imx_ports[] = {
831 .type = PORT_IMX, 826 .type = PORT_IMX,
832 .iotype = UPIO_MEM, 827 .iotype = UPIO_MEM,
833 .membase = (void *)IMX_UART2_BASE, 828 .membase = (void *)IMX_UART2_BASE,
834 .mapbase = IMX_UART2_BASE, /* FIXME */ 829 .mapbase = 0x00207000,
835 .irq = UART2_MINT_RX, 830 .irq = UART2_MINT_RX,
836 .uartclk = 16000000, 831 .uartclk = 16000000,
837 .fifosize = 32, 832 .fifosize = 32,
diff --git a/drivers/serial/mcfserial.c b/drivers/serial/mcfserial.c
index 99af084c7cec..ddd3aa50d4ad 100644
--- a/drivers/serial/mcfserial.c
+++ b/drivers/serial/mcfserial.c
@@ -40,7 +40,6 @@
40#include <asm/io.h> 40#include <asm/io.h>
41#include <asm/irq.h> 41#include <asm/irq.h>
42#include <asm/system.h> 42#include <asm/system.h>
43#include <asm/semaphore.h>
44#include <asm/delay.h> 43#include <asm/delay.h>
45#include <asm/coldfire.h> 44#include <asm/coldfire.h>
46#include <asm/mcfsim.h> 45#include <asm/mcfsim.h>
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c
index eff593080d4f..c2ea5d4df44a 100644
--- a/drivers/serial/sh-sci.c
+++ b/drivers/serial/sh-sci.c
@@ -333,7 +333,6 @@ static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag)
333 } 333 }
334 sci_out(port, SCFCR, fcr_val); 334 sci_out(port, SCFCR, fcr_val);
335} 335}
336
337#elif defined(CONFIG_CPU_SH3) 336#elif defined(CONFIG_CPU_SH3)
338/* For SH7705, SH7706, SH7707, SH7709, SH7709A, SH7729 */ 337/* For SH7705, SH7706, SH7707, SH7709, SH7709A, SH7729 */
339static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag) 338static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag)
@@ -384,6 +383,12 @@ static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag)
384 383
385 sci_out(port, SCFCR, fcr_val); 384 sci_out(port, SCFCR, fcr_val);
386} 385}
386#elif defined(CONFIG_CPU_SUBTYPE_SH7723)
387static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag)
388{
389 /* Nothing to do here.. */
390 sci_out(port, SCFCR, 0);
391}
387#else 392#else
388/* For SH7750 */ 393/* For SH7750 */
389static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag) 394static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag)
diff --git a/drivers/serial/sh-sci.h b/drivers/serial/sh-sci.h
index 01a9dd715f5d..fa8700a968fc 100644
--- a/drivers/serial/sh-sci.h
+++ b/drivers/serial/sh-sci.h
@@ -1,20 +1,5 @@
1/* $Id: sh-sci.h,v 1.4 2004/02/19 16:43:56 lethal Exp $
2 *
3 * linux/drivers/serial/sh-sci.h
4 *
5 * SuperH on-chip serial module support. (SCI with no FIFO / with FIFO)
6 * Copyright (C) 1999, 2000 Niibe Yutaka
7 * Copyright (C) 2000 Greg Banks
8 * Copyright (C) 2002, 2003 Paul Mundt
9 * Modified to support multiple serial ports. Stuart Menefy (May 2000).
10 * Modified to support SH7300(SH-Mobile) SCIF. Takashi Kusuda (Jun 2003).
11 * Modified to support H8/300 Series Yoshinori Sato (Feb 2004).
12 * Removed SH7300 support (Jul 2007).
13 * Modified to support SH7720 SCIF. Markus Brunner, Mark Jonas (Aug 2007).
14 */
15#include <linux/serial_core.h> 1#include <linux/serial_core.h>
16#include <asm/io.h> 2#include <asm/io.h>
17
18#include <asm/gpio.h> 3#include <asm/gpio.h>
19 4
20#if defined(CONFIG_H83007) || defined(CONFIG_H83068) 5#if defined(CONFIG_H83007) || defined(CONFIG_H83068)
@@ -102,6 +87,15 @@
102# define SCSPTR0 SCPDR0 87# define SCSPTR0 SCPDR0
103# define SCIF_ORER 0x0001 /* overrun error bit */ 88# define SCIF_ORER 0x0001 /* overrun error bit */
104# define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ 89# define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
90#elif defined(CONFIG_CPU_SUBTYPE_SH7723)
91# define SCSPTR0 0xa4050160
92# define SCSPTR1 0xa405013e
93# define SCSPTR2 0xa4050160
94# define SCSPTR3 0xa405013e
95# define SCSPTR4 0xa4050128
96# define SCSPTR5 0xa4050128
97# define SCIF_ORER 0x0001 /* overrun error bit */
98# define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
105# define SCIF_ONLY 99# define SCIF_ONLY
106#elif defined(CONFIG_CPU_SUBTYPE_SH4_202) 100#elif defined(CONFIG_CPU_SUBTYPE_SH4_202)
107# define SCSPTR2 0xffe80020 /* 16 bit SCIF */ 101# define SCSPTR2 0xffe80020 /* 16 bit SCIF */
@@ -395,6 +389,11 @@
395 h8_sci_offset, h8_sci_size) \ 389 h8_sci_offset, h8_sci_size) \
396 CPU_SCI_FNS(name, h8_sci_offset, h8_sci_size) 390 CPU_SCI_FNS(name, h8_sci_offset, h8_sci_size)
397#define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) 391#define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size)
392#elif defined(CONFIG_CPU_SUBTYPE_SH7723)
393 #define SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size, sh4_scif_offset, sh4_scif_size) \
394 CPU_SCIx_FNS(name, sh4_scifa_offset, sh4_scifa_size, sh4_scif_offset, sh4_scif_size)
395 #define SCIF_FNS(name, sh4_scif_offset, sh4_scif_size) \
396 CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size)
398#else 397#else
399#define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \ 398#define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \
400 sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size, \ 399 sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size, \
@@ -419,6 +418,18 @@ SCIF_FNS(SCFDR, 0x1c, 16)
419SCIF_FNS(SCxTDR, 0x20, 8) 418SCIF_FNS(SCxTDR, 0x20, 8)
420SCIF_FNS(SCxRDR, 0x24, 8) 419SCIF_FNS(SCxRDR, 0x24, 8)
421SCIF_FNS(SCLSR, 0x24, 16) 420SCIF_FNS(SCLSR, 0x24, 16)
421#elif defined(CONFIG_CPU_SUBTYPE_SH7723)
422SCIx_FNS(SCSMR, 0x00, 16, 0x00, 16)
423SCIx_FNS(SCBRR, 0x04, 8, 0x04, 8)
424SCIx_FNS(SCSCR, 0x08, 16, 0x08, 16)
425SCIx_FNS(SCxTDR, 0x20, 8, 0x0c, 8)
426SCIx_FNS(SCxSR, 0x14, 16, 0x10, 16)
427SCIx_FNS(SCxRDR, 0x24, 8, 0x14, 8)
428SCIF_FNS(SCTDSR, 0x0c, 8)
429SCIF_FNS(SCFER, 0x10, 16)
430SCIF_FNS(SCFCR, 0x18, 16)
431SCIF_FNS(SCFDR, 0x1c, 16)
432SCIF_FNS(SCLSR, 0x24, 16)
422#else 433#else
423/* reg SCI/SH3 SCI/SH4 SCIF/SH3 SCIF/SH4 SCI/H8*/ 434/* reg SCI/SH3 SCI/SH4 SCIF/SH3 SCIF/SH4 SCI/H8*/
424/* name off sz off sz off sz off sz off sz*/ 435/* name off sz off sz off sz off sz off sz*/
@@ -589,6 +600,23 @@ static inline int sci_rxd_in(struct uart_port *port)
589 return ctrl_inb(SCPDR0) & 0x0001 ? 1 : 0; /* SCIF0 */ 600 return ctrl_inb(SCPDR0) & 0x0001 ? 1 : 0; /* SCIF0 */
590 return 1; 601 return 1;
591} 602}
603#elif defined(CONFIG_CPU_SUBTYPE_SH7723)
604static inline int sci_rxd_in(struct uart_port *port)
605{
606 if (port->mapbase == 0xffe00000)
607 return ctrl_inb(SCSPTR0) & 0x0008 ? 1 : 0; /* SCIF0 */
608 if (port->mapbase == 0xffe10000)
609 return ctrl_inb(SCSPTR1) & 0x0020 ? 1 : 0; /* SCIF1 */
610 if (port->mapbase == 0xffe20000)
611 return ctrl_inb(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF2 */
612 if (port->mapbase == 0xa4e30000)
613 return ctrl_inb(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF3 */
614 if (port->mapbase == 0xa4e40000)
615 return ctrl_inb(SCSPTR4) & 0x0001 ? 1 : 0; /* SCIF4 */
616 if (port->mapbase == 0xa4e50000)
617 return ctrl_inb(SCSPTR5) & 0x0008 ? 1 : 0; /* SCIF5 */
618 return 1;
619}
592#elif defined(CONFIG_CPU_SUBTYPE_SH5_101) || defined(CONFIG_CPU_SUBTYPE_SH5_103) 620#elif defined(CONFIG_CPU_SUBTYPE_SH5_101) || defined(CONFIG_CPU_SUBTYPE_SH5_103)
593static inline int sci_rxd_in(struct uart_port *port) 621static inline int sci_rxd_in(struct uart_port *port)
594{ 622{
@@ -727,6 +755,8 @@ static inline int sci_rxd_in(struct uart_port *port)
727 defined(CONFIG_CPU_SUBTYPE_SH7720) || \ 755 defined(CONFIG_CPU_SUBTYPE_SH7720) || \
728 defined(CONFIG_CPU_SUBTYPE_SH7721) 756 defined(CONFIG_CPU_SUBTYPE_SH7721)
729#define SCBRR_VALUE(bps, clk) (((clk*2)+16*bps)/(32*bps)-1) 757#define SCBRR_VALUE(bps, clk) (((clk*2)+16*bps)/(32*bps)-1)
758#elif defined(CONFIG_CPU_SUBTYPE_SH7723)
759#define SCBRR_VALUE(bps, clk) (((clk*2)+16*bps)/(16*bps)-1)
730#elif defined(__H8300H__) || defined(__H8300S__) 760#elif defined(__H8300H__) || defined(__H8300S__)
731#define SCBRR_VALUE(bps) (((CONFIG_CPU_CLOCK*1000/32)/bps)-1) 761#define SCBRR_VALUE(bps) (((CONFIG_CPU_CLOCK*1000/32)/bps)-1)
732#elif defined(CONFIG_SUPERH64) 762#elif defined(CONFIG_SUPERH64)
diff --git a/drivers/usb/atm/usbatm.h b/drivers/usb/atm/usbatm.h
index ff8551e93372..fc6c2be5999c 100644
--- a/drivers/usb/atm/usbatm.h
+++ b/drivers/usb/atm/usbatm.h
@@ -24,7 +24,6 @@
24#ifndef _USBATM_H_ 24#ifndef _USBATM_H_
25#define _USBATM_H_ 25#define _USBATM_H_
26 26
27#include <asm/semaphore.h>
28#include <linux/atm.h> 27#include <linux/atm.h>
29#include <linux/atmdev.h> 28#include <linux/atmdev.h>
30#include <linux/completion.h> 29#include <linux/completion.h>
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 68fc5219ca15..57aeca160f38 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -23,7 +23,6 @@
23#include <linux/mutex.h> 23#include <linux/mutex.h>
24#include <linux/freezer.h> 24#include <linux/freezer.h>
25 25
26#include <asm/semaphore.h>
27#include <asm/uaccess.h> 26#include <asm/uaccess.h>
28#include <asm/byteorder.h> 27#include <asm/byteorder.h>
29 28
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 6f45dd669b33..d681bb27fa58 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -118,10 +118,10 @@ config USB_AMD5536UDC
118config USB_GADGET_ATMEL_USBA 118config USB_GADGET_ATMEL_USBA
119 boolean "Atmel USBA" 119 boolean "Atmel USBA"
120 select USB_GADGET_DUALSPEED 120 select USB_GADGET_DUALSPEED
121 depends on AVR32 121 depends on AVR32 || ARCH_AT91CAP9
122 help 122 help
123 USBA is the integrated high-speed USB Device controller on 123 USBA is the integrated high-speed USB Device controller on
124 the AT32AP700x processors from Atmel. 124 the AT32AP700x and AT91CAP9 processors from Atmel.
125 125
126config USB_ATMEL_USBA 126config USB_ATMEL_USBA
127 tristate 127 tristate
diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c
index b0db4c31d018..e756023362c2 100644
--- a/drivers/usb/gadget/atmel_usba_udc.c
+++ b/drivers/usb/gadget/atmel_usba_udc.c
@@ -18,6 +18,7 @@
18#include <linux/platform_device.h> 18#include <linux/platform_device.h>
19#include <linux/usb/ch9.h> 19#include <linux/usb/ch9.h>
20#include <linux/usb/gadget.h> 20#include <linux/usb/gadget.h>
21#include <linux/usb/atmel_usba_udc.h>
21#include <linux/delay.h> 22#include <linux/delay.h>
22 23
23#include <asm/gpio.h> 24#include <asm/gpio.h>
@@ -27,6 +28,7 @@
27 28
28 29
29static struct usba_udc the_udc; 30static struct usba_udc the_udc;
31static struct usba_ep *usba_ep;
30 32
31#ifdef CONFIG_USB_GADGET_DEBUG_FS 33#ifdef CONFIG_USB_GADGET_DEBUG_FS
32#include <linux/debugfs.h> 34#include <linux/debugfs.h>
@@ -324,53 +326,28 @@ static int vbus_is_present(struct usba_udc *udc)
324 return 1; 326 return 1;
325} 327}
326 328
327static void copy_to_fifo(void __iomem *fifo, const void *buf, int len) 329#if defined(CONFIG_AVR32)
330
331static void toggle_bias(int is_on)
328{ 332{
329 unsigned long tmp;
330
331 DBG(DBG_FIFO, "copy to FIFO (len %d):\n", len);
332 for (; len > 0; len -= 4, buf += 4, fifo += 4) {
333 tmp = *(unsigned long *)buf;
334 if (len >= 4) {
335 DBG(DBG_FIFO, " -> %08lx\n", tmp);
336 __raw_writel(tmp, fifo);
337 } else {
338 do {
339 DBG(DBG_FIFO, " -> %02lx\n", tmp >> 24);
340 __raw_writeb(tmp >> 24, fifo);
341 fifo++;
342 tmp <<= 8;
343 } while (--len);
344 break;
345 }
346 }
347} 333}
348 334
349static void copy_from_fifo(void *buf, void __iomem *fifo, int len) 335#elif defined(CONFIG_ARCH_AT91)
336
337#include <asm/arch/at91_pmc.h>
338
339static void toggle_bias(int is_on)
350{ 340{
351 union { 341 unsigned int uckr = at91_sys_read(AT91_CKGR_UCKR);
352 unsigned long *w; 342
353 unsigned char *b; 343 if (is_on)
354 } p; 344 at91_sys_write(AT91_CKGR_UCKR, uckr | AT91_PMC_BIASEN);
355 unsigned long tmp; 345 else
356 346 at91_sys_write(AT91_CKGR_UCKR, uckr & ~(AT91_PMC_BIASEN));
357 DBG(DBG_FIFO, "copy from FIFO (len %d):\n", len);
358 for (p.w = buf; len > 0; len -= 4, p.w++, fifo += 4) {
359 if (len >= 4) {
360 tmp = __raw_readl(fifo);
361 *p.w = tmp;
362 DBG(DBG_FIFO, " -> %08lx\n", tmp);
363 } else {
364 do {
365 tmp = __raw_readb(fifo);
366 *p.b = tmp;
367 DBG(DBG_FIFO, " -> %02lx\n", tmp);
368 fifo++, p.b++;
369 } while (--len);
370 }
371 }
372} 347}
373 348
349#endif /* CONFIG_ARCH_AT91 */
350
374static void next_fifo_transaction(struct usba_ep *ep, struct usba_request *req) 351static void next_fifo_transaction(struct usba_ep *ep, struct usba_request *req)
375{ 352{
376 unsigned int transaction_len; 353 unsigned int transaction_len;
@@ -387,7 +364,7 @@ static void next_fifo_transaction(struct usba_ep *ep, struct usba_request *req)
387 ep->ep.name, req, transaction_len, 364 ep->ep.name, req, transaction_len,
388 req->last_transaction ? ", done" : ""); 365 req->last_transaction ? ", done" : "");
389 366
390 copy_to_fifo(ep->fifo, req->req.buf + req->req.actual, transaction_len); 367 memcpy_toio(ep->fifo, req->req.buf + req->req.actual, transaction_len);
391 usba_ep_writel(ep, SET_STA, USBA_TX_PK_RDY); 368 usba_ep_writel(ep, SET_STA, USBA_TX_PK_RDY);
392 req->req.actual += transaction_len; 369 req->req.actual += transaction_len;
393} 370}
@@ -476,7 +453,7 @@ static void receive_data(struct usba_ep *ep)
476 bytecount = req->req.length - req->req.actual; 453 bytecount = req->req.length - req->req.actual;
477 } 454 }
478 455
479 copy_from_fifo(req->req.buf + req->req.actual, 456 memcpy_fromio(req->req.buf + req->req.actual,
480 ep->fifo, bytecount); 457 ep->fifo, bytecount);
481 req->req.actual += bytecount; 458 req->req.actual += bytecount;
482 459
@@ -1029,33 +1006,6 @@ static const struct usb_gadget_ops usba_udc_ops = {
1029 .set_selfpowered = usba_udc_set_selfpowered, 1006 .set_selfpowered = usba_udc_set_selfpowered,
1030}; 1007};
1031 1008
1032#define EP(nam, idx, maxpkt, maxbk, dma, isoc) \
1033{ \
1034 .ep = { \
1035 .ops = &usba_ep_ops, \
1036 .name = nam, \
1037 .maxpacket = maxpkt, \
1038 }, \
1039 .udc = &the_udc, \
1040 .queue = LIST_HEAD_INIT(usba_ep[idx].queue), \
1041 .fifo_size = maxpkt, \
1042 .nr_banks = maxbk, \
1043 .index = idx, \
1044 .can_dma = dma, \
1045 .can_isoc = isoc, \
1046}
1047
1048static struct usba_ep usba_ep[] = {
1049 EP("ep0", 0, 64, 1, 0, 0),
1050 EP("ep1in-bulk", 1, 512, 2, 1, 1),
1051 EP("ep2out-bulk", 2, 512, 2, 1, 1),
1052 EP("ep3in-int", 3, 64, 3, 1, 0),
1053 EP("ep4out-int", 4, 64, 3, 1, 0),
1054 EP("ep5in-iso", 5, 1024, 3, 1, 1),
1055 EP("ep6out-iso", 6, 1024, 3, 1, 1),
1056};
1057#undef EP
1058
1059static struct usb_endpoint_descriptor usba_ep0_desc = { 1009static struct usb_endpoint_descriptor usba_ep0_desc = {
1060 .bLength = USB_DT_ENDPOINT_SIZE, 1010 .bLength = USB_DT_ENDPOINT_SIZE,
1061 .bDescriptorType = USB_DT_ENDPOINT, 1011 .bDescriptorType = USB_DT_ENDPOINT,
@@ -1074,7 +1024,6 @@ static void nop_release(struct device *dev)
1074static struct usba_udc the_udc = { 1024static struct usba_udc the_udc = {
1075 .gadget = { 1025 .gadget = {
1076 .ops = &usba_udc_ops, 1026 .ops = &usba_udc_ops,
1077 .ep0 = &usba_ep[0].ep,
1078 .ep_list = LIST_HEAD_INIT(the_udc.gadget.ep_list), 1027 .ep_list = LIST_HEAD_INIT(the_udc.gadget.ep_list),
1079 .is_dualspeed = 1, 1028 .is_dualspeed = 1,
1080 .name = "atmel_usba_udc", 1029 .name = "atmel_usba_udc",
@@ -1231,7 +1180,7 @@ static int do_test_mode(struct usba_udc *udc)
1231 } else { 1180 } else {
1232 usba_ep_writel(ep, CTL_ENB, USBA_EPT_ENABLE); 1181 usba_ep_writel(ep, CTL_ENB, USBA_EPT_ENABLE);
1233 usba_writel(udc, TST, USBA_TST_PKT_MODE); 1182 usba_writel(udc, TST, USBA_TST_PKT_MODE);
1234 copy_to_fifo(ep->fifo, test_packet_buffer, 1183 memcpy_toio(ep->fifo, test_packet_buffer,
1235 sizeof(test_packet_buffer)); 1184 sizeof(test_packet_buffer));
1236 usba_ep_writel(ep, SET_STA, USBA_TX_PK_RDY); 1185 usba_ep_writel(ep, SET_STA, USBA_TX_PK_RDY);
1237 dev_info(dev, "Entering Test_Packet mode...\n"); 1186 dev_info(dev, "Entering Test_Packet mode...\n");
@@ -1530,13 +1479,13 @@ restart:
1530 DBG(DBG_HW, "Packet length: %u\n", pkt_len); 1479 DBG(DBG_HW, "Packet length: %u\n", pkt_len);
1531 if (pkt_len != sizeof(crq)) { 1480 if (pkt_len != sizeof(crq)) {
1532 pr_warning("udc: Invalid packet length %u " 1481 pr_warning("udc: Invalid packet length %u "
1533 "(expected %lu)\n", pkt_len, sizeof(crq)); 1482 "(expected %zu)\n", pkt_len, sizeof(crq));
1534 set_protocol_stall(udc, ep); 1483 set_protocol_stall(udc, ep);
1535 return; 1484 return;
1536 } 1485 }
1537 1486
1538 DBG(DBG_FIFO, "Copying ctrl request from 0x%p:\n", ep->fifo); 1487 DBG(DBG_FIFO, "Copying ctrl request from 0x%p:\n", ep->fifo);
1539 copy_from_fifo(crq.data, ep->fifo, sizeof(crq)); 1488 memcpy_fromio(crq.data, ep->fifo, sizeof(crq));
1540 1489
1541 /* Free up one bank in the FIFO so that we can 1490 /* Free up one bank in the FIFO so that we can
1542 * generate or receive a reply right away. */ 1491 * generate or receive a reply right away. */
@@ -1688,6 +1637,7 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
1688 DBG(DBG_INT, "irq, status=%#08x\n", status); 1637 DBG(DBG_INT, "irq, status=%#08x\n", status);
1689 1638
1690 if (status & USBA_DET_SUSPEND) { 1639 if (status & USBA_DET_SUSPEND) {
1640 toggle_bias(0);
1691 usba_writel(udc, INT_CLR, USBA_DET_SUSPEND); 1641 usba_writel(udc, INT_CLR, USBA_DET_SUSPEND);
1692 DBG(DBG_BUS, "Suspend detected\n"); 1642 DBG(DBG_BUS, "Suspend detected\n");
1693 if (udc->gadget.speed != USB_SPEED_UNKNOWN 1643 if (udc->gadget.speed != USB_SPEED_UNKNOWN
@@ -1699,6 +1649,7 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
1699 } 1649 }
1700 1650
1701 if (status & USBA_WAKE_UP) { 1651 if (status & USBA_WAKE_UP) {
1652 toggle_bias(1);
1702 usba_writel(udc, INT_CLR, USBA_WAKE_UP); 1653 usba_writel(udc, INT_CLR, USBA_WAKE_UP);
1703 DBG(DBG_BUS, "Wake Up CPU detected\n"); 1654 DBG(DBG_BUS, "Wake Up CPU detected\n");
1704 } 1655 }
@@ -1792,12 +1743,14 @@ static irqreturn_t usba_vbus_irq(int irq, void *devid)
1792 vbus = gpio_get_value(udc->vbus_pin); 1743 vbus = gpio_get_value(udc->vbus_pin);
1793 if (vbus != udc->vbus_prev) { 1744 if (vbus != udc->vbus_prev) {
1794 if (vbus) { 1745 if (vbus) {
1795 usba_writel(udc, CTRL, USBA_EN_USBA); 1746 toggle_bias(1);
1747 usba_writel(udc, CTRL, USBA_ENABLE_MASK);
1796 usba_writel(udc, INT_ENB, USBA_END_OF_RESET); 1748 usba_writel(udc, INT_ENB, USBA_END_OF_RESET);
1797 } else { 1749 } else {
1798 udc->gadget.speed = USB_SPEED_UNKNOWN; 1750 udc->gadget.speed = USB_SPEED_UNKNOWN;
1799 reset_all_endpoints(udc); 1751 reset_all_endpoints(udc);
1800 usba_writel(udc, CTRL, 0); 1752 toggle_bias(0);
1753 usba_writel(udc, CTRL, USBA_DISABLE_MASK);
1801 spin_unlock(&udc->lock); 1754 spin_unlock(&udc->lock);
1802 udc->driver->disconnect(&udc->gadget); 1755 udc->driver->disconnect(&udc->gadget);
1803 spin_lock(&udc->lock); 1756 spin_lock(&udc->lock);
@@ -1850,7 +1803,8 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
1850 /* If Vbus is present, enable the controller and wait for reset */ 1803 /* If Vbus is present, enable the controller and wait for reset */
1851 spin_lock_irqsave(&udc->lock, flags); 1804 spin_lock_irqsave(&udc->lock, flags);
1852 if (vbus_is_present(udc) && udc->vbus_prev == 0) { 1805 if (vbus_is_present(udc) && udc->vbus_prev == 0) {
1853 usba_writel(udc, CTRL, USBA_EN_USBA); 1806 toggle_bias(1);
1807 usba_writel(udc, CTRL, USBA_ENABLE_MASK);
1854 usba_writel(udc, INT_ENB, USBA_END_OF_RESET); 1808 usba_writel(udc, INT_ENB, USBA_END_OF_RESET);
1855 } 1809 }
1856 spin_unlock_irqrestore(&udc->lock, flags); 1810 spin_unlock_irqrestore(&udc->lock, flags);
@@ -1883,7 +1837,8 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
1883 spin_unlock_irqrestore(&udc->lock, flags); 1837 spin_unlock_irqrestore(&udc->lock, flags);
1884 1838
1885 /* This will also disable the DP pullup */ 1839 /* This will also disable the DP pullup */
1886 usba_writel(udc, CTRL, 0); 1840 toggle_bias(0);
1841 usba_writel(udc, CTRL, USBA_DISABLE_MASK);
1887 1842
1888 driver->unbind(&udc->gadget); 1843 driver->unbind(&udc->gadget);
1889 udc->gadget.dev.driver = NULL; 1844 udc->gadget.dev.driver = NULL;
@@ -1908,7 +1863,7 @@ static int __init usba_udc_probe(struct platform_device *pdev)
1908 1863
1909 regs = platform_get_resource(pdev, IORESOURCE_MEM, CTRL_IOMEM_ID); 1864 regs = platform_get_resource(pdev, IORESOURCE_MEM, CTRL_IOMEM_ID);
1910 fifo = platform_get_resource(pdev, IORESOURCE_MEM, FIFO_IOMEM_ID); 1865 fifo = platform_get_resource(pdev, IORESOURCE_MEM, FIFO_IOMEM_ID);
1911 if (!regs || !fifo) 1866 if (!regs || !fifo || !pdata)
1912 return -ENXIO; 1867 return -ENXIO;
1913 1868
1914 irq = platform_get_irq(pdev, 0); 1869 irq = platform_get_irq(pdev, 0);
@@ -1953,19 +1908,48 @@ static int __init usba_udc_probe(struct platform_device *pdev)
1953 1908
1954 /* Make sure we start from a clean slate */ 1909 /* Make sure we start from a clean slate */
1955 clk_enable(pclk); 1910 clk_enable(pclk);
1956 usba_writel(udc, CTRL, 0); 1911 toggle_bias(0);
1912 usba_writel(udc, CTRL, USBA_DISABLE_MASK);
1957 clk_disable(pclk); 1913 clk_disable(pclk);
1958 1914
1915 usba_ep = kmalloc(sizeof(struct usba_ep) * pdata->num_ep,
1916 GFP_KERNEL);
1917 if (!usba_ep)
1918 goto err_alloc_ep;
1919
1920 the_udc.gadget.ep0 = &usba_ep[0].ep;
1921
1959 INIT_LIST_HEAD(&usba_ep[0].ep.ep_list); 1922 INIT_LIST_HEAD(&usba_ep[0].ep.ep_list);
1960 usba_ep[0].ep_regs = udc->regs + USBA_EPT_BASE(0); 1923 usba_ep[0].ep_regs = udc->regs + USBA_EPT_BASE(0);
1961 usba_ep[0].dma_regs = udc->regs + USBA_DMA_BASE(0); 1924 usba_ep[0].dma_regs = udc->regs + USBA_DMA_BASE(0);
1962 usba_ep[0].fifo = udc->fifo + USBA_FIFO_BASE(0); 1925 usba_ep[0].fifo = udc->fifo + USBA_FIFO_BASE(0);
1963 for (i = 1; i < ARRAY_SIZE(usba_ep); i++) { 1926 usba_ep[0].ep.ops = &usba_ep_ops;
1927 usba_ep[0].ep.name = pdata->ep[0].name;
1928 usba_ep[0].ep.maxpacket = pdata->ep[0].fifo_size;
1929 usba_ep[0].udc = &the_udc;
1930 INIT_LIST_HEAD(&usba_ep[0].queue);
1931 usba_ep[0].fifo_size = pdata->ep[0].fifo_size;
1932 usba_ep[0].nr_banks = pdata->ep[0].nr_banks;
1933 usba_ep[0].index = pdata->ep[0].index;
1934 usba_ep[0].can_dma = pdata->ep[0].can_dma;
1935 usba_ep[0].can_isoc = pdata->ep[0].can_isoc;
1936
1937 for (i = 1; i < pdata->num_ep; i++) {
1964 struct usba_ep *ep = &usba_ep[i]; 1938 struct usba_ep *ep = &usba_ep[i];
1965 1939
1966 ep->ep_regs = udc->regs + USBA_EPT_BASE(i); 1940 ep->ep_regs = udc->regs + USBA_EPT_BASE(i);
1967 ep->dma_regs = udc->regs + USBA_DMA_BASE(i); 1941 ep->dma_regs = udc->regs + USBA_DMA_BASE(i);
1968 ep->fifo = udc->fifo + USBA_FIFO_BASE(i); 1942 ep->fifo = udc->fifo + USBA_FIFO_BASE(i);
1943 ep->ep.ops = &usba_ep_ops;
1944 ep->ep.name = pdata->ep[i].name;
1945 ep->ep.maxpacket = pdata->ep[i].fifo_size;
1946 ep->udc = &the_udc;
1947 INIT_LIST_HEAD(&ep->queue);
1948 ep->fifo_size = pdata->ep[i].fifo_size;
1949 ep->nr_banks = pdata->ep[i].nr_banks;
1950 ep->index = pdata->ep[i].index;
1951 ep->can_dma = pdata->ep[i].can_dma;
1952 ep->can_isoc = pdata->ep[i].can_isoc;
1969 1953
1970 list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list); 1954 list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list);
1971 } 1955 }
@@ -1984,7 +1968,7 @@ static int __init usba_udc_probe(struct platform_device *pdev)
1984 goto err_device_add; 1968 goto err_device_add;
1985 } 1969 }
1986 1970
1987 if (pdata && pdata->vbus_pin != GPIO_PIN_NONE) { 1971 if (pdata->vbus_pin >= 0) {
1988 if (!gpio_request(pdata->vbus_pin, "atmel_usba_udc")) { 1972 if (!gpio_request(pdata->vbus_pin, "atmel_usba_udc")) {
1989 udc->vbus_pin = pdata->vbus_pin; 1973 udc->vbus_pin = pdata->vbus_pin;
1990 1974
@@ -2004,7 +1988,7 @@ static int __init usba_udc_probe(struct platform_device *pdev)
2004 } 1988 }
2005 1989
2006 usba_init_debugfs(udc); 1990 usba_init_debugfs(udc);
2007 for (i = 1; i < ARRAY_SIZE(usba_ep); i++) 1991 for (i = 1; i < pdata->num_ep; i++)
2008 usba_ep_init_debugfs(udc, &usba_ep[i]); 1992 usba_ep_init_debugfs(udc, &usba_ep[i]);
2009 1993
2010 return 0; 1994 return 0;
@@ -2012,6 +1996,8 @@ static int __init usba_udc_probe(struct platform_device *pdev)
2012err_device_add: 1996err_device_add:
2013 free_irq(irq, udc); 1997 free_irq(irq, udc);
2014err_request_irq: 1998err_request_irq:
1999 kfree(usba_ep);
2000err_alloc_ep:
2015 iounmap(udc->fifo); 2001 iounmap(udc->fifo);
2016err_map_fifo: 2002err_map_fifo:
2017 iounmap(udc->regs); 2003 iounmap(udc->regs);
@@ -2029,10 +2015,11 @@ static int __exit usba_udc_remove(struct platform_device *pdev)
2029{ 2015{
2030 struct usba_udc *udc; 2016 struct usba_udc *udc;
2031 int i; 2017 int i;
2018 struct usba_platform_data *pdata = pdev->dev.platform_data;
2032 2019
2033 udc = platform_get_drvdata(pdev); 2020 udc = platform_get_drvdata(pdev);
2034 2021
2035 for (i = 1; i < ARRAY_SIZE(usba_ep); i++) 2022 for (i = 1; i < pdata->num_ep; i++)
2036 usba_ep_cleanup_debugfs(&usba_ep[i]); 2023 usba_ep_cleanup_debugfs(&usba_ep[i]);
2037 usba_cleanup_debugfs(udc); 2024 usba_cleanup_debugfs(udc);
2038 2025
@@ -2040,6 +2027,7 @@ static int __exit usba_udc_remove(struct platform_device *pdev)
2040 gpio_free(udc->vbus_pin); 2027 gpio_free(udc->vbus_pin);
2041 2028
2042 free_irq(udc->irq, udc); 2029 free_irq(udc->irq, udc);
2030 kfree(usba_ep);
2043 iounmap(udc->fifo); 2031 iounmap(udc->fifo);
2044 iounmap(udc->regs); 2032 iounmap(udc->regs);
2045 clk_put(udc->hclk); 2033 clk_put(udc->hclk);
diff --git a/drivers/usb/gadget/atmel_usba_udc.h b/drivers/usb/gadget/atmel_usba_udc.h
index 08bf6f9aaf7e..f7baea307f0d 100644
--- a/drivers/usb/gadget/atmel_usba_udc.h
+++ b/drivers/usb/gadget/atmel_usba_udc.h
@@ -41,6 +41,15 @@
41#define USBA_EN_USBA (1 << 8) 41#define USBA_EN_USBA (1 << 8)
42#define USBA_DETACH (1 << 9) 42#define USBA_DETACH (1 << 9)
43#define USBA_REMOTE_WAKE_UP (1 << 10) 43#define USBA_REMOTE_WAKE_UP (1 << 10)
44#define USBA_PULLD_DIS (1 << 11)
45
46#if defined(CONFIG_AVR32)
47#define USBA_ENABLE_MASK USBA_EN_USBA
48#define USBA_DISABLE_MASK 0
49#elif defined(CONFIG_ARCH_AT91)
50#define USBA_ENABLE_MASK (USBA_EN_USBA | USBA_PULLD_DIS)
51#define USBA_DISABLE_MASK USBA_DETACH
52#endif /* CONFIG_ARCH_AT91 */
44 53
45/* Bitfields in FNUM */ 54/* Bitfields in FNUM */
46#define USBA_MICRO_FRAME_NUM_OFFSET 0 55#define USBA_MICRO_FRAME_NUM_OFFSET 0
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 46ee7f4c0912..85074cb36f38 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1033,7 +1033,7 @@ MODULE_LICENSE ("GPL");
1033#define OF_PLATFORM_DRIVER ehci_hcd_ppc_of_driver 1033#define OF_PLATFORM_DRIVER ehci_hcd_ppc_of_driver
1034#endif 1034#endif
1035 1035
1036#ifdef CONFIG_ARCH_ORION 1036#ifdef CONFIG_PLAT_ORION
1037#include "ehci-orion.c" 1037#include "ehci-orion.c"
1038#define PLATFORM_DRIVER ehci_orion_driver 1038#define PLATFORM_DRIVER ehci_orion_driver
1039#endif 1039#endif
diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c
index e129981f139f..d187d0313742 100644
--- a/drivers/usb/host/ehci-orion.c
+++ b/drivers/usb/host/ehci-orion.c
@@ -11,15 +11,18 @@
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/platform_device.h> 13#include <linux/platform_device.h>
14#include <asm/arch/orion.h> 14#include <linux/mbus.h>
15#include <asm/plat-orion/ehci-orion.h>
15 16
16#define rdl(off) __raw_readl(hcd->regs + (off)) 17#define rdl(off) __raw_readl(hcd->regs + (off))
17#define wrl(off, val) __raw_writel((val), hcd->regs + (off)) 18#define wrl(off, val) __raw_writel((val), hcd->regs + (off))
18 19
19#define USB_CAUSE 0x310
20#define USB_MASK 0x314
21#define USB_CMD 0x140 20#define USB_CMD 0x140
22#define USB_MODE 0x1a8 21#define USB_MODE 0x1a8
22#define USB_CAUSE 0x310
23#define USB_MASK 0x314
24#define USB_WINDOW_CTRL(i) (0x320 + ((i) << 4))
25#define USB_WINDOW_BASE(i) (0x324 + ((i) << 4))
23#define USB_IPG 0x360 26#define USB_IPG 0x360
24#define USB_PHY_PWR_CTRL 0x400 27#define USB_PHY_PWR_CTRL 0x400
25#define USB_PHY_TX_CTRL 0x420 28#define USB_PHY_TX_CTRL 0x420
@@ -162,8 +165,30 @@ static const struct hc_driver ehci_orion_hc_driver = {
162 .bus_resume = ehci_bus_resume, 165 .bus_resume = ehci_bus_resume,
163}; 166};
164 167
168static void __init
169ehci_orion_conf_mbus_windows(struct usb_hcd *hcd,
170 struct mbus_dram_target_info *dram)
171{
172 int i;
173
174 for (i = 0; i < 4; i++) {
175 wrl(USB_WINDOW_CTRL(i), 0);
176 wrl(USB_WINDOW_BASE(i), 0);
177 }
178
179 for (i = 0; i < dram->num_cs; i++) {
180 struct mbus_dram_window *cs = dram->cs + i;
181
182 wrl(USB_WINDOW_CTRL(i), ((cs->size - 1) & 0xffff0000) |
183 (cs->mbus_attr << 8) |
184 (dram->mbus_dram_target_id << 4) | 1);
185 wrl(USB_WINDOW_BASE(i), cs->base);
186 }
187}
188
165static int __init ehci_orion_drv_probe(struct platform_device *pdev) 189static int __init ehci_orion_drv_probe(struct platform_device *pdev)
166{ 190{
191 struct orion_ehci_data *pd = pdev->dev.platform_data;
167 struct resource *res; 192 struct resource *res;
168 struct usb_hcd *hcd; 193 struct usb_hcd *hcd;
169 struct ehci_hcd *ehci; 194 struct ehci_hcd *ehci;
@@ -227,6 +252,12 @@ static int __init ehci_orion_drv_probe(struct platform_device *pdev)
227 ehci->sbrn = 0x20; 252 ehci->sbrn = 0x20;
228 253
229 /* 254 /*
255 * (Re-)program MBUS remapping windows if we are asked to.
256 */
257 if (pd != NULL && pd->dram != NULL)
258 ehci_orion_conf_mbus_windows(hcd, pd->dram);
259
260 /*
230 * setup Orion USB controller 261 * setup Orion USB controller
231 */ 262 */
232 orion_usb_setup(hcd); 263 orion_usb_setup(hcd);
diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
index 1cb56f2d5c84..a5e4c3545c72 100644
--- a/drivers/usb/misc/appledisplay.c
+++ b/drivers/usb/misc/appledisplay.c
@@ -29,7 +29,6 @@
29#include <linux/timer.h> 29#include <linux/timer.h>
30#include <linux/workqueue.h> 30#include <linux/workqueue.h>
31#include <asm/atomic.h> 31#include <asm/atomic.h>
32#include <asm/semaphore.h>
33 32
34#define APPLE_VENDOR_ID 0x05AC 33#define APPLE_VENDOR_ID 0x05AC
35 34
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index cd3405953f74..e5ea5ef6335d 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -38,7 +38,6 @@
38#include <linux/serial.h> 38#include <linux/serial.h>
39#include <linux/ioctl.h> 39#include <linux/ioctl.h>
40#include <asm/uaccess.h> 40#include <asm/uaccess.h>
41#include <asm/semaphore.h>
42#include <linux/usb.h> 41#include <linux/usb.h>
43#include <linux/usb/serial.h> 42#include <linux/usb/serial.h>
44 43
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index e3d241f67afc..3a3776677339 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -82,7 +82,6 @@
82#include <linux/circ_buf.h> 82#include <linux/circ_buf.h>
83#include <linux/mutex.h> 83#include <linux/mutex.h>
84#include <asm/uaccess.h> 84#include <asm/uaccess.h>
85#include <asm/semaphore.h>
86#include <linux/usb.h> 85#include <linux/usb.h>
87#include <linux/usb/serial.h> 86#include <linux/usb/serial.h>
88 87
diff --git a/drivers/video/pxafb.c b/drivers/video/pxafb.c
index 97facb121c73..757651954e6c 100644
--- a/drivers/video/pxafb.c
+++ b/drivers/video/pxafb.c
@@ -45,6 +45,7 @@
45#include <asm/irq.h> 45#include <asm/irq.h>
46#include <asm/div64.h> 46#include <asm/div64.h>
47#include <asm/arch/pxa-regs.h> 47#include <asm/arch/pxa-regs.h>
48#include <asm/arch/pxa2xx-gpio.h>
48#include <asm/arch/bitfield.h> 49#include <asm/arch/bitfield.h>
49#include <asm/arch/pxafb.h> 50#include <asm/arch/pxafb.h>
50 51
diff --git a/drivers/watchdog/sc1200wdt.c b/drivers/watchdog/sc1200wdt.c
index 32ccd7c89c7d..35cddff7020f 100644
--- a/drivers/watchdog/sc1200wdt.c
+++ b/drivers/watchdog/sc1200wdt.c
@@ -38,8 +38,8 @@
38#include <linux/init.h> 38#include <linux/init.h>
39#include <linux/pnp.h> 39#include <linux/pnp.h>
40#include <linux/fs.h> 40#include <linux/fs.h>
41#include <linux/semaphore.h>
41 42
42#include <asm/semaphore.h>
43#include <asm/io.h> 43#include <asm/io.h>
44#include <asm/uaccess.h> 44#include <asm/uaccess.h>
45 45