aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2009-01-18 12:15:49 -0500
committerIngo Molnar <mingo@elte.hu>2009-01-18 12:15:49 -0500
commitaf37501c792107c2bde1524bdae38d9a247b841a (patch)
treeb50ee90d29e72956b8b7d8d19677fe5996755d49 /drivers
parentd859e29fe34cb833071b20aef860ee94fbad9bb2 (diff)
parent99937d6455cea95405ac681c86a857d0fcd530bd (diff)
Merge branch 'core/percpu' into perfcounters/core
Conflicts: arch/x86/include/asm/pda.h We merge tip/core/percpu into tip/perfcounters/core because of a semantic and contextual conflict: the former eliminates the PDA, while the latter extends it with apic_perf_irqs field. Resolve the conflict by moving the new field to the irq_cpustat structure on 64-bit too. Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ata/libata-sff.c9
-rw-r--r--drivers/ata/pata_it821x.c17
-rw-r--r--drivers/base/cpu.c2
-rw-r--r--drivers/base/topology.c33
-rw-r--r--drivers/block/amiflop.c40
-rw-r--r--drivers/char/amiserial.c36
-rw-r--r--drivers/char/pty.c4
-rw-r--r--drivers/char/ser_a2232.c12
-rw-r--r--drivers/char/vme_scc.c166
-rw-r--r--drivers/dio/dio-sysfs.c19
-rw-r--r--drivers/dio/dio.c18
-rw-r--r--drivers/firmware/dcdbas.c12
-rw-r--r--drivers/infiniband/hw/ehca/ehca_main.c2
-rw-r--r--drivers/infiniband/hw/mlx4/main.c13
-rw-r--r--drivers/infiniband/hw/nes/nes_cm.c12
-rw-r--r--drivers/infiniband/hw/nes/nes_utils.c4
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_main.c38
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_multicast.c3
-rw-r--r--drivers/infiniband/ulp/iser/Kconfig2
-rw-r--r--drivers/input/misc/Kconfig7
-rw-r--r--drivers/input/misc/Makefile1
-rw-r--r--drivers/input/misc/pcf50633-input.c132
-rw-r--r--drivers/isdn/hardware/mISDN/hfcmulti.c3
-rw-r--r--drivers/isdn/hardware/mISDN/hfcpci.c2
-rw-r--r--drivers/isdn/mISDN/dsp_cmx.c5
-rw-r--r--drivers/isdn/mISDN/dsp_pipeline.c4
-rw-r--r--drivers/mfd/Kconfig23
-rw-r--r--drivers/mfd/Makefile4
-rw-r--r--drivers/mfd/dm355evm_msp.c10
-rw-r--r--drivers/mfd/pcf50633-adc.c277
-rw-r--r--drivers/mfd/pcf50633-core.c710
-rw-r--r--drivers/mfd/pcf50633-gpio.c118
-rw-r--r--drivers/mfd/sm501.c30
-rw-r--r--drivers/mfd/twl4030-core.c11
-rw-r--r--drivers/misc/sgi-xp/xpc_main.c2
-rw-r--r--drivers/net/3c503.c1
-rw-r--r--drivers/net/3c59x.c2
-rw-r--r--drivers/net/8139cp.c2
-rw-r--r--drivers/net/8139too.c2
-rw-r--r--drivers/net/8390.c1
-rw-r--r--drivers/net/8390p.c1
-rw-r--r--drivers/net/Kconfig2
-rw-r--r--drivers/net/acenic.c1
-rw-r--r--drivers/net/arm/etherh.c1
-rw-r--r--drivers/net/arm/ks8695net.c1
-rw-r--r--drivers/net/b44.c13
-rw-r--r--drivers/net/cxgb3/adapter.h7
-rw-r--r--drivers/net/cxgb3/cxgb3_main.c22
-rw-r--r--drivers/net/cxgb3/sge.c2
-rw-r--r--drivers/net/e1000e/ich8lan.c19
-rw-r--r--drivers/net/e2100.c1
-rw-r--r--drivers/net/enic/enic_main.c1
-rw-r--r--drivers/net/forcedeth.c22
-rw-r--r--drivers/net/gianfar.c15
-rw-r--r--drivers/net/hamachi.c1
-rw-r--r--drivers/net/hamradio/6pack.c3
-rw-r--r--drivers/net/hp-plus.c1
-rw-r--r--drivers/net/hydra.c1
-rw-r--r--drivers/net/irda/au1k_ir.c2
-rw-r--r--drivers/net/irda/donauboe.c8
-rw-r--r--drivers/net/mac8390.c1
-rw-r--r--drivers/net/mlx4/en_netdev.c1
-rw-r--r--drivers/net/mlx4/main.c4
-rw-r--r--drivers/net/ne-h8300.c1
-rw-r--r--drivers/net/ne2k-pci.c1
-rw-r--r--drivers/net/ns83820.c1
-rw-r--r--drivers/net/qlge/qlge.h61
-rw-r--r--drivers/net/qlge/qlge_dbg.c62
-rw-r--r--drivers/net/qlge/qlge_main.c80
-rw-r--r--drivers/net/r6040.c43
-rw-r--r--drivers/net/sc92031.c1
-rw-r--r--drivers/net/sfc/efx.c17
-rw-r--r--drivers/net/sfc/tenxpress.c5
-rw-r--r--drivers/net/sis900.c1
-rw-r--r--drivers/net/smc-mca.c1
-rw-r--r--drivers/net/smc-ultra.c1
-rw-r--r--drivers/net/smsc911x.c4
-rw-r--r--drivers/net/smsc9420.c1
-rw-r--r--drivers/net/ucc_geth.c128
-rw-r--r--drivers/net/ucc_geth.h114
-rw-r--r--drivers/net/via-rhine.c1
-rw-r--r--drivers/net/via-velocity.c1
-rw-r--r--drivers/net/wd.c1
-rw-r--r--drivers/net/wireless/libertas/main.c7
-rw-r--r--drivers/net/yellowfin.c1
-rw-r--r--drivers/net/zorro8390.c1
-rw-r--r--drivers/oprofile/buffer_sync.c22
-rw-r--r--drivers/oprofile/buffer_sync.h4
-rw-r--r--drivers/oprofile/oprof.c9
-rw-r--r--drivers/parisc/superio.c1
-rw-r--r--drivers/pci/intel-iommu.c3
-rw-r--r--drivers/pci/intr_remapping.c1
-rw-r--r--drivers/power/Kconfig6
-rw-r--r--drivers/power/Makefile1
-rw-r--r--drivers/power/pcf50633-charger.c358
-rw-r--r--drivers/regulator/Kconfig7
-rw-r--r--drivers/regulator/Makefile1
-rw-r--r--drivers/regulator/pcf50633-regulator.c329
-rw-r--r--drivers/rtc/Kconfig7
-rw-r--r--drivers/rtc/Makefile1
-rw-r--r--drivers/rtc/rtc-pcf50633.c344
-rw-r--r--drivers/s390/net/qeth_l2_main.c2
-rw-r--r--drivers/s390/net/qeth_l3_main.c24
-rw-r--r--drivers/serial/8250.c2
-rw-r--r--drivers/serial/jsm/jsm_neo.c3
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c73
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.h8
-rw-r--r--drivers/usb/serial/usb-serial.c3
-rw-r--r--drivers/video/Makefile4
-rw-r--r--drivers/video/amifb.c6
-rw-r--r--drivers/video/atafb.c112
-rw-r--r--drivers/video/c2p.c232
-rw-r--r--drivers/video/c2p.h11
-rw-r--r--drivers/video/c2p_core.h153
-rw-r--r--drivers/video/c2p_iplan2.c153
-rw-r--r--drivers/video/c2p_planar.c156
-rw-r--r--drivers/video/console/fbcon.c38
-rw-r--r--drivers/watchdog/Kconfig14
-rw-r--r--drivers/watchdog/Makefile2
-rw-r--r--drivers/watchdog/gef_wdt.c330
-rw-r--r--drivers/watchdog/pika_wdt.c301
-rw-r--r--drivers/watchdog/wm8350_wdt.c6
-rw-r--r--drivers/xen/events.c26
-rw-r--r--drivers/xen/manage.c2
-rw-r--r--drivers/zorro/.gitignore2
-rw-r--r--drivers/zorro/zorro-sysfs.c20
-rw-r--r--drivers/zorro/zorro.c23
-rw-r--r--drivers/zorro/zorro.h2
128 files changed, 4342 insertions, 913 deletions
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index 0eae9b45355..5a4aad123c4 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -1013,9 +1013,12 @@ next_sg:
1013 qc->cursg_ofs = 0; 1013 qc->cursg_ofs = 0;
1014 } 1014 }
1015 1015
1016 /* consumed can be larger than count only for the last transfer */ 1016 /*
1017 WARN_ON_ONCE(qc->cursg && count != consumed); 1017 * There used to be a WARN_ON_ONCE(qc->cursg && count != consumed);
1018 1018 * Unfortunately __atapi_pio_bytes doesn't know enough to do the WARN
1019 * check correctly as it doesn't know if it is the last request being
1020 * made. Somebody should implement a proper sanity check.
1021 */
1019 if (bytes) 1022 if (bytes)
1020 goto next_sg; 1023 goto next_sg;
1021 return 0; 1024 return 0;
diff --git a/drivers/ata/pata_it821x.c b/drivers/ata/pata_it821x.c
index f828a29d775..f1bb2f9fecb 100644
--- a/drivers/ata/pata_it821x.c
+++ b/drivers/ata/pata_it821x.c
@@ -80,7 +80,7 @@
80 80
81 81
82#define DRV_NAME "pata_it821x" 82#define DRV_NAME "pata_it821x"
83#define DRV_VERSION "0.4.0" 83#define DRV_VERSION "0.4.2"
84 84
85struct it821x_dev 85struct it821x_dev
86{ 86{
@@ -494,8 +494,6 @@ static int it821x_smart_set_mode(struct ata_link *link, struct ata_device **unus
494 * special. In our case we need to lock the sector count to avoid 494 * special. In our case we need to lock the sector count to avoid
495 * blowing the brains out of the firmware with large LBA48 requests 495 * blowing the brains out of the firmware with large LBA48 requests
496 * 496 *
497 * FIXME: When FUA appears we need to block FUA too. And SMART and
498 * basically we need to filter commands for this chip.
499 */ 497 */
500 498
501static void it821x_dev_config(struct ata_device *adev) 499static void it821x_dev_config(struct ata_device *adev)
@@ -890,6 +888,13 @@ static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
890 .flags = ATA_FLAG_SLAVE_POSS, 888 .flags = ATA_FLAG_SLAVE_POSS,
891 .pio_mask = 0x1f, 889 .pio_mask = 0x1f,
892 .mwdma_mask = 0x07, 890 .mwdma_mask = 0x07,
891 .udma_mask = ATA_UDMA6,
892 .port_ops = &it821x_rdc_port_ops
893 };
894 static const struct ata_port_info info_rdc_11 = {
895 .flags = ATA_FLAG_SLAVE_POSS,
896 .pio_mask = 0x1f,
897 .mwdma_mask = 0x07,
893 /* No UDMA */ 898 /* No UDMA */
894 .port_ops = &it821x_rdc_port_ops 899 .port_ops = &it821x_rdc_port_ops
895 }; 900 };
@@ -903,7 +908,11 @@ static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
903 return rc; 908 return rc;
904 909
905 if (pdev->vendor == PCI_VENDOR_ID_RDC) { 910 if (pdev->vendor == PCI_VENDOR_ID_RDC) {
906 ppi[0] = &info_rdc; 911 /* Deal with Vortex86SX */
912 if (pdev->revision == 0x11)
913 ppi[0] = &info_rdc_11;
914 else
915 ppi[0] = &info_rdc;
907 } else { 916 } else {
908 /* Force the card into bypass mode if so requested */ 917 /* Force the card into bypass mode if so requested */
909 if (it8212_noraid) { 918 if (it8212_noraid) {
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 719ee5c1c8d..5b257a57bc5 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -107,7 +107,7 @@ static SYSDEV_ATTR(crash_notes, 0400, show_crash_notes, NULL);
107/* 107/*
108 * Print cpu online, possible, present, and system maps 108 * Print cpu online, possible, present, and system maps
109 */ 109 */
110static ssize_t print_cpus_map(char *buf, cpumask_t *map) 110static ssize_t print_cpus_map(char *buf, const struct cpumask *map)
111{ 111{
112 int n = cpulist_scnprintf(buf, PAGE_SIZE-2, map); 112 int n = cpulist_scnprintf(buf, PAGE_SIZE-2, map);
113 113
diff --git a/drivers/base/topology.c b/drivers/base/topology.c
index a778fb52b11..bf6b13206d0 100644
--- a/drivers/base/topology.c
+++ b/drivers/base/topology.c
@@ -31,7 +31,10 @@
31#include <linux/hardirq.h> 31#include <linux/hardirq.h>
32#include <linux/topology.h> 32#include <linux/topology.h>
33 33
34#define define_one_ro(_name) \ 34#define define_one_ro_named(_name, _func) \
35static SYSDEV_ATTR(_name, 0444, _func, NULL)
36
37#define define_one_ro(_name) \
35static SYSDEV_ATTR(_name, 0444, show_##_name, NULL) 38static SYSDEV_ATTR(_name, 0444, show_##_name, NULL)
36 39
37#define define_id_show_func(name) \ 40#define define_id_show_func(name) \
@@ -42,8 +45,8 @@ static ssize_t show_##name(struct sys_device *dev, \
42 return sprintf(buf, "%d\n", topology_##name(cpu)); \ 45 return sprintf(buf, "%d\n", topology_##name(cpu)); \
43} 46}
44 47
45#if defined(topology_thread_siblings) || defined(topology_core_siblings) 48#if defined(topology_thread_cpumask) || defined(topology_core_cpumask)
46static ssize_t show_cpumap(int type, cpumask_t *mask, char *buf) 49static ssize_t show_cpumap(int type, const struct cpumask *mask, char *buf)
47{ 50{
48 ptrdiff_t len = PTR_ALIGN(buf + PAGE_SIZE - 1, PAGE_SIZE) - buf; 51 ptrdiff_t len = PTR_ALIGN(buf + PAGE_SIZE - 1, PAGE_SIZE) - buf;
49 int n = 0; 52 int n = 0;
@@ -65,7 +68,7 @@ static ssize_t show_##name(struct sys_device *dev, \
65 struct sysdev_attribute *attr, char *buf) \ 68 struct sysdev_attribute *attr, char *buf) \
66{ \ 69{ \
67 unsigned int cpu = dev->id; \ 70 unsigned int cpu = dev->id; \
68 return show_cpumap(0, &(topology_##name(cpu)), buf); \ 71 return show_cpumap(0, topology_##name(cpu), buf); \
69} 72}
70 73
71#define define_siblings_show_list(name) \ 74#define define_siblings_show_list(name) \
@@ -74,7 +77,7 @@ static ssize_t show_##name##_list(struct sys_device *dev, \
74 char *buf) \ 77 char *buf) \
75{ \ 78{ \
76 unsigned int cpu = dev->id; \ 79 unsigned int cpu = dev->id; \
77 return show_cpumap(1, &(topology_##name(cpu)), buf); \ 80 return show_cpumap(1, topology_##name(cpu), buf); \
78} 81}
79 82
80#else 83#else
@@ -82,9 +85,7 @@ static ssize_t show_##name##_list(struct sys_device *dev, \
82static ssize_t show_##name(struct sys_device *dev, \ 85static ssize_t show_##name(struct sys_device *dev, \
83 struct sysdev_attribute *attr, char *buf) \ 86 struct sysdev_attribute *attr, char *buf) \
84{ \ 87{ \
85 unsigned int cpu = dev->id; \ 88 return show_cpumap(0, topology_##name(dev->id), buf); \
86 cpumask_t mask = topology_##name(cpu); \
87 return show_cpumap(0, &mask, buf); \
88} 89}
89 90
90#define define_siblings_show_list(name) \ 91#define define_siblings_show_list(name) \
@@ -92,9 +93,7 @@ static ssize_t show_##name##_list(struct sys_device *dev, \
92 struct sysdev_attribute *attr, \ 93 struct sysdev_attribute *attr, \
93 char *buf) \ 94 char *buf) \
94{ \ 95{ \
95 unsigned int cpu = dev->id; \ 96 return show_cpumap(1, topology_##name(dev->id), buf); \
96 cpumask_t mask = topology_##name(cpu); \
97 return show_cpumap(1, &mask, buf); \
98} 97}
99#endif 98#endif
100 99
@@ -107,13 +106,13 @@ define_one_ro(physical_package_id);
107define_id_show_func(core_id); 106define_id_show_func(core_id);
108define_one_ro(core_id); 107define_one_ro(core_id);
109 108
110define_siblings_show_func(thread_siblings); 109define_siblings_show_func(thread_cpumask);
111define_one_ro(thread_siblings); 110define_one_ro_named(thread_siblings, show_thread_cpumask);
112define_one_ro(thread_siblings_list); 111define_one_ro_named(thread_siblings_list, show_thread_cpumask_list);
113 112
114define_siblings_show_func(core_siblings); 113define_siblings_show_func(core_cpumask);
115define_one_ro(core_siblings); 114define_one_ro_named(core_siblings, show_core_cpumask);
116define_one_ro(core_siblings_list); 115define_one_ro_named(core_siblings_list, show_core_cpumask_list);
117 116
118static struct attribute *default_attrs[] = { 117static struct attribute *default_attrs[] = {
119 &attr_physical_package_id.attr, 118 &attr_physical_package_id.attr,
diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c
index 4b1d4ac960f..8df436ff706 100644
--- a/drivers/block/amiflop.c
+++ b/drivers/block/amiflop.c
@@ -156,7 +156,7 @@ static volatile int fdc_busy = -1;
156static volatile int fdc_nested; 156static volatile int fdc_nested;
157static DECLARE_WAIT_QUEUE_HEAD(fdc_wait); 157static DECLARE_WAIT_QUEUE_HEAD(fdc_wait);
158 158
159static DECLARE_WAIT_QUEUE_HEAD(motor_wait); 159static DECLARE_COMPLETION(motor_on_completion);
160 160
161static volatile int selected = -1; /* currently selected drive */ 161static volatile int selected = -1; /* currently selected drive */
162 162
@@ -184,8 +184,7 @@ static unsigned char mfmencode[16]={
184static unsigned char mfmdecode[128]; 184static unsigned char mfmdecode[128];
185 185
186/* floppy internal millisecond timer stuff */ 186/* floppy internal millisecond timer stuff */
187static volatile int ms_busy = -1; 187static DECLARE_COMPLETION(ms_wait_completion);
188static DECLARE_WAIT_QUEUE_HEAD(ms_wait);
189#define MS_TICKS ((amiga_eclock+50)/1000) 188#define MS_TICKS ((amiga_eclock+50)/1000)
190 189
191/* 190/*
@@ -211,8 +210,7 @@ static int fd_device[4] = { 0, 0, 0, 0 };
211 210
212static irqreturn_t ms_isr(int irq, void *dummy) 211static irqreturn_t ms_isr(int irq, void *dummy)
213{ 212{
214 ms_busy = -1; 213 complete(&ms_wait_completion);
215 wake_up(&ms_wait);
216 return IRQ_HANDLED; 214 return IRQ_HANDLED;
217} 215}
218 216
@@ -220,19 +218,17 @@ static irqreturn_t ms_isr(int irq, void *dummy)
220 A more generic routine would do a schedule a la timer.device */ 218 A more generic routine would do a schedule a la timer.device */
221static void ms_delay(int ms) 219static void ms_delay(int ms)
222{ 220{
223 unsigned long flags;
224 int ticks; 221 int ticks;
222 static DEFINE_MUTEX(mutex);
223
225 if (ms > 0) { 224 if (ms > 0) {
226 local_irq_save(flags); 225 mutex_lock(&mutex);
227 while (ms_busy == 0)
228 sleep_on(&ms_wait);
229 ms_busy = 0;
230 local_irq_restore(flags);
231 ticks = MS_TICKS*ms-1; 226 ticks = MS_TICKS*ms-1;
232 ciaa.tblo=ticks%256; 227 ciaa.tblo=ticks%256;
233 ciaa.tbhi=ticks/256; 228 ciaa.tbhi=ticks/256;
234 ciaa.crb=0x19; /*count eclock, force load, one-shoot, start */ 229 ciaa.crb=0x19; /*count eclock, force load, one-shoot, start */
235 sleep_on(&ms_wait); 230 wait_for_completion(&ms_wait_completion);
231 mutex_unlock(&mutex);
236 } 232 }
237} 233}
238 234
@@ -254,8 +250,7 @@ static void get_fdc(int drive)
254 printk("get_fdc: drive %d fdc_busy %d fdc_nested %d\n",drive,fdc_busy,fdc_nested); 250 printk("get_fdc: drive %d fdc_busy %d fdc_nested %d\n",drive,fdc_busy,fdc_nested);
255#endif 251#endif
256 local_irq_save(flags); 252 local_irq_save(flags);
257 while (!try_fdc(drive)) 253 wait_event(fdc_wait, try_fdc(drive));
258 sleep_on(&fdc_wait);
259 fdc_busy = drive; 254 fdc_busy = drive;
260 fdc_nested++; 255 fdc_nested++;
261 local_irq_restore(flags); 256 local_irq_restore(flags);
@@ -330,7 +325,7 @@ static void fd_deselect (int drive)
330static void motor_on_callback(unsigned long nr) 325static void motor_on_callback(unsigned long nr)
331{ 326{
332 if (!(ciaa.pra & DSKRDY) || --on_attempts == 0) { 327 if (!(ciaa.pra & DSKRDY) || --on_attempts == 0) {
333 wake_up (&motor_wait); 328 complete_all(&motor_on_completion);
334 } else { 329 } else {
335 motor_on_timer.expires = jiffies + HZ/10; 330 motor_on_timer.expires = jiffies + HZ/10;
336 add_timer(&motor_on_timer); 331 add_timer(&motor_on_timer);
@@ -347,11 +342,12 @@ static int fd_motor_on(int nr)
347 unit[nr].motor = 1; 342 unit[nr].motor = 1;
348 fd_select(nr); 343 fd_select(nr);
349 344
345 INIT_COMPLETION(motor_on_completion);
350 motor_on_timer.data = nr; 346 motor_on_timer.data = nr;
351 mod_timer(&motor_on_timer, jiffies + HZ/2); 347 mod_timer(&motor_on_timer, jiffies + HZ/2);
352 348
353 on_attempts = 10; 349 on_attempts = 10;
354 sleep_on (&motor_wait); 350 wait_for_completion(&motor_on_completion);
355 fd_deselect(nr); 351 fd_deselect(nr);
356 } 352 }
357 353
@@ -582,8 +578,7 @@ static void raw_read(int drive)
582{ 578{
583 drive&=3; 579 drive&=3;
584 get_fdc(drive); 580 get_fdc(drive);
585 while (block_flag) 581 wait_event(wait_fd_block, !block_flag);
586 sleep_on(&wait_fd_block);
587 fd_select(drive); 582 fd_select(drive);
588 /* setup adkcon bits correctly */ 583 /* setup adkcon bits correctly */
589 custom.adkcon = ADK_MSBSYNC; 584 custom.adkcon = ADK_MSBSYNC;
@@ -598,8 +593,7 @@ static void raw_read(int drive)
598 593
599 block_flag = 1; 594 block_flag = 1;
600 595
601 while (block_flag) 596 wait_event(wait_fd_block, !block_flag);
602 sleep_on (&wait_fd_block);
603 597
604 custom.dsklen = 0; 598 custom.dsklen = 0;
605 fd_deselect(drive); 599 fd_deselect(drive);
@@ -616,8 +610,7 @@ static int raw_write(int drive)
616 rel_fdc(); 610 rel_fdc();
617 return 0; 611 return 0;
618 } 612 }
619 while (block_flag) 613 wait_event(wait_fd_block, !block_flag);
620 sleep_on(&wait_fd_block);
621 fd_select(drive); 614 fd_select(drive);
622 /* clear adkcon bits */ 615 /* clear adkcon bits */
623 custom.adkcon = ADK_PRECOMP1|ADK_PRECOMP0|ADK_WORDSYNC|ADK_MSBSYNC; 616 custom.adkcon = ADK_PRECOMP1|ADK_PRECOMP0|ADK_WORDSYNC|ADK_MSBSYNC;
@@ -1294,8 +1287,7 @@ static int non_int_flush_track (unsigned long nr)
1294 writepending = 0; 1287 writepending = 0;
1295 return 0; 1288 return 0;
1296 } 1289 }
1297 while (block_flag == 2) 1290 wait_event(wait_fd_block, block_flag != 2);
1298 sleep_on (&wait_fd_block);
1299 } 1291 }
1300 else { 1292 else {
1301 local_irq_restore(flags); 1293 local_irq_restore(flags);
diff --git a/drivers/char/amiserial.c b/drivers/char/amiserial.c
index 4e0cfdeab14..a58869ea851 100644
--- a/drivers/char/amiserial.c
+++ b/drivers/char/amiserial.c
@@ -1963,6 +1963,7 @@ static int __init rs_init(void)
1963{ 1963{
1964 unsigned long flags; 1964 unsigned long flags;
1965 struct serial_state * state; 1965 struct serial_state * state;
1966 int error;
1966 1967
1967 if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(AMI_SERIAL)) 1968 if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(AMI_SERIAL))
1968 return -ENODEV; 1969 return -ENODEV;
@@ -1975,8 +1976,11 @@ static int __init rs_init(void)
1975 * We request SERDAT and SERPER only, because the serial registers are 1976 * We request SERDAT and SERPER only, because the serial registers are
1976 * too spreaded over the custom register space 1977 * too spreaded over the custom register space
1977 */ 1978 */
1978 if (!request_mem_region(CUSTOM_PHYSADDR+0x30, 4, "amiserial [Paula]")) 1979 if (!request_mem_region(CUSTOM_PHYSADDR+0x30, 4,
1979 return -EBUSY; 1980 "amiserial [Paula]")) {
1981 error = -EBUSY;
1982 goto fail_put_tty_driver;
1983 }
1980 1984
1981 IRQ_ports = NULL; 1985 IRQ_ports = NULL;
1982 1986
@@ -1997,8 +2001,9 @@ static int __init rs_init(void)
1997 serial_driver->flags = TTY_DRIVER_REAL_RAW; 2001 serial_driver->flags = TTY_DRIVER_REAL_RAW;
1998 tty_set_operations(serial_driver, &serial_ops); 2002 tty_set_operations(serial_driver, &serial_ops);
1999 2003
2000 if (tty_register_driver(serial_driver)) 2004 error = tty_register_driver(serial_driver);
2001 panic("Couldn't register serial driver\n"); 2005 if (error)
2006 goto fail_release_mem_region;
2002 2007
2003 state = rs_table; 2008 state = rs_table;
2004 state->magic = SSTATE_MAGIC; 2009 state->magic = SSTATE_MAGIC;
@@ -2024,8 +2029,14 @@ static int __init rs_init(void)
2024 local_irq_save(flags); 2029 local_irq_save(flags);
2025 2030
2026 /* set ISRs, and then disable the rx interrupts */ 2031 /* set ISRs, and then disable the rx interrupts */
2027 request_irq(IRQ_AMIGA_TBE, ser_tx_int, 0, "serial TX", state); 2032 error = request_irq(IRQ_AMIGA_TBE, ser_tx_int, 0, "serial TX", state);
2028 request_irq(IRQ_AMIGA_RBF, ser_rx_int, IRQF_DISABLED, "serial RX", state); 2033 if (error)
2034 goto fail_unregister;
2035
2036 error = request_irq(IRQ_AMIGA_RBF, ser_rx_int, IRQF_DISABLED,
2037 "serial RX", state);
2038 if (error)
2039 goto fail_free_irq;
2029 2040
2030 /* turn off Rx and Tx interrupts */ 2041 /* turn off Rx and Tx interrupts */
2031 custom.intena = IF_RBF | IF_TBE; 2042 custom.intena = IF_RBF | IF_TBE;
@@ -2045,6 +2056,16 @@ static int __init rs_init(void)
2045 ciab.ddra &= ~(SER_DCD | SER_CTS | SER_DSR); /* inputs */ 2056 ciab.ddra &= ~(SER_DCD | SER_CTS | SER_DSR); /* inputs */
2046 2057
2047 return 0; 2058 return 0;
2059
2060fail_free_irq:
2061 free_irq(IRQ_AMIGA_TBE, state);
2062fail_unregister:
2063 tty_unregister_driver(serial_driver);
2064fail_release_mem_region:
2065 release_mem_region(CUSTOM_PHYSADDR+0x30, 4);
2066fail_put_tty_driver:
2067 put_tty_driver(serial_driver);
2068 return error;
2048} 2069}
2049 2070
2050static __exit void rs_exit(void) 2071static __exit void rs_exit(void)
@@ -2064,6 +2085,9 @@ static __exit void rs_exit(void)
2064 kfree(info); 2085 kfree(info);
2065 } 2086 }
2066 2087
2088 free_irq(IRQ_AMIGA_TBE, rs_table);
2089 free_irq(IRQ_AMIGA_RBF, rs_table);
2090
2067 release_mem_region(CUSTOM_PHYSADDR+0x30, 4); 2091 release_mem_region(CUSTOM_PHYSADDR+0x30, 4);
2068} 2092}
2069 2093
diff --git a/drivers/char/pty.c b/drivers/char/pty.c
index 146c97613da..31038a0052a 100644
--- a/drivers/char/pty.c
+++ b/drivers/char/pty.c
@@ -230,9 +230,7 @@ static void pty_set_termios(struct tty_struct *tty,
230/** 230/**
231 * pty_do_resize - resize event 231 * pty_do_resize - resize event
232 * @tty: tty being resized 232 * @tty: tty being resized
233 * @real_tty: real tty (not the same as tty if using a pty/tty pair) 233 * @ws: window size being set.
234 * @rows: rows (character)
235 * @cols: cols (character)
236 * 234 *
237 * Update the termios variables and send the neccessary signals to 235 * Update the termios variables and send the neccessary signals to
238 * peform a terminal resize correctly 236 * peform a terminal resize correctly
diff --git a/drivers/char/ser_a2232.c b/drivers/char/ser_a2232.c
index 33872a219df..33a2b531802 100644
--- a/drivers/char/ser_a2232.c
+++ b/drivers/char/ser_a2232.c
@@ -718,6 +718,7 @@ static int __init a2232board_init(void)
718 u_char *from; 718 u_char *from;
719 volatile u_char *to; 719 volatile u_char *to;
720 volatile struct a2232memory *mem; 720 volatile struct a2232memory *mem;
721 int error, i;
721 722
722#ifdef CONFIG_SMP 723#ifdef CONFIG_SMP
723 return -ENODEV; /* This driver is not SMP aware. Is there an SMP ZorroII-bus-machine? */ 724 return -ENODEV; /* This driver is not SMP aware. Is there an SMP ZorroII-bus-machine? */
@@ -797,8 +798,15 @@ static int __init a2232board_init(void)
797 */ 798 */
798 if (a2232_init_drivers()) return -ENODEV; // maybe we should use a different -Exxx? 799 if (a2232_init_drivers()) return -ENODEV; // maybe we should use a different -Exxx?
799 800
800 request_irq(IRQ_AMIGA_VERTB, a2232_vbl_inter, 0, "A2232 serial VBL", a2232_driver_ID); 801 error = request_irq(IRQ_AMIGA_VERTB, a2232_vbl_inter, 0,
801 return 0; 802 "A2232 serial VBL", a2232_driver_ID);
803 if (error) {
804 for (i = 0; i < nr_a2232; i++)
805 zorro_release_device(zd_a2232[i]);
806 tty_unregister_driver(a2232_driver);
807 put_tty_driver(a2232_driver);
808 }
809 return error;
802} 810}
803 811
804static void __exit a2232board_exit(void) 812static void __exit a2232board_exit(void)
diff --git a/drivers/char/vme_scc.c b/drivers/char/vme_scc.c
index 0e8234bd0e1..994e1a58b98 100644
--- a/drivers/char/vme_scc.c
+++ b/drivers/char/vme_scc.c
@@ -198,6 +198,7 @@ static void scc_init_portstructs(void)
198static int mvme147_scc_init(void) 198static int mvme147_scc_init(void)
199{ 199{
200 struct scc_port *port; 200 struct scc_port *port;
201 int error;
201 202
202 printk(KERN_INFO "SCC: MVME147 Serial Driver\n"); 203 printk(KERN_INFO "SCC: MVME147 Serial Driver\n");
203 /* Init channel A */ 204 /* Init channel A */
@@ -207,14 +208,23 @@ static int mvme147_scc_init(void)
207 port->datap = port->ctrlp + 1; 208 port->datap = port->ctrlp + 1;
208 port->port_a = &scc_ports[0]; 209 port->port_a = &scc_ports[0];
209 port->port_b = &scc_ports[1]; 210 port->port_b = &scc_ports[1];
210 request_irq(MVME147_IRQ_SCCA_TX, scc_tx_int, IRQF_DISABLED, 211 error = request_irq(MVME147_IRQ_SCCA_TX, scc_tx_int, IRQF_DISABLED,
211 "SCC-A TX", port); 212 "SCC-A TX", port);
212 request_irq(MVME147_IRQ_SCCA_STAT, scc_stat_int, IRQF_DISABLED, 213 if (error)
214 goto fail;
215 error = request_irq(MVME147_IRQ_SCCA_STAT, scc_stat_int, IRQF_DISABLED,
213 "SCC-A status", port); 216 "SCC-A status", port);
214 request_irq(MVME147_IRQ_SCCA_RX, scc_rx_int, IRQF_DISABLED, 217 if (error)
218 goto fail_free_a_tx;
219 error = request_irq(MVME147_IRQ_SCCA_RX, scc_rx_int, IRQF_DISABLED,
215 "SCC-A RX", port); 220 "SCC-A RX", port);
216 request_irq(MVME147_IRQ_SCCA_SPCOND, scc_spcond_int, IRQF_DISABLED, 221 if (error)
217 "SCC-A special cond", port); 222 goto fail_free_a_stat;
223 error = request_irq(MVME147_IRQ_SCCA_SPCOND, scc_spcond_int,
224 IRQF_DISABLED, "SCC-A special cond", port);
225 if (error)
226 goto fail_free_a_rx;
227
218 { 228 {
219 SCC_ACCESS_INIT(port); 229 SCC_ACCESS_INIT(port);
220 230
@@ -234,14 +244,23 @@ static int mvme147_scc_init(void)
234 port->datap = port->ctrlp + 1; 244 port->datap = port->ctrlp + 1;
235 port->port_a = &scc_ports[0]; 245 port->port_a = &scc_ports[0];
236 port->port_b = &scc_ports[1]; 246 port->port_b = &scc_ports[1];
237 request_irq(MVME147_IRQ_SCCB_TX, scc_tx_int, IRQF_DISABLED, 247 error = request_irq(MVME147_IRQ_SCCB_TX, scc_tx_int, IRQF_DISABLED,
238 "SCC-B TX", port); 248 "SCC-B TX", port);
239 request_irq(MVME147_IRQ_SCCB_STAT, scc_stat_int, IRQF_DISABLED, 249 if (error)
250 goto fail_free_a_spcond;
251 error = request_irq(MVME147_IRQ_SCCB_STAT, scc_stat_int, IRQF_DISABLED,
240 "SCC-B status", port); 252 "SCC-B status", port);
241 request_irq(MVME147_IRQ_SCCB_RX, scc_rx_int, IRQF_DISABLED, 253 if (error)
254 goto fail_free_b_tx;
255 error = request_irq(MVME147_IRQ_SCCB_RX, scc_rx_int, IRQF_DISABLED,
242 "SCC-B RX", port); 256 "SCC-B RX", port);
243 request_irq(MVME147_IRQ_SCCB_SPCOND, scc_spcond_int, IRQF_DISABLED, 257 if (error)
244 "SCC-B special cond", port); 258 goto fail_free_b_stat;
259 error = request_irq(MVME147_IRQ_SCCB_SPCOND, scc_spcond_int,
260 IRQF_DISABLED, "SCC-B special cond", port);
261 if (error)
262 goto fail_free_b_rx;
263
245 { 264 {
246 SCC_ACCESS_INIT(port); 265 SCC_ACCESS_INIT(port);
247 266
@@ -257,6 +276,23 @@ static int mvme147_scc_init(void)
257 scc_init_drivers(); 276 scc_init_drivers();
258 277
259 return 0; 278 return 0;
279
280fail_free_b_rx:
281 free_irq(MVME147_IRQ_SCCB_RX, port);
282fail_free_b_stat:
283 free_irq(MVME147_IRQ_SCCB_STAT, port);
284fail_free_b_tx:
285 free_irq(MVME147_IRQ_SCCB_TX, port);
286fail_free_a_spcond:
287 free_irq(MVME147_IRQ_SCCA_SPCOND, port);
288fail_free_a_rx:
289 free_irq(MVME147_IRQ_SCCA_RX, port);
290fail_free_a_stat:
291 free_irq(MVME147_IRQ_SCCA_STAT, port);
292fail_free_a_tx:
293 free_irq(MVME147_IRQ_SCCA_TX, port);
294fail:
295 return error;
260} 296}
261#endif 297#endif
262 298
@@ -265,6 +301,7 @@ static int mvme147_scc_init(void)
265static int mvme162_scc_init(void) 301static int mvme162_scc_init(void)
266{ 302{
267 struct scc_port *port; 303 struct scc_port *port;
304 int error;
268 305
269 if (!(mvme16x_config & MVME16x_CONFIG_GOT_SCCA)) 306 if (!(mvme16x_config & MVME16x_CONFIG_GOT_SCCA))
270 return (-ENODEV); 307 return (-ENODEV);
@@ -277,14 +314,23 @@ static int mvme162_scc_init(void)
277 port->datap = port->ctrlp + 2; 314 port->datap = port->ctrlp + 2;
278 port->port_a = &scc_ports[0]; 315 port->port_a = &scc_ports[0];
279 port->port_b = &scc_ports[1]; 316 port->port_b = &scc_ports[1];
280 request_irq(MVME162_IRQ_SCCA_TX, scc_tx_int, IRQF_DISABLED, 317 error = request_irq(MVME162_IRQ_SCCA_TX, scc_tx_int, IRQF_DISABLED,
281 "SCC-A TX", port); 318 "SCC-A TX", port);
282 request_irq(MVME162_IRQ_SCCA_STAT, scc_stat_int, IRQF_DISABLED, 319 if (error)
320 goto fail;
321 error = request_irq(MVME162_IRQ_SCCA_STAT, scc_stat_int, IRQF_DISABLED,
283 "SCC-A status", port); 322 "SCC-A status", port);
284 request_irq(MVME162_IRQ_SCCA_RX, scc_rx_int, IRQF_DISABLED, 323 if (error)
324 goto fail_free_a_tx;
325 error = request_irq(MVME162_IRQ_SCCA_RX, scc_rx_int, IRQF_DISABLED,
285 "SCC-A RX", port); 326 "SCC-A RX", port);
286 request_irq(MVME162_IRQ_SCCA_SPCOND, scc_spcond_int, IRQF_DISABLED, 327 if (error)
287 "SCC-A special cond", port); 328 goto fail_free_a_stat;
329 error = request_irq(MVME162_IRQ_SCCA_SPCOND, scc_spcond_int,
330 IRQF_DISABLED, "SCC-A special cond", port);
331 if (error)
332 goto fail_free_a_rx;
333
288 { 334 {
289 SCC_ACCESS_INIT(port); 335 SCC_ACCESS_INIT(port);
290 336
@@ -304,14 +350,22 @@ static int mvme162_scc_init(void)
304 port->datap = port->ctrlp + 2; 350 port->datap = port->ctrlp + 2;
305 port->port_a = &scc_ports[0]; 351 port->port_a = &scc_ports[0];
306 port->port_b = &scc_ports[1]; 352 port->port_b = &scc_ports[1];
307 request_irq(MVME162_IRQ_SCCB_TX, scc_tx_int, IRQF_DISABLED, 353 error = request_irq(MVME162_IRQ_SCCB_TX, scc_tx_int, IRQF_DISABLED,
308 "SCC-B TX", port); 354 "SCC-B TX", port);
309 request_irq(MVME162_IRQ_SCCB_STAT, scc_stat_int, IRQF_DISABLED, 355 if (error)
356 goto fail_free_a_spcond;
357 error = request_irq(MVME162_IRQ_SCCB_STAT, scc_stat_int, IRQF_DISABLED,
310 "SCC-B status", port); 358 "SCC-B status", port);
311 request_irq(MVME162_IRQ_SCCB_RX, scc_rx_int, IRQF_DISABLED, 359 if (error)
360 goto fail_free_b_tx;
361 error = request_irq(MVME162_IRQ_SCCB_RX, scc_rx_int, IRQF_DISABLED,
312 "SCC-B RX", port); 362 "SCC-B RX", port);
313 request_irq(MVME162_IRQ_SCCB_SPCOND, scc_spcond_int, IRQF_DISABLED, 363 if (error)
314 "SCC-B special cond", port); 364 goto fail_free_b_stat;
365 error = request_irq(MVME162_IRQ_SCCB_SPCOND, scc_spcond_int,
366 IRQF_DISABLED, "SCC-B special cond", port);
367 if (error)
368 goto fail_free_b_rx;
315 369
316 { 370 {
317 SCC_ACCESS_INIT(port); /* Either channel will do */ 371 SCC_ACCESS_INIT(port); /* Either channel will do */
@@ -328,6 +382,23 @@ static int mvme162_scc_init(void)
328 scc_init_drivers(); 382 scc_init_drivers();
329 383
330 return 0; 384 return 0;
385
386fail_free_b_rx:
387 free_irq(MVME162_IRQ_SCCB_RX, port);
388fail_free_b_stat:
389 free_irq(MVME162_IRQ_SCCB_STAT, port);
390fail_free_b_tx:
391 free_irq(MVME162_IRQ_SCCB_TX, port);
392fail_free_a_spcond:
393 free_irq(MVME162_IRQ_SCCA_SPCOND, port);
394fail_free_a_rx:
395 free_irq(MVME162_IRQ_SCCA_RX, port);
396fail_free_a_stat:
397 free_irq(MVME162_IRQ_SCCA_STAT, port);
398fail_free_a_tx:
399 free_irq(MVME162_IRQ_SCCA_TX, port);
400fail:
401 return error;
331} 402}
332#endif 403#endif
333 404
@@ -336,6 +407,7 @@ static int mvme162_scc_init(void)
336static int bvme6000_scc_init(void) 407static int bvme6000_scc_init(void)
337{ 408{
338 struct scc_port *port; 409 struct scc_port *port;
410 int error;
339 411
340 printk(KERN_INFO "SCC: BVME6000 Serial Driver\n"); 412 printk(KERN_INFO "SCC: BVME6000 Serial Driver\n");
341 /* Init channel A */ 413 /* Init channel A */
@@ -345,14 +417,23 @@ static int bvme6000_scc_init(void)
345 port->datap = port->ctrlp + 4; 417 port->datap = port->ctrlp + 4;
346 port->port_a = &scc_ports[0]; 418 port->port_a = &scc_ports[0];
347 port->port_b = &scc_ports[1]; 419 port->port_b = &scc_ports[1];
348 request_irq(BVME_IRQ_SCCA_TX, scc_tx_int, IRQF_DISABLED, 420 error = request_irq(BVME_IRQ_SCCA_TX, scc_tx_int, IRQF_DISABLED,
349 "SCC-A TX", port); 421 "SCC-A TX", port);
350 request_irq(BVME_IRQ_SCCA_STAT, scc_stat_int, IRQF_DISABLED, 422 if (error)
423 goto fail;
424 error = request_irq(BVME_IRQ_SCCA_STAT, scc_stat_int, IRQF_DISABLED,
351 "SCC-A status", port); 425 "SCC-A status", port);
352 request_irq(BVME_IRQ_SCCA_RX, scc_rx_int, IRQF_DISABLED, 426 if (error)
427 goto fail_free_a_tx;
428 error = request_irq(BVME_IRQ_SCCA_RX, scc_rx_int, IRQF_DISABLED,
353 "SCC-A RX", port); 429 "SCC-A RX", port);
354 request_irq(BVME_IRQ_SCCA_SPCOND, scc_spcond_int, IRQF_DISABLED, 430 if (error)
355 "SCC-A special cond", port); 431 goto fail_free_a_stat;
432 error = request_irq(BVME_IRQ_SCCA_SPCOND, scc_spcond_int,
433 IRQF_DISABLED, "SCC-A special cond", port);
434 if (error)
435 goto fail_free_a_rx;
436
356 { 437 {
357 SCC_ACCESS_INIT(port); 438 SCC_ACCESS_INIT(port);
358 439
@@ -372,14 +453,22 @@ static int bvme6000_scc_init(void)
372 port->datap = port->ctrlp + 4; 453 port->datap = port->ctrlp + 4;
373 port->port_a = &scc_ports[0]; 454 port->port_a = &scc_ports[0];
374 port->port_b = &scc_ports[1]; 455 port->port_b = &scc_ports[1];
375 request_irq(BVME_IRQ_SCCB_TX, scc_tx_int, IRQF_DISABLED, 456 error = request_irq(BVME_IRQ_SCCB_TX, scc_tx_int, IRQF_DISABLED,
376 "SCC-B TX", port); 457 "SCC-B TX", port);
377 request_irq(BVME_IRQ_SCCB_STAT, scc_stat_int, IRQF_DISABLED, 458 if (error)
459 goto fail_free_a_spcond;
460 error = request_irq(BVME_IRQ_SCCB_STAT, scc_stat_int, IRQF_DISABLED,
378 "SCC-B status", port); 461 "SCC-B status", port);
379 request_irq(BVME_IRQ_SCCB_RX, scc_rx_int, IRQF_DISABLED, 462 if (error)
463 goto fail_free_b_tx;
464 error = request_irq(BVME_IRQ_SCCB_RX, scc_rx_int, IRQF_DISABLED,
380 "SCC-B RX", port); 465 "SCC-B RX", port);
381 request_irq(BVME_IRQ_SCCB_SPCOND, scc_spcond_int, IRQF_DISABLED, 466 if (error)
382 "SCC-B special cond", port); 467 goto fail_free_b_stat;
468 error = request_irq(BVME_IRQ_SCCB_SPCOND, scc_spcond_int,
469 IRQF_DISABLED, "SCC-B special cond", port);
470 if (error)
471 goto fail_free_b_rx;
383 472
384 { 473 {
385 SCC_ACCESS_INIT(port); /* Either channel will do */ 474 SCC_ACCESS_INIT(port); /* Either channel will do */
@@ -393,6 +482,23 @@ static int bvme6000_scc_init(void)
393 scc_init_drivers(); 482 scc_init_drivers();
394 483
395 return 0; 484 return 0;
485
486fail:
487 free_irq(BVME_IRQ_SCCA_STAT, port);
488fail_free_a_tx:
489 free_irq(BVME_IRQ_SCCA_RX, port);
490fail_free_a_stat:
491 free_irq(BVME_IRQ_SCCA_SPCOND, port);
492fail_free_a_rx:
493 free_irq(BVME_IRQ_SCCB_TX, port);
494fail_free_a_spcond:
495 free_irq(BVME_IRQ_SCCB_STAT, port);
496fail_free_b_tx:
497 free_irq(BVME_IRQ_SCCB_RX, port);
498fail_free_b_stat:
499 free_irq(BVME_IRQ_SCCB_SPCOND, port);
500fail_free_b_rx:
501 return error;
396} 502}
397#endif 503#endif
398 504
diff --git a/drivers/dio/dio-sysfs.c b/drivers/dio/dio-sysfs.c
index f4646303884..ee1a3b59bd4 100644
--- a/drivers/dio/dio-sysfs.c
+++ b/drivers/dio/dio-sysfs.c
@@ -58,20 +58,25 @@ static ssize_t dio_show_resource(struct device *dev, struct device_attribute *at
58 struct dio_dev *d = to_dio_dev(dev); 58 struct dio_dev *d = to_dio_dev(dev);
59 59
60 return sprintf(buf, "0x%08lx 0x%08lx 0x%08lx\n", 60 return sprintf(buf, "0x%08lx 0x%08lx 0x%08lx\n",
61 dio_resource_start(d), dio_resource_end(d), 61 (unsigned long)dio_resource_start(d),
62 (unsigned long)dio_resource_end(d),
62 dio_resource_flags(d)); 63 dio_resource_flags(d));
63} 64}
64static DEVICE_ATTR(resource, S_IRUGO, dio_show_resource, NULL); 65static DEVICE_ATTR(resource, S_IRUGO, dio_show_resource, NULL);
65 66
66void dio_create_sysfs_dev_files(struct dio_dev *d) 67int dio_create_sysfs_dev_files(struct dio_dev *d)
67{ 68{
68 struct device *dev = &d->dev; 69 struct device *dev = &d->dev;
70 int error;
69 71
70 /* current configuration's attributes */ 72 /* current configuration's attributes */
71 device_create_file(dev, &dev_attr_id); 73 if ((error = device_create_file(dev, &dev_attr_id)) ||
72 device_create_file(dev, &dev_attr_ipl); 74 (error = device_create_file(dev, &dev_attr_ipl)) ||
73 device_create_file(dev, &dev_attr_secid); 75 (error = device_create_file(dev, &dev_attr_secid)) ||
74 device_create_file(dev, &dev_attr_name); 76 (error = device_create_file(dev, &dev_attr_name)) ||
75 device_create_file(dev, &dev_attr_resource); 77 (error = device_create_file(dev, &dev_attr_resource)))
78 return error;
79
80 return 0;
76} 81}
77 82
diff --git a/drivers/dio/dio.c b/drivers/dio/dio.c
index 07f274f853d..10c3c498358 100644
--- a/drivers/dio/dio.c
+++ b/drivers/dio/dio.c
@@ -173,6 +173,7 @@ static int __init dio_init(void)
173 mm_segment_t fs; 173 mm_segment_t fs;
174 int i; 174 int i;
175 struct dio_dev *dev; 175 struct dio_dev *dev;
176 int error;
176 177
177 if (!MACH_IS_HP300) 178 if (!MACH_IS_HP300)
178 return 0; 179 return 0;
@@ -182,7 +183,11 @@ static int __init dio_init(void)
182 /* Initialize the DIO bus */ 183 /* Initialize the DIO bus */
183 INIT_LIST_HEAD(&dio_bus.devices); 184 INIT_LIST_HEAD(&dio_bus.devices);
184 strcpy(dio_bus.dev.bus_id, "dio"); 185 strcpy(dio_bus.dev.bus_id, "dio");
185 device_register(&dio_bus.dev); 186 error = device_register(&dio_bus.dev);
187 if (error) {
188 pr_err("DIO: Error registering dio_bus\n");
189 return error;
190 }
186 191
187 /* Request all resources */ 192 /* Request all resources */
188 dio_bus.num_resources = (hp300_model == HP_320 ? 1 : 2); 193 dio_bus.num_resources = (hp300_model == HP_320 ? 1 : 2);
@@ -252,8 +257,15 @@ static int __init dio_init(void)
252 257
253 if (scode >= DIOII_SCBASE) 258 if (scode >= DIOII_SCBASE)
254 iounmap(va); 259 iounmap(va);
255 device_register(&dev->dev); 260 error = device_register(&dev->dev);
256 dio_create_sysfs_dev_files(dev); 261 if (error) {
262 pr_err("DIO: Error registering device %s\n",
263 dev->name);
264 continue;
265 }
266 error = dio_create_sysfs_dev_files(dev);
267 if (error)
268 dev_err(&dev->dev, "Error creating sysfs files\n");
257 } 269 }
258 return 0; 270 return 0;
259} 271}
diff --git a/drivers/firmware/dcdbas.c b/drivers/firmware/dcdbas.c
index 777fba48d2d..3009e0171e5 100644
--- a/drivers/firmware/dcdbas.c
+++ b/drivers/firmware/dcdbas.c
@@ -244,7 +244,7 @@ static ssize_t host_control_on_shutdown_store(struct device *dev,
244 */ 244 */
245int dcdbas_smi_request(struct smi_cmd *smi_cmd) 245int dcdbas_smi_request(struct smi_cmd *smi_cmd)
246{ 246{
247 cpumask_t old_mask; 247 cpumask_var_t old_mask;
248 int ret = 0; 248 int ret = 0;
249 249
250 if (smi_cmd->magic != SMI_CMD_MAGIC) { 250 if (smi_cmd->magic != SMI_CMD_MAGIC) {
@@ -254,8 +254,11 @@ int dcdbas_smi_request(struct smi_cmd *smi_cmd)
254 } 254 }
255 255
256 /* SMI requires CPU 0 */ 256 /* SMI requires CPU 0 */
257 old_mask = current->cpus_allowed; 257 if (!alloc_cpumask_var(&old_mask, GFP_KERNEL))
258 set_cpus_allowed_ptr(current, &cpumask_of_cpu(0)); 258 return -ENOMEM;
259
260 cpumask_copy(old_mask, &current->cpus_allowed);
261 set_cpus_allowed_ptr(current, cpumask_of(0));
259 if (smp_processor_id() != 0) { 262 if (smp_processor_id() != 0) {
260 dev_dbg(&dcdbas_pdev->dev, "%s: failed to get CPU 0\n", 263 dev_dbg(&dcdbas_pdev->dev, "%s: failed to get CPU 0\n",
261 __func__); 264 __func__);
@@ -275,7 +278,8 @@ int dcdbas_smi_request(struct smi_cmd *smi_cmd)
275 ); 278 );
276 279
277out: 280out:
278 set_cpus_allowed_ptr(current, &old_mask); 281 set_cpus_allowed_ptr(current, old_mask);
282 free_cpumask_var(old_mask);
279 return ret; 283 return ret;
280} 284}
281 285
diff --git a/drivers/infiniband/hw/ehca/ehca_main.c b/drivers/infiniband/hw/ehca/ehca_main.c
index 3b77b674cbf..c7b8a506af6 100644
--- a/drivers/infiniband/hw/ehca/ehca_main.c
+++ b/drivers/infiniband/hw/ehca/ehca_main.c
@@ -955,7 +955,7 @@ void ehca_poll_eqs(unsigned long data)
955 struct ehca_eq *eq = &shca->eq; 955 struct ehca_eq *eq = &shca->eq;
956 int max = 3; 956 int max = 3;
957 volatile u64 q_ofs, q_ofs2; 957 volatile u64 q_ofs, q_ofs2;
958 u64 flags; 958 unsigned long flags;
959 spin_lock_irqsave(&eq->spinlock, flags); 959 spin_lock_irqsave(&eq->spinlock, flags);
960 q_ofs = eq->ipz_queue.current_q_offset; 960 q_ofs = eq->ipz_queue.current_q_offset;
961 spin_unlock_irqrestore(&eq->spinlock, flags); 961 spin_unlock_irqrestore(&eq->spinlock, flags);
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index dcefe1fceb5..61588bd273b 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -543,14 +543,21 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
543{ 543{
544 static int mlx4_ib_version_printed; 544 static int mlx4_ib_version_printed;
545 struct mlx4_ib_dev *ibdev; 545 struct mlx4_ib_dev *ibdev;
546 int num_ports = 0;
546 int i; 547 int i;
547 548
548
549 if (!mlx4_ib_version_printed) { 549 if (!mlx4_ib_version_printed) {
550 printk(KERN_INFO "%s", mlx4_ib_version); 550 printk(KERN_INFO "%s", mlx4_ib_version);
551 ++mlx4_ib_version_printed; 551 ++mlx4_ib_version_printed;
552 } 552 }
553 553
554 mlx4_foreach_port(i, dev, MLX4_PORT_TYPE_IB)
555 num_ports++;
556
557 /* No point in registering a device with no ports... */
558 if (num_ports == 0)
559 return NULL;
560
554 ibdev = (struct mlx4_ib_dev *) ib_alloc_device(sizeof *ibdev); 561 ibdev = (struct mlx4_ib_dev *) ib_alloc_device(sizeof *ibdev);
555 if (!ibdev) { 562 if (!ibdev) {
556 dev_err(&dev->pdev->dev, "Device struct alloc failed\n"); 563 dev_err(&dev->pdev->dev, "Device struct alloc failed\n");
@@ -574,9 +581,7 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
574 ibdev->ib_dev.owner = THIS_MODULE; 581 ibdev->ib_dev.owner = THIS_MODULE;
575 ibdev->ib_dev.node_type = RDMA_NODE_IB_CA; 582 ibdev->ib_dev.node_type = RDMA_NODE_IB_CA;
576 ibdev->ib_dev.local_dma_lkey = dev->caps.reserved_lkey; 583 ibdev->ib_dev.local_dma_lkey = dev->caps.reserved_lkey;
577 ibdev->num_ports = 0; 584 ibdev->num_ports = num_ports;
578 mlx4_foreach_port(i, dev, MLX4_PORT_TYPE_IB)
579 ibdev->num_ports++;
580 ibdev->ib_dev.phys_port_cnt = ibdev->num_ports; 585 ibdev->ib_dev.phys_port_cnt = ibdev->num_ports;
581 ibdev->ib_dev.num_comp_vectors = dev->caps.num_comp_vectors; 586 ibdev->ib_dev.num_comp_vectors = dev->caps.num_comp_vectors;
582 ibdev->ib_dev.dma_device = &dev->pdev->dev; 587 ibdev->ib_dev.dma_device = &dev->pdev->dev;
diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
index 6ba57e91d7a..a01b4488208 100644
--- a/drivers/infiniband/hw/nes/nes_cm.c
+++ b/drivers/infiniband/hw/nes/nes_cm.c
@@ -778,12 +778,13 @@ static struct nes_cm_node *find_node(struct nes_cm_core *cm_core,
778 unsigned long flags; 778 unsigned long flags;
779 struct list_head *hte; 779 struct list_head *hte;
780 struct nes_cm_node *cm_node; 780 struct nes_cm_node *cm_node;
781 __be32 tmp_addr = cpu_to_be32(loc_addr);
781 782
782 /* get a handle on the hte */ 783 /* get a handle on the hte */
783 hte = &cm_core->connected_nodes; 784 hte = &cm_core->connected_nodes;
784 785
785 nes_debug(NES_DBG_CM, "Searching for an owner node: %pI4:%x from core %p->%p\n", 786 nes_debug(NES_DBG_CM, "Searching for an owner node: %pI4:%x from core %p->%p\n",
786 &loc_addr, loc_port, cm_core, hte); 787 &tmp_addr, loc_port, cm_core, hte);
787 788
788 /* walk list and find cm_node associated with this session ID */ 789 /* walk list and find cm_node associated with this session ID */
789 spin_lock_irqsave(&cm_core->ht_lock, flags); 790 spin_lock_irqsave(&cm_core->ht_lock, flags);
@@ -816,6 +817,7 @@ static struct nes_cm_listener *find_listener(struct nes_cm_core *cm_core,
816{ 817{
817 unsigned long flags; 818 unsigned long flags;
818 struct nes_cm_listener *listen_node; 819 struct nes_cm_listener *listen_node;
820 __be32 tmp_addr = cpu_to_be32(dst_addr);
819 821
820 /* walk list and find cm_node associated with this session ID */ 822 /* walk list and find cm_node associated with this session ID */
821 spin_lock_irqsave(&cm_core->listen_list_lock, flags); 823 spin_lock_irqsave(&cm_core->listen_list_lock, flags);
@@ -833,7 +835,7 @@ static struct nes_cm_listener *find_listener(struct nes_cm_core *cm_core,
833 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags); 835 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
834 836
835 nes_debug(NES_DBG_CM, "Unable to find listener for %pI4:%x\n", 837 nes_debug(NES_DBG_CM, "Unable to find listener for %pI4:%x\n",
836 &dst_addr, dst_port); 838 &tmp_addr, dst_port);
837 839
838 /* no listener */ 840 /* no listener */
839 return NULL; 841 return NULL;
@@ -2059,6 +2061,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
2059 struct tcphdr *tcph; 2061 struct tcphdr *tcph;
2060 struct nes_cm_info nfo; 2062 struct nes_cm_info nfo;
2061 int skb_handled = 1; 2063 int skb_handled = 1;
2064 __be32 tmp_daddr, tmp_saddr;
2062 2065
2063 if (!skb) 2066 if (!skb)
2064 return 0; 2067 return 0;
@@ -2074,8 +2077,11 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
2074 nfo.rem_addr = ntohl(iph->saddr); 2077 nfo.rem_addr = ntohl(iph->saddr);
2075 nfo.rem_port = ntohs(tcph->source); 2078 nfo.rem_port = ntohs(tcph->source);
2076 2079
2080 tmp_daddr = cpu_to_be32(iph->daddr);
2081 tmp_saddr = cpu_to_be32(iph->saddr);
2082
2077 nes_debug(NES_DBG_CM, "Received packet: dest=%pI4:0x%04X src=%pI4:0x%04X\n", 2083 nes_debug(NES_DBG_CM, "Received packet: dest=%pI4:0x%04X src=%pI4:0x%04X\n",
2078 &iph->daddr, tcph->dest, &iph->saddr, tcph->source); 2084 &tmp_daddr, tcph->dest, &tmp_saddr, tcph->source);
2079 2085
2080 do { 2086 do {
2081 cm_node = find_node(cm_core, 2087 cm_node = find_node(cm_core,
diff --git a/drivers/infiniband/hw/nes/nes_utils.c b/drivers/infiniband/hw/nes/nes_utils.c
index aa9b7348c72..6f3bc1b6bf2 100644
--- a/drivers/infiniband/hw/nes/nes_utils.c
+++ b/drivers/infiniband/hw/nes/nes_utils.c
@@ -655,6 +655,7 @@ int nes_arp_table(struct nes_device *nesdev, u32 ip_addr, u8 *mac_addr, u32 acti
655 struct nes_adapter *nesadapter = nesdev->nesadapter; 655 struct nes_adapter *nesadapter = nesdev->nesadapter;
656 int arp_index; 656 int arp_index;
657 int err = 0; 657 int err = 0;
658 __be32 tmp_addr;
658 659
659 for (arp_index = 0; (u32) arp_index < nesadapter->arp_table_size; arp_index++) { 660 for (arp_index = 0; (u32) arp_index < nesadapter->arp_table_size; arp_index++) {
660 if (nesadapter->arp_table[arp_index].ip_addr == ip_addr) 661 if (nesadapter->arp_table[arp_index].ip_addr == ip_addr)
@@ -682,8 +683,9 @@ int nes_arp_table(struct nes_device *nesdev, u32 ip_addr, u8 *mac_addr, u32 acti
682 683
683 /* DELETE or RESOLVE */ 684 /* DELETE or RESOLVE */
684 if (arp_index == nesadapter->arp_table_size) { 685 if (arp_index == nesadapter->arp_table_size) {
686 tmp_addr = cpu_to_be32(ip_addr);
685 nes_debug(NES_DBG_NETDEV, "MAC for %pI4 not in ARP table - cannot %s\n", 687 nes_debug(NES_DBG_NETDEV, "MAC for %pI4 not in ARP table - cannot %s\n",
686 &ip_addr, action == NES_ARP_RESOLVE ? "resolve" : "delete"); 688 &tmp_addr, action == NES_ARP_RESOLVE ? "resolve" : "delete");
687 return -1; 689 return -1;
688 } 690 }
689 691
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 19e06bc38b3..dce0443f9d6 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -711,26 +711,26 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev)
711 711
712 neigh = *to_ipoib_neigh(skb->dst->neighbour); 712 neigh = *to_ipoib_neigh(skb->dst->neighbour);
713 713
714 if (neigh->ah) 714 if (unlikely((memcmp(&neigh->dgid.raw,
715 if (unlikely((memcmp(&neigh->dgid.raw, 715 skb->dst->neighbour->ha + 4,
716 skb->dst->neighbour->ha + 4, 716 sizeof(union ib_gid))) ||
717 sizeof(union ib_gid))) || 717 (neigh->dev != dev))) {
718 (neigh->dev != dev))) { 718 spin_lock_irqsave(&priv->lock, flags);
719 spin_lock_irqsave(&priv->lock, flags); 719 /*
720 /* 720 * It's safe to call ipoib_put_ah() inside
721 * It's safe to call ipoib_put_ah() inside 721 * priv->lock here, because we know that
722 * priv->lock here, because we know that 722 * path->ah will always hold one more reference,
723 * path->ah will always hold one more reference, 723 * so ipoib_put_ah() will never do more than
724 * so ipoib_put_ah() will never do more than 724 * decrement the ref count.
725 * decrement the ref count. 725 */
726 */ 726 if (neigh->ah)
727 ipoib_put_ah(neigh->ah); 727 ipoib_put_ah(neigh->ah);
728 list_del(&neigh->list); 728 list_del(&neigh->list);
729 ipoib_neigh_free(dev, neigh); 729 ipoib_neigh_free(dev, neigh);
730 spin_unlock_irqrestore(&priv->lock, flags); 730 spin_unlock_irqrestore(&priv->lock, flags);
731 ipoib_path_lookup(skb, dev); 731 ipoib_path_lookup(skb, dev);
732 return NETDEV_TX_OK; 732 return NETDEV_TX_OK;
733 } 733 }
734 734
735 if (ipoib_cm_get(neigh)) { 735 if (ipoib_cm_get(neigh)) {
736 if (ipoib_cm_up(neigh)) { 736 if (ipoib_cm_up(neigh)) {
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
index a2eb3b9789e..59d02e0b8df 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
@@ -529,6 +529,9 @@ void ipoib_mcast_join_task(struct work_struct *work)
529 if (!priv->broadcast) { 529 if (!priv->broadcast) {
530 struct ipoib_mcast *broadcast; 530 struct ipoib_mcast *broadcast;
531 531
532 if (!test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags))
533 return;
534
532 broadcast = ipoib_mcast_alloc(dev, 1); 535 broadcast = ipoib_mcast_alloc(dev, 1);
533 if (!broadcast) { 536 if (!broadcast) {
534 ipoib_warn(priv, "failed to allocate broadcast group\n"); 537 ipoib_warn(priv, "failed to allocate broadcast group\n");
diff --git a/drivers/infiniband/ulp/iser/Kconfig b/drivers/infiniband/ulp/iser/Kconfig
index 77dedba829e..b411c51842d 100644
--- a/drivers/infiniband/ulp/iser/Kconfig
+++ b/drivers/infiniband/ulp/iser/Kconfig
@@ -1,6 +1,6 @@
1config INFINIBAND_ISER 1config INFINIBAND_ISER
2 tristate "iSCSI Extensions for RDMA (iSER)" 2 tristate "iSCSI Extensions for RDMA (iSER)"
3 depends on SCSI && INET 3 depends on SCSI && INET && INFINIBAND_ADDR_TRANS
4 select SCSI_ISCSI_ATTRS 4 select SCSI_ISCSI_ATTRS
5 ---help--- 5 ---help---
6 Support for the iSCSI Extensions for RDMA (iSER) Protocol 6 Support for the iSCSI Extensions for RDMA (iSER) Protocol
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 199055db508..67e5553f699 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -220,4 +220,11 @@ config HP_SDC_RTC
220 Say Y here if you want to support the built-in real time clock 220 Say Y here if you want to support the built-in real time clock
221 of the HP SDC controller. 221 of the HP SDC controller.
222 222
223config INPUT_PCF50633_PMU
224 tristate "PCF50633 PMU events"
225 depends on MFD_PCF50633
226 help
227 Say Y to include support for delivering PMU events via input
228 layer on NXP PCF50633.
229
223endif 230endif
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index d7db2aeb8a9..bb62e6efacf 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -21,3 +21,4 @@ obj-$(CONFIG_HP_SDC_RTC) += hp_sdc_rtc.o
21obj-$(CONFIG_INPUT_UINPUT) += uinput.o 21obj-$(CONFIG_INPUT_UINPUT) += uinput.o
22obj-$(CONFIG_INPUT_APANEL) += apanel.o 22obj-$(CONFIG_INPUT_APANEL) += apanel.o
23obj-$(CONFIG_INPUT_SGI_BTNS) += sgi_btns.o 23obj-$(CONFIG_INPUT_SGI_BTNS) += sgi_btns.o
24obj-$(CONFIG_INPUT_PCF50633_PMU) += pcf50633-input.o
diff --git a/drivers/input/misc/pcf50633-input.c b/drivers/input/misc/pcf50633-input.c
new file mode 100644
index 00000000000..039dcb00ebd
--- /dev/null
+++ b/drivers/input/misc/pcf50633-input.c
@@ -0,0 +1,132 @@
1/* NXP PCF50633 Input Driver
2 *
3 * (C) 2006-2008 by Openmoko, Inc.
4 * Author: Balaji Rao <balajirrao@openmoko.org>
5 * All rights reserved.
6 *
7 * Broken down from monstrous PCF50633 driver mainly by
8 * Harald Welte, Andy Green and Werner Almesberger
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 */
16
17#include <linux/kernel.h>
18#include <linux/module.h>
19#include <linux/init.h>
20#include <linux/device.h>
21#include <linux/platform_device.h>
22#include <linux/input.h>
23
24#include <linux/mfd/pcf50633/core.h>
25
26#define PCF50633_OOCSTAT_ONKEY 0x01
27#define PCF50633_REG_OOCSTAT 0x12
28#define PCF50633_REG_OOCMODE 0x10
29
30struct pcf50633_input {
31 struct pcf50633 *pcf;
32 struct input_dev *input_dev;
33};
34
35static void
36pcf50633_input_irq(int irq, void *data)
37{
38 struct pcf50633_input *input;
39 int onkey_released;
40
41 input = data;
42
43 /* We report only one event depending on the key press status */
44 onkey_released = pcf50633_reg_read(input->pcf, PCF50633_REG_OOCSTAT)
45 & PCF50633_OOCSTAT_ONKEY;
46
47 if (irq == PCF50633_IRQ_ONKEYF && !onkey_released)
48 input_report_key(input->input_dev, KEY_POWER, 1);
49 else if (irq == PCF50633_IRQ_ONKEYR && onkey_released)
50 input_report_key(input->input_dev, KEY_POWER, 0);
51
52 input_sync(input->input_dev);
53}
54
55static int __devinit pcf50633_input_probe(struct platform_device *pdev)
56{
57 struct pcf50633_input *input;
58 struct pcf50633_subdev_pdata *pdata = pdev->dev.platform_data;
59 struct input_dev *input_dev;
60 int ret;
61
62
63 input = kzalloc(sizeof(*input), GFP_KERNEL);
64 if (!input)
65 return -ENOMEM;
66
67 input_dev = input_allocate_device();
68 if (!input_dev) {
69 kfree(input);
70 return -ENOMEM;
71 }
72
73 platform_set_drvdata(pdev, input);
74 input->pcf = pdata->pcf;
75 input->input_dev = input_dev;
76
77 input_dev->name = "PCF50633 PMU events";
78 input_dev->id.bustype = BUS_I2C;
79 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_PWR);
80 set_bit(KEY_POWER, input_dev->keybit);
81
82 ret = input_register_device(input_dev);
83 if (ret) {
84 input_free_device(input_dev);
85 kfree(input);
86 return ret;
87 }
88 pcf50633_register_irq(pdata->pcf, PCF50633_IRQ_ONKEYR,
89 pcf50633_input_irq, input);
90 pcf50633_register_irq(pdata->pcf, PCF50633_IRQ_ONKEYF,
91 pcf50633_input_irq, input);
92
93 return 0;
94}
95
96static int __devexit pcf50633_input_remove(struct platform_device *pdev)
97{
98 struct pcf50633_input *input = platform_get_drvdata(pdev);
99
100 pcf50633_free_irq(input->pcf, PCF50633_IRQ_ONKEYR);
101 pcf50633_free_irq(input->pcf, PCF50633_IRQ_ONKEYF);
102
103 input_unregister_device(input->input_dev);
104 kfree(input);
105
106 return 0;
107}
108
109static struct platform_driver pcf50633_input_driver = {
110 .driver = {
111 .name = "pcf50633-input",
112 },
113 .probe = pcf50633_input_probe,
114 .remove = __devexit_p(pcf50633_input_remove),
115};
116
117static int __init pcf50633_input_init(void)
118{
119 return platform_driver_register(&pcf50633_input_driver);
120}
121module_init(pcf50633_input_init);
122
123static void __exit pcf50633_input_exit(void)
124{
125 platform_driver_unregister(&pcf50633_input_driver);
126}
127module_exit(pcf50633_input_exit);
128
129MODULE_AUTHOR("Balaji Rao <balajirrao@openmoko.org>");
130MODULE_DESCRIPTION("PCF50633 input driver");
131MODULE_LICENSE("GPL");
132MODULE_ALIAS("platform:pcf50633-input");
diff --git a/drivers/isdn/hardware/mISDN/hfcmulti.c b/drivers/isdn/hardware/mISDN/hfcmulti.c
index 97f4708b387..595ba8eb4a0 100644
--- a/drivers/isdn/hardware/mISDN/hfcmulti.c
+++ b/drivers/isdn/hardware/mISDN/hfcmulti.c
@@ -3615,7 +3615,7 @@ hfcm_bctrl(struct mISDNchannel *ch, u_int cmd, void *arg)
3615static void 3615static void
3616ph_state_change(struct dchannel *dch) 3616ph_state_change(struct dchannel *dch)
3617{ 3617{
3618 struct hfc_multi *hc = dch->hw; 3618 struct hfc_multi *hc;
3619 int ch, i; 3619 int ch, i;
3620 3620
3621 if (!dch) { 3621 if (!dch) {
@@ -3623,6 +3623,7 @@ ph_state_change(struct dchannel *dch)
3623 __func__); 3623 __func__);
3624 return; 3624 return;
3625 } 3625 }
3626 hc = dch->hw;
3626 ch = dch->slot; 3627 ch = dch->slot;
3627 3628
3628 if (hc->type == 1) { 3629 if (hc->type == 1) {
diff --git a/drivers/isdn/hardware/mISDN/hfcpci.c b/drivers/isdn/hardware/mISDN/hfcpci.c
index 917bf41a293..f0e14dfcf71 100644
--- a/drivers/isdn/hardware/mISDN/hfcpci.c
+++ b/drivers/isdn/hardware/mISDN/hfcpci.c
@@ -61,7 +61,7 @@ u32 hfc_jiffies;
61 61
62MODULE_AUTHOR("Karsten Keil"); 62MODULE_AUTHOR("Karsten Keil");
63MODULE_LICENSE("GPL"); 63MODULE_LICENSE("GPL");
64module_param(debug, uint, 0); 64module_param(debug, uint, S_IRUGO | S_IWUSR);
65module_param(poll, uint, S_IRUGO | S_IWUSR); 65module_param(poll, uint, S_IRUGO | S_IWUSR);
66 66
67enum { 67enum {
diff --git a/drivers/isdn/mISDN/dsp_cmx.c b/drivers/isdn/mISDN/dsp_cmx.c
index 0ac67bff303..58c43e429f7 100644
--- a/drivers/isdn/mISDN/dsp_cmx.c
+++ b/drivers/isdn/mISDN/dsp_cmx.c
@@ -1579,7 +1579,7 @@ send_packet:
1579 schedule_work(&dsp->workq); 1579 schedule_work(&dsp->workq);
1580} 1580}
1581 1581
1582static u32 jittercount; /* counter for jitter check */; 1582static u32 jittercount; /* counter for jitter check */
1583struct timer_list dsp_spl_tl; 1583struct timer_list dsp_spl_tl;
1584u32 dsp_spl_jiffies; /* calculate the next time to fire */ 1584u32 dsp_spl_jiffies; /* calculate the next time to fire */
1585static u16 dsp_count; /* last sample count */ 1585static u16 dsp_count; /* last sample count */
@@ -1893,7 +1893,7 @@ dsp_cmx_hdlc(struct dsp *dsp, struct sk_buff *skb)
1893 /* in case of hardware (echo) */ 1893 /* in case of hardware (echo) */
1894 if (dsp->pcm_slot_tx >= 0) 1894 if (dsp->pcm_slot_tx >= 0)
1895 return; 1895 return;
1896 if (dsp->echo) 1896 if (dsp->echo) {
1897 nskb = skb_clone(skb, GFP_ATOMIC); 1897 nskb = skb_clone(skb, GFP_ATOMIC);
1898 if (nskb) { 1898 if (nskb) {
1899 hh = mISDN_HEAD_P(nskb); 1899 hh = mISDN_HEAD_P(nskb);
@@ -1902,6 +1902,7 @@ dsp_cmx_hdlc(struct dsp *dsp, struct sk_buff *skb)
1902 skb_queue_tail(&dsp->sendq, nskb); 1902 skb_queue_tail(&dsp->sendq, nskb);
1903 schedule_work(&dsp->workq); 1903 schedule_work(&dsp->workq);
1904 } 1904 }
1905 }
1905 return; 1906 return;
1906 } 1907 }
1907 /* in case of hardware conference */ 1908 /* in case of hardware conference */
diff --git a/drivers/isdn/mISDN/dsp_pipeline.c b/drivers/isdn/mISDN/dsp_pipeline.c
index bf999bdc41c..18cf87c113e 100644
--- a/drivers/isdn/mISDN/dsp_pipeline.c
+++ b/drivers/isdn/mISDN/dsp_pipeline.c
@@ -110,8 +110,7 @@ int mISDN_dsp_element_register(struct mISDN_dsp_element *elem)
110 } 110 }
111 list_add_tail(&entry->list, &dsp_elements); 111 list_add_tail(&entry->list, &dsp_elements);
112 112
113 for (i = 0; i < (sizeof(element_attributes) 113 for (i = 0; i < ARRAY_SIZE(element_attributes); ++i) {
114 / sizeof(struct device_attribute)); ++i)
115 ret = device_create_file(&entry->dev, 114 ret = device_create_file(&entry->dev,
116 &element_attributes[i]); 115 &element_attributes[i]);
117 if (ret) { 116 if (ret) {
@@ -119,6 +118,7 @@ int mISDN_dsp_element_register(struct mISDN_dsp_element *elem)
119 __func__); 118 __func__);
120 goto err2; 119 goto err2;
121 } 120 }
121 }
122 122
123#ifdef PIPELINE_DEBUG 123#ifdef PIPELINE_DEBUG
124 printk(KERN_DEBUG "%s: %s registered\n", __func__, elem->name); 124 printk(KERN_DEBUG "%s: %s registered\n", __func__, elem->name);
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 416f9e7286b..06a2b0f7737 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -217,6 +217,29 @@ config MFD_WM8350_I2C
217 I2C as the control interface. Additional options must be 217 I2C as the control interface. Additional options must be
218 selected to enable support for the functionality of the chip. 218 selected to enable support for the functionality of the chip.
219 219
220config MFD_PCF50633
221 tristate "Support for NXP PCF50633"
222 depends on I2C
223 help
224 Say yes here if you have NXP PCF50633 chip on your board.
225 This core driver provides register access and IRQ handling
226 facilities, and registers devices for the various functions
227 so that function-specific drivers can bind to them.
228
229config PCF50633_ADC
230 tristate "Support for NXP PCF50633 ADC"
231 depends on MFD_PCF50633
232 help
233 Say yes here if you want to include support for ADC in the
234 NXP PCF50633 chip.
235
236config PCF50633_GPIO
237 tristate "Support for NXP PCF50633 GPIO"
238 depends on MFD_PCF50633
239 help
240 Say yes here if you want to include support GPIO for pins on
241 the PCF50633 chip.
242
220endmenu 243endmenu
221 244
222menu "Multimedia Capabilities Port drivers" 245menu "Multimedia Capabilities Port drivers"
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 0c9418b36c2..3afb5192e4d 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -37,3 +37,7 @@ endif
37obj-$(CONFIG_UCB1400_CORE) += ucb1400_core.o 37obj-$(CONFIG_UCB1400_CORE) += ucb1400_core.o
38 38
39obj-$(CONFIG_PMIC_DA903X) += da903x.o 39obj-$(CONFIG_PMIC_DA903X) += da903x.o
40
41obj-$(CONFIG_MFD_PCF50633) += pcf50633-core.o
42obj-$(CONFIG_PCF50633_ADC) += pcf50633-adc.o
43obj-$(CONFIG_PCF50633_GPIO) += pcf50633-gpio.o \ No newline at end of file
diff --git a/drivers/mfd/dm355evm_msp.c b/drivers/mfd/dm355evm_msp.c
index 4214b3f7242..7ac12cb0be4 100644
--- a/drivers/mfd/dm355evm_msp.c
+++ b/drivers/mfd/dm355evm_msp.c
@@ -107,6 +107,9 @@ static const u8 msp_gpios[] = {
107 MSP_GPIO(0, SWITCH1), MSP_GPIO(1, SWITCH1), 107 MSP_GPIO(0, SWITCH1), MSP_GPIO(1, SWITCH1),
108 MSP_GPIO(2, SWITCH1), MSP_GPIO(3, SWITCH1), 108 MSP_GPIO(2, SWITCH1), MSP_GPIO(3, SWITCH1),
109 MSP_GPIO(4, SWITCH1), 109 MSP_GPIO(4, SWITCH1),
110 /* switches on MMC/SD sockets */
111 MSP_GPIO(1, SDMMC), MSP_GPIO(2, SDMMC), /* mmc0 WP, nCD */
112 MSP_GPIO(3, SDMMC), MSP_GPIO(4, SDMMC), /* mmc1 WP, nCD */
110}; 113};
111 114
112#define MSP_GPIO_REG(offset) (msp_gpios[(offset)] >> 3) 115#define MSP_GPIO_REG(offset) (msp_gpios[(offset)] >> 3)
@@ -304,6 +307,13 @@ static int add_children(struct i2c_client *client)
304 gpio_export(gpio, false); 307 gpio_export(gpio, false);
305 } 308 }
306 309
310 /* MMC/SD inputs -- right after the last config input */
311 if (client->dev.platform_data) {
312 void (*mmcsd_setup)(unsigned) = client->dev.platform_data;
313
314 mmcsd_setup(dm355evm_msp_gpio.base + 8 + 5);
315 }
316
307 /* RTC is a 32 bit counter, no alarm */ 317 /* RTC is a 32 bit counter, no alarm */
308 if (msp_has_rtc()) { 318 if (msp_has_rtc()) {
309 child = add_child(client, "rtc-dm355evm", 319 child = add_child(client, "rtc-dm355evm",
diff --git a/drivers/mfd/pcf50633-adc.c b/drivers/mfd/pcf50633-adc.c
new file mode 100644
index 00000000000..c2d05becfa9
--- /dev/null
+++ b/drivers/mfd/pcf50633-adc.c
@@ -0,0 +1,277 @@
1/* NXP PCF50633 ADC Driver
2 *
3 * (C) 2006-2008 by Openmoko, Inc.
4 * Author: Balaji Rao <balajirrao@openmoko.org>
5 * All rights reserved.
6 *
7 * Broken down from monstrous PCF50633 driver mainly by
8 * Harald Welte, Andy Green and Werner Almesberger
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 * NOTE: This driver does not yet support subtractive ADC mode, which means
16 * you can do only one measurement per read request.
17 */
18
19#include <linux/kernel.h>
20#include <linux/module.h>
21#include <linux/init.h>
22#include <linux/device.h>
23#include <linux/platform_device.h>
24#include <linux/completion.h>
25
26#include <linux/mfd/pcf50633/core.h>
27#include <linux/mfd/pcf50633/adc.h>
28
29struct pcf50633_adc_request {
30 int mux;
31 int avg;
32 int result;
33 void (*callback)(struct pcf50633 *, void *, int);
34 void *callback_param;
35
36 /* Used in case of sync requests */
37 struct completion completion;
38
39};
40
41#define PCF50633_MAX_ADC_FIFO_DEPTH 8
42
43struct pcf50633_adc {
44 struct pcf50633 *pcf;
45
46 /* Private stuff */
47 struct pcf50633_adc_request *queue[PCF50633_MAX_ADC_FIFO_DEPTH];
48 int queue_head;
49 int queue_tail;
50 struct mutex queue_mutex;
51};
52
53static inline struct pcf50633_adc *__to_adc(struct pcf50633 *pcf)
54{
55 return platform_get_drvdata(pcf->adc_pdev);
56}
57
58static void adc_setup(struct pcf50633 *pcf, int channel, int avg)
59{
60 channel &= PCF50633_ADCC1_ADCMUX_MASK;
61
62 /* kill ratiometric, but enable ACCSW biasing */
63 pcf50633_reg_write(pcf, PCF50633_REG_ADCC2, 0x00);
64 pcf50633_reg_write(pcf, PCF50633_REG_ADCC3, 0x01);
65
66 /* start ADC conversion on selected channel */
67 pcf50633_reg_write(pcf, PCF50633_REG_ADCC1, channel | avg |
68 PCF50633_ADCC1_ADCSTART | PCF50633_ADCC1_RES_10BIT);
69}
70
71static void trigger_next_adc_job_if_any(struct pcf50633 *pcf)
72{
73 struct pcf50633_adc *adc = __to_adc(pcf);
74 int head;
75
76 mutex_lock(&adc->queue_mutex);
77
78 head = adc->queue_head;
79
80 if (!adc->queue[head]) {
81 mutex_unlock(&adc->queue_mutex);
82 return;
83 }
84 mutex_unlock(&adc->queue_mutex);
85
86 adc_setup(pcf, adc->queue[head]->mux, adc->queue[head]->avg);
87}
88
89static int
90adc_enqueue_request(struct pcf50633 *pcf, struct pcf50633_adc_request *req)
91{
92 struct pcf50633_adc *adc = __to_adc(pcf);
93 int head, tail;
94
95 mutex_lock(&adc->queue_mutex);
96
97 head = adc->queue_head;
98 tail = adc->queue_tail;
99
100 if (adc->queue[tail]) {
101 mutex_unlock(&adc->queue_mutex);
102 return -EBUSY;
103 }
104
105 adc->queue[tail] = req;
106 adc->queue_tail = (tail + 1) & (PCF50633_MAX_ADC_FIFO_DEPTH - 1);
107
108 mutex_unlock(&adc->queue_mutex);
109
110 trigger_next_adc_job_if_any(pcf);
111
112 return 0;
113}
114
115static void
116pcf50633_adc_sync_read_callback(struct pcf50633 *pcf, void *param, int result)
117{
118 struct pcf50633_adc_request *req = param;
119
120 req->result = result;
121 complete(&req->completion);
122}
123
124int pcf50633_adc_sync_read(struct pcf50633 *pcf, int mux, int avg)
125{
126 struct pcf50633_adc_request *req;
127
128 /* req is freed when the result is ready, in interrupt handler */
129 req = kzalloc(sizeof(*req), GFP_KERNEL);
130 if (!req)
131 return -ENOMEM;
132
133 req->mux = mux;
134 req->avg = avg;
135 req->callback = pcf50633_adc_sync_read_callback;
136 req->callback_param = req;
137
138 init_completion(&req->completion);
139 adc_enqueue_request(pcf, req);
140 wait_for_completion(&req->completion);
141
142 return req->result;
143}
144EXPORT_SYMBOL_GPL(pcf50633_adc_sync_read);
145
146int pcf50633_adc_async_read(struct pcf50633 *pcf, int mux, int avg,
147 void (*callback)(struct pcf50633 *, void *, int),
148 void *callback_param)
149{
150 struct pcf50633_adc_request *req;
151
152 /* req is freed when the result is ready, in interrupt handler */
153 req = kmalloc(sizeof(*req), GFP_KERNEL);
154 if (!req)
155 return -ENOMEM;
156
157 req->mux = mux;
158 req->avg = avg;
159 req->callback = callback;
160 req->callback_param = callback_param;
161
162 adc_enqueue_request(pcf, req);
163
164 return 0;
165}
166EXPORT_SYMBOL_GPL(pcf50633_adc_async_read);
167
168static int adc_result(struct pcf50633 *pcf)
169{
170 u8 adcs1, adcs3;
171 u16 result;
172
173 adcs1 = pcf50633_reg_read(pcf, PCF50633_REG_ADCS1);
174 adcs3 = pcf50633_reg_read(pcf, PCF50633_REG_ADCS3);
175 result = (adcs1 << 2) | (adcs3 & PCF50633_ADCS3_ADCDAT1L_MASK);
176
177 dev_dbg(pcf->dev, "adc result = %d\n", result);
178
179 return result;
180}
181
182static void pcf50633_adc_irq(int irq, void *data)
183{
184 struct pcf50633_adc *adc = data;
185 struct pcf50633 *pcf = adc->pcf;
186 struct pcf50633_adc_request *req;
187 int head;
188
189 mutex_lock(&adc->queue_mutex);
190 head = adc->queue_head;
191
192 req = adc->queue[head];
193 if (WARN_ON(!req)) {
194 dev_err(pcf->dev, "pcf50633-adc irq: ADC queue empty!\n");
195 mutex_unlock(&adc->queue_mutex);
196 return;
197 }
198 adc->queue[head] = NULL;
199 adc->queue_head = (head + 1) &
200 (PCF50633_MAX_ADC_FIFO_DEPTH - 1);
201
202 mutex_unlock(&adc->queue_mutex);
203
204 req->callback(pcf, req->callback_param, adc_result(pcf));
205 kfree(req);
206
207 trigger_next_adc_job_if_any(pcf);
208}
209
210static int __devinit pcf50633_adc_probe(struct platform_device *pdev)
211{
212 struct pcf50633_subdev_pdata *pdata = pdev->dev.platform_data;
213 struct pcf50633_adc *adc;
214
215 adc = kzalloc(sizeof(*adc), GFP_KERNEL);
216 if (!adc)
217 return -ENOMEM;
218
219 adc->pcf = pdata->pcf;
220 platform_set_drvdata(pdev, adc);
221
222 pcf50633_register_irq(pdata->pcf, PCF50633_IRQ_ADCRDY,
223 pcf50633_adc_irq, adc);
224
225 mutex_init(&adc->queue_mutex);
226
227 return 0;
228}
229
230static int __devexit pcf50633_adc_remove(struct platform_device *pdev)
231{
232 struct pcf50633_adc *adc = platform_get_drvdata(pdev);
233 int i, head;
234
235 pcf50633_free_irq(adc->pcf, PCF50633_IRQ_ADCRDY);
236
237 mutex_lock(&adc->queue_mutex);
238 head = adc->queue_head;
239
240 if (WARN_ON(adc->queue[head]))
241 dev_err(adc->pcf->dev,
242 "adc driver removed with request pending\n");
243
244 for (i = 0; i < PCF50633_MAX_ADC_FIFO_DEPTH; i++)
245 kfree(adc->queue[i]);
246
247 mutex_unlock(&adc->queue_mutex);
248 kfree(adc);
249
250 return 0;
251}
252
253static struct platform_driver pcf50633_adc_driver = {
254 .driver = {
255 .name = "pcf50633-adc",
256 },
257 .probe = pcf50633_adc_probe,
258 .remove = __devexit_p(pcf50633_adc_remove),
259};
260
261static int __init pcf50633_adc_init(void)
262{
263 return platform_driver_register(&pcf50633_adc_driver);
264}
265module_init(pcf50633_adc_init);
266
267static void __exit pcf50633_adc_exit(void)
268{
269 platform_driver_unregister(&pcf50633_adc_driver);
270}
271module_exit(pcf50633_adc_exit);
272
273MODULE_AUTHOR("Balaji Rao <balajirrao@openmoko.org>");
274MODULE_DESCRIPTION("PCF50633 adc driver");
275MODULE_LICENSE("GPL");
276MODULE_ALIAS("platform:pcf50633-adc");
277
diff --git a/drivers/mfd/pcf50633-core.c b/drivers/mfd/pcf50633-core.c
new file mode 100644
index 00000000000..24508e28e3f
--- /dev/null
+++ b/drivers/mfd/pcf50633-core.c
@@ -0,0 +1,710 @@
1/* NXP PCF50633 Power Management Unit (PMU) driver
2 *
3 * (C) 2006-2008 by Openmoko, Inc.
4 * Author: Harald Welte <laforge@openmoko.org>
5 * Balaji Rao <balajirrao@openmoko.org>
6 * All rights reserved.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 */
14
15#include <linux/kernel.h>
16#include <linux/device.h>
17#include <linux/sysfs.h>
18#include <linux/device.h>
19#include <linux/module.h>
20#include <linux/types.h>
21#include <linux/interrupt.h>
22#include <linux/workqueue.h>
23#include <linux/platform_device.h>
24#include <linux/i2c.h>
25#include <linux/irq.h>
26
27#include <linux/mfd/pcf50633/core.h>
28
29/* Two MBCS registers used during cold start */
30#define PCF50633_REG_MBCS1 0x4b
31#define PCF50633_REG_MBCS2 0x4c
32#define PCF50633_MBCS1_USBPRES 0x01
33#define PCF50633_MBCS1_ADAPTPRES 0x01
34
35static int __pcf50633_read(struct pcf50633 *pcf, u8 reg, int num, u8 *data)
36{
37 int ret;
38
39 ret = i2c_smbus_read_i2c_block_data(pcf->i2c_client, reg,
40 num, data);
41 if (ret < 0)
42 dev_err(pcf->dev, "Error reading %d regs at %d\n", num, reg);
43
44 return ret;
45}
46
47static int __pcf50633_write(struct pcf50633 *pcf, u8 reg, int num, u8 *data)
48{
49 int ret;
50
51 ret = i2c_smbus_write_i2c_block_data(pcf->i2c_client, reg,
52 num, data);
53 if (ret < 0)
54 dev_err(pcf->dev, "Error writing %d regs at %d\n", num, reg);
55
56 return ret;
57
58}
59
60/* Read a block of upto 32 regs */
61int pcf50633_read_block(struct pcf50633 *pcf, u8 reg,
62 int nr_regs, u8 *data)
63{
64 int ret;
65
66 mutex_lock(&pcf->lock);
67 ret = __pcf50633_read(pcf, reg, nr_regs, data);
68 mutex_unlock(&pcf->lock);
69
70 return ret;
71}
72EXPORT_SYMBOL_GPL(pcf50633_read_block);
73
74/* Write a block of upto 32 regs */
75int pcf50633_write_block(struct pcf50633 *pcf , u8 reg,
76 int nr_regs, u8 *data)
77{
78 int ret;
79
80 mutex_lock(&pcf->lock);
81 ret = __pcf50633_write(pcf, reg, nr_regs, data);
82 mutex_unlock(&pcf->lock);
83
84 return ret;
85}
86EXPORT_SYMBOL_GPL(pcf50633_write_block);
87
88u8 pcf50633_reg_read(struct pcf50633 *pcf, u8 reg)
89{
90 u8 val;
91
92 mutex_lock(&pcf->lock);
93 __pcf50633_read(pcf, reg, 1, &val);
94 mutex_unlock(&pcf->lock);
95
96 return val;
97}
98EXPORT_SYMBOL_GPL(pcf50633_reg_read);
99
100int pcf50633_reg_write(struct pcf50633 *pcf, u8 reg, u8 val)
101{
102 int ret;
103
104 mutex_lock(&pcf->lock);
105 ret = __pcf50633_write(pcf, reg, 1, &val);
106 mutex_unlock(&pcf->lock);
107
108 return ret;
109}
110EXPORT_SYMBOL_GPL(pcf50633_reg_write);
111
112int pcf50633_reg_set_bit_mask(struct pcf50633 *pcf, u8 reg, u8 mask, u8 val)
113{
114 int ret;
115 u8 tmp;
116
117 val &= mask;
118
119 mutex_lock(&pcf->lock);
120 ret = __pcf50633_read(pcf, reg, 1, &tmp);
121 if (ret < 0)
122 goto out;
123
124 tmp &= ~mask;
125 tmp |= val;
126 ret = __pcf50633_write(pcf, reg, 1, &tmp);
127
128out:
129 mutex_unlock(&pcf->lock);
130
131 return ret;
132}
133EXPORT_SYMBOL_GPL(pcf50633_reg_set_bit_mask);
134
135int pcf50633_reg_clear_bits(struct pcf50633 *pcf, u8 reg, u8 val)
136{
137 int ret;
138 u8 tmp;
139
140 mutex_lock(&pcf->lock);
141 ret = __pcf50633_read(pcf, reg, 1, &tmp);
142 if (ret < 0)
143 goto out;
144
145 tmp &= ~val;
146 ret = __pcf50633_write(pcf, reg, 1, &tmp);
147
148out:
149 mutex_unlock(&pcf->lock);
150
151 return ret;
152}
153EXPORT_SYMBOL_GPL(pcf50633_reg_clear_bits);
154
155/* sysfs attributes */
156static ssize_t show_dump_regs(struct device *dev, struct device_attribute *attr,
157 char *buf)
158{
159 struct pcf50633 *pcf = dev_get_drvdata(dev);
160 u8 dump[16];
161 int n, n1, idx = 0;
162 char *buf1 = buf;
163 static u8 address_no_read[] = { /* must be ascending */
164 PCF50633_REG_INT1,
165 PCF50633_REG_INT2,
166 PCF50633_REG_INT3,
167 PCF50633_REG_INT4,
168 PCF50633_REG_INT5,
169 0 /* terminator */
170 };
171
172 for (n = 0; n < 256; n += sizeof(dump)) {
173 for (n1 = 0; n1 < sizeof(dump); n1++)
174 if (n == address_no_read[idx]) {
175 idx++;
176 dump[n1] = 0x00;
177 } else
178 dump[n1] = pcf50633_reg_read(pcf, n + n1);
179
180 hex_dump_to_buffer(dump, sizeof(dump), 16, 1, buf1, 128, 0);
181 buf1 += strlen(buf1);
182 *buf1++ = '\n';
183 *buf1 = '\0';
184 }
185
186 return buf1 - buf;
187}
188static DEVICE_ATTR(dump_regs, 0400, show_dump_regs, NULL);
189
190static ssize_t show_resume_reason(struct device *dev,
191 struct device_attribute *attr, char *buf)
192{
193 struct pcf50633 *pcf = dev_get_drvdata(dev);
194 int n;
195
196 n = sprintf(buf, "%02x%02x%02x%02x%02x\n",
197 pcf->resume_reason[0],
198 pcf->resume_reason[1],
199 pcf->resume_reason[2],
200 pcf->resume_reason[3],
201 pcf->resume_reason[4]);
202
203 return n;
204}
205static DEVICE_ATTR(resume_reason, 0400, show_resume_reason, NULL);
206
207static struct attribute *pcf_sysfs_entries[] = {
208 &dev_attr_dump_regs.attr,
209 &dev_attr_resume_reason.attr,
210 NULL,
211};
212
213static struct attribute_group pcf_attr_group = {
214 .name = NULL, /* put in device directory */
215 .attrs = pcf_sysfs_entries,
216};
217
218int pcf50633_register_irq(struct pcf50633 *pcf, int irq,
219 void (*handler) (int, void *), void *data)
220{
221 if (irq < 0 || irq > PCF50633_NUM_IRQ || !handler)
222 return -EINVAL;
223
224 if (WARN_ON(pcf->irq_handler[irq].handler))
225 return -EBUSY;
226
227 mutex_lock(&pcf->lock);
228 pcf->irq_handler[irq].handler = handler;
229 pcf->irq_handler[irq].data = data;
230 mutex_unlock(&pcf->lock);
231
232 return 0;
233}
234EXPORT_SYMBOL_GPL(pcf50633_register_irq);
235
236int pcf50633_free_irq(struct pcf50633 *pcf, int irq)
237{
238 if (irq < 0 || irq > PCF50633_NUM_IRQ)
239 return -EINVAL;
240
241 mutex_lock(&pcf->lock);
242 pcf->irq_handler[irq].handler = NULL;
243 mutex_unlock(&pcf->lock);
244
245 return 0;
246}
247EXPORT_SYMBOL_GPL(pcf50633_free_irq);
248
249static int __pcf50633_irq_mask_set(struct pcf50633 *pcf, int irq, u8 mask)
250{
251 u8 reg, bits, tmp;
252 int ret = 0, idx;
253
254 idx = irq >> 3;
255 reg = PCF50633_REG_INT1M + idx;
256 bits = 1 << (irq & 0x07);
257
258 mutex_lock(&pcf->lock);
259
260 if (mask) {
261 ret = __pcf50633_read(pcf, reg, 1, &tmp);
262 if (ret < 0)
263 goto out;
264
265 tmp |= bits;
266
267 ret = __pcf50633_write(pcf, reg, 1, &tmp);
268 if (ret < 0)
269 goto out;
270
271 pcf->mask_regs[idx] &= ~bits;
272 pcf->mask_regs[idx] |= bits;
273 } else {
274 ret = __pcf50633_read(pcf, reg, 1, &tmp);
275 if (ret < 0)
276 goto out;
277
278 tmp &= ~bits;
279
280 ret = __pcf50633_write(pcf, reg, 1, &tmp);
281 if (ret < 0)
282 goto out;
283
284 pcf->mask_regs[idx] &= ~bits;
285 }
286out:
287 mutex_unlock(&pcf->lock);
288
289 return ret;
290}
291
292int pcf50633_irq_mask(struct pcf50633 *pcf, int irq)
293{
294 dev_info(pcf->dev, "Masking IRQ %d\n", irq);
295
296 return __pcf50633_irq_mask_set(pcf, irq, 1);
297}
298EXPORT_SYMBOL_GPL(pcf50633_irq_mask);
299
300int pcf50633_irq_unmask(struct pcf50633 *pcf, int irq)
301{
302 dev_info(pcf->dev, "Unmasking IRQ %d\n", irq);
303
304 return __pcf50633_irq_mask_set(pcf, irq, 0);
305}
306EXPORT_SYMBOL_GPL(pcf50633_irq_unmask);
307
308int pcf50633_irq_mask_get(struct pcf50633 *pcf, int irq)
309{
310 u8 reg, bits;
311
312 reg = irq >> 3;
313 bits = 1 << (irq & 0x07);
314
315 return pcf->mask_regs[reg] & bits;
316}
317EXPORT_SYMBOL_GPL(pcf50633_irq_mask_get);
318
319static void pcf50633_irq_call_handler(struct pcf50633 *pcf, int irq)
320{
321 if (pcf->irq_handler[irq].handler)
322 pcf->irq_handler[irq].handler(irq, pcf->irq_handler[irq].data);
323}
324
325/* Maximum amount of time ONKEY is held before emergency action is taken */
326#define PCF50633_ONKEY1S_TIMEOUT 8
327
328static void pcf50633_irq_worker(struct work_struct *work)
329{
330 struct pcf50633 *pcf;
331 int ret, i, j;
332 u8 pcf_int[5], chgstat;
333
334 pcf = container_of(work, struct pcf50633, irq_work);
335
336 /* Read the 5 INT regs in one transaction */
337 ret = pcf50633_read_block(pcf, PCF50633_REG_INT1,
338 ARRAY_SIZE(pcf_int), pcf_int);
339 if (ret != ARRAY_SIZE(pcf_int)) {
340 dev_err(pcf->dev, "Error reading INT registers\n");
341
342 /*
343 * If this doesn't ACK the interrupt to the chip, we'll be
344 * called once again as we're level triggered.
345 */
346 goto out;
347 }
348
349 /* We immediately read the usb and adapter status. We thus make sure
350 * only of USBINS/USBREM IRQ handlers are called */
351 if (pcf_int[0] & (PCF50633_INT1_USBINS | PCF50633_INT1_USBREM)) {
352 chgstat = pcf50633_reg_read(pcf, PCF50633_REG_MBCS2);
353 if (chgstat & (0x3 << 4))
354 pcf_int[0] &= ~(1 << PCF50633_INT1_USBREM);
355 else
356 pcf_int[0] &= ~(1 << PCF50633_INT1_USBINS);
357 }
358
359 /* Make sure only one of ADPINS or ADPREM is set */
360 if (pcf_int[0] & (PCF50633_INT1_ADPINS | PCF50633_INT1_ADPREM)) {
361 chgstat = pcf50633_reg_read(pcf, PCF50633_REG_MBCS2);
362 if (chgstat & (0x3 << 4))
363 pcf_int[0] &= ~(1 << PCF50633_INT1_ADPREM);
364 else
365 pcf_int[0] &= ~(1 << PCF50633_INT1_ADPINS);
366 }
367
368 dev_dbg(pcf->dev, "INT1=0x%02x INT2=0x%02x INT3=0x%02x "
369 "INT4=0x%02x INT5=0x%02x\n", pcf_int[0],
370 pcf_int[1], pcf_int[2], pcf_int[3], pcf_int[4]);
371
372 /* Some revisions of the chip don't have a 8s standby mode on
373 * ONKEY1S press. We try to manually do it in such cases. */
374 if ((pcf_int[0] & PCF50633_INT1_SECOND) && pcf->onkey1s_held) {
375 dev_info(pcf->dev, "ONKEY1S held for %d secs\n",
376 pcf->onkey1s_held);
377 if (pcf->onkey1s_held++ == PCF50633_ONKEY1S_TIMEOUT)
378 if (pcf->pdata->force_shutdown)
379 pcf->pdata->force_shutdown(pcf);
380 }
381
382 if (pcf_int[2] & PCF50633_INT3_ONKEY1S) {
383 dev_info(pcf->dev, "ONKEY1S held\n");
384 pcf->onkey1s_held = 1 ;
385
386 /* Unmask IRQ_SECOND */
387 pcf50633_reg_clear_bits(pcf, PCF50633_REG_INT1M,
388 PCF50633_INT1_SECOND);
389
390 /* Unmask IRQ_ONKEYR */
391 pcf50633_reg_clear_bits(pcf, PCF50633_REG_INT2M,
392 PCF50633_INT2_ONKEYR);
393 }
394
395 if ((pcf_int[1] & PCF50633_INT2_ONKEYR) && pcf->onkey1s_held) {
396 pcf->onkey1s_held = 0;
397
398 /* Mask SECOND and ONKEYR interrupts */
399 if (pcf->mask_regs[0] & PCF50633_INT1_SECOND)
400 pcf50633_reg_set_bit_mask(pcf,
401 PCF50633_REG_INT1M,
402 PCF50633_INT1_SECOND,
403 PCF50633_INT1_SECOND);
404
405 if (pcf->mask_regs[1] & PCF50633_INT2_ONKEYR)
406 pcf50633_reg_set_bit_mask(pcf,
407 PCF50633_REG_INT2M,
408 PCF50633_INT2_ONKEYR,
409 PCF50633_INT2_ONKEYR);
410 }
411
412 /* Have we just resumed ? */
413 if (pcf->is_suspended) {
414 pcf->is_suspended = 0;
415
416 /* Set the resume reason filtering out non resumers */
417 for (i = 0; i < ARRAY_SIZE(pcf_int); i++)
418 pcf->resume_reason[i] = pcf_int[i] &
419 pcf->pdata->resumers[i];
420
421 /* Make sure we don't pass on any ONKEY events to
422 * userspace now */
423 pcf_int[1] &= ~(PCF50633_INT2_ONKEYR | PCF50633_INT2_ONKEYF);
424 }
425
426 for (i = 0; i < ARRAY_SIZE(pcf_int); i++) {
427 /* Unset masked interrupts */
428 pcf_int[i] &= ~pcf->mask_regs[i];
429
430 for (j = 0; j < 8 ; j++)
431 if (pcf_int[i] & (1 << j))
432 pcf50633_irq_call_handler(pcf, (i * 8) + j);
433 }
434
435out:
436 put_device(pcf->dev);
437 enable_irq(pcf->irq);
438}
439
440static irqreturn_t pcf50633_irq(int irq, void *data)
441{
442 struct pcf50633 *pcf = data;
443
444 dev_dbg(pcf->dev, "pcf50633_irq\n");
445
446 get_device(pcf->dev);
447 disable_irq(pcf->irq);
448 schedule_work(&pcf->irq_work);
449
450 return IRQ_HANDLED;
451}
452
453static void
454pcf50633_client_dev_register(struct pcf50633 *pcf, const char *name,
455 struct platform_device **pdev)
456{
457 struct pcf50633_subdev_pdata *subdev_pdata;
458 int ret;
459
460 *pdev = platform_device_alloc(name, -1);
461 if (!*pdev) {
462 dev_err(pcf->dev, "Falied to allocate %s\n", name);
463 return;
464 }
465
466 subdev_pdata = kmalloc(sizeof(*subdev_pdata), GFP_KERNEL);
467 if (!subdev_pdata) {
468 dev_err(pcf->dev, "Error allocating subdev pdata\n");
469 platform_device_put(*pdev);
470 }
471
472 subdev_pdata->pcf = pcf;
473 platform_device_add_data(*pdev, subdev_pdata, sizeof(*subdev_pdata));
474
475 (*pdev)->dev.parent = pcf->dev;
476
477 ret = platform_device_add(*pdev);
478 if (ret) {
479 dev_err(pcf->dev, "Failed to register %s: %d\n", name, ret);
480 platform_device_put(*pdev);
481 *pdev = NULL;
482 }
483}
484
485#ifdef CONFIG_PM
486static int pcf50633_suspend(struct device *dev, pm_message_t state)
487{
488 struct pcf50633 *pcf;
489 int ret = 0, i;
490 u8 res[5];
491
492 pcf = dev_get_drvdata(dev);
493
494 /* Make sure our interrupt handlers are not called
495 * henceforth */
496 disable_irq(pcf->irq);
497
498 /* Make sure that any running IRQ worker has quit */
499 cancel_work_sync(&pcf->irq_work);
500
501 /* Save the masks */
502 ret = pcf50633_read_block(pcf, PCF50633_REG_INT1M,
503 ARRAY_SIZE(pcf->suspend_irq_masks),
504 pcf->suspend_irq_masks);
505 if (ret < 0) {
506 dev_err(pcf->dev, "error saving irq masks\n");
507 goto out;
508 }
509
510 /* Write wakeup irq masks */
511 for (i = 0; i < ARRAY_SIZE(res); i++)
512 res[i] = ~pcf->pdata->resumers[i];
513
514 ret = pcf50633_write_block(pcf, PCF50633_REG_INT1M,
515 ARRAY_SIZE(res), &res[0]);
516 if (ret < 0) {
517 dev_err(pcf->dev, "error writing wakeup irq masks\n");
518 goto out;
519 }
520
521 pcf->is_suspended = 1;
522
523out:
524 return ret;
525}
526
527static int pcf50633_resume(struct device *dev)
528{
529 struct pcf50633 *pcf;
530 int ret;
531
532 pcf = dev_get_drvdata(dev);
533
534 /* Write the saved mask registers */
535 ret = pcf50633_write_block(pcf, PCF50633_REG_INT1M,
536 ARRAY_SIZE(pcf->suspend_irq_masks),
537 pcf->suspend_irq_masks);
538 if (ret < 0)
539 dev_err(pcf->dev, "Error restoring saved suspend masks\n");
540
541 /* Restore regulators' state */
542
543
544 get_device(pcf->dev);
545
546 /*
547 * Clear any pending interrupts and set resume reason if any.
548 * This will leave with enable_irq()
549 */
550 pcf50633_irq_worker(&pcf->irq_work);
551
552 return 0;
553}
554#else
555#define pcf50633_suspend NULL
556#define pcf50633_resume NULL
557#endif
558
559static int __devinit pcf50633_probe(struct i2c_client *client,
560 const struct i2c_device_id *ids)
561{
562 struct pcf50633 *pcf;
563 struct pcf50633_platform_data *pdata = client->dev.platform_data;
564 int i, ret = 0;
565 int version, variant;
566
567 pcf = kzalloc(sizeof(*pcf), GFP_KERNEL);
568 if (!pcf)
569 return -ENOMEM;
570
571 pcf->pdata = pdata;
572
573 mutex_init(&pcf->lock);
574
575 i2c_set_clientdata(client, pcf);
576 pcf->dev = &client->dev;
577 pcf->i2c_client = client;
578 pcf->irq = client->irq;
579
580 INIT_WORK(&pcf->irq_work, pcf50633_irq_worker);
581
582 version = pcf50633_reg_read(pcf, 0);
583 variant = pcf50633_reg_read(pcf, 1);
584 if (version < 0 || variant < 0) {
585 dev_err(pcf->dev, "Unable to probe pcf50633\n");
586 ret = -ENODEV;
587 goto err;
588 }
589
590 dev_info(pcf->dev, "Probed device version %d variant %d\n",
591 version, variant);
592
593 /* Enable all interrupts except RTC SECOND */
594 pcf->mask_regs[0] = 0x80;
595 pcf50633_reg_write(pcf, PCF50633_REG_INT1M, pcf->mask_regs[0]);
596 pcf50633_reg_write(pcf, PCF50633_REG_INT2M, 0x00);
597 pcf50633_reg_write(pcf, PCF50633_REG_INT3M, 0x00);
598 pcf50633_reg_write(pcf, PCF50633_REG_INT4M, 0x00);
599 pcf50633_reg_write(pcf, PCF50633_REG_INT5M, 0x00);
600
601 /* Create sub devices */
602 pcf50633_client_dev_register(pcf, "pcf50633-input",
603 &pcf->input_pdev);
604 pcf50633_client_dev_register(pcf, "pcf50633-rtc",
605 &pcf->rtc_pdev);
606 pcf50633_client_dev_register(pcf, "pcf50633-mbc",
607 &pcf->mbc_pdev);
608 pcf50633_client_dev_register(pcf, "pcf50633-adc",
609 &pcf->adc_pdev);
610
611 for (i = 0; i < PCF50633_NUM_REGULATORS; i++) {
612 struct platform_device *pdev;
613
614 pdev = platform_device_alloc("pcf50633-regltr", i);
615 if (!pdev) {
616 dev_err(pcf->dev, "Cannot create regulator\n");
617 continue;
618 }
619
620 pdev->dev.parent = pcf->dev;
621 pdev->dev.platform_data = &pdata->reg_init_data[i];
622 pdev->dev.driver_data = pcf;
623 pcf->regulator_pdev[i] = pdev;
624
625 platform_device_add(pdev);
626 }
627
628 if (client->irq) {
629 set_irq_handler(client->irq, handle_level_irq);
630 ret = request_irq(client->irq, pcf50633_irq,
631 IRQF_TRIGGER_LOW, "pcf50633", pcf);
632
633 if (ret) {
634 dev_err(pcf->dev, "Failed to request IRQ %d\n", ret);
635 goto err;
636 }
637 } else {
638 dev_err(pcf->dev, "No IRQ configured\n");
639 goto err;
640 }
641
642 if (enable_irq_wake(client->irq) < 0)
643 dev_err(pcf->dev, "IRQ %u cannot be enabled as wake-up source"
644 "in this hardware revision", client->irq);
645
646 ret = sysfs_create_group(&client->dev.kobj, &pcf_attr_group);
647 if (ret)
648 dev_err(pcf->dev, "error creating sysfs entries\n");
649
650 if (pdata->probe_done)
651 pdata->probe_done(pcf);
652
653 return 0;
654
655err:
656 kfree(pcf);
657 return ret;
658}
659
660static int __devexit pcf50633_remove(struct i2c_client *client)
661{
662 struct pcf50633 *pcf = i2c_get_clientdata(client);
663 int i;
664
665 free_irq(pcf->irq, pcf);
666
667 platform_device_unregister(pcf->input_pdev);
668 platform_device_unregister(pcf->rtc_pdev);
669 platform_device_unregister(pcf->mbc_pdev);
670 platform_device_unregister(pcf->adc_pdev);
671
672 for (i = 0; i < PCF50633_NUM_REGULATORS; i++)
673 platform_device_unregister(pcf->regulator_pdev[i]);
674
675 kfree(pcf);
676
677 return 0;
678}
679
680static struct i2c_device_id pcf50633_id_table[] = {
681 {"pcf50633", 0x73},
682};
683
684static struct i2c_driver pcf50633_driver = {
685 .driver = {
686 .name = "pcf50633",
687 .suspend = pcf50633_suspend,
688 .resume = pcf50633_resume,
689 },
690 .id_table = pcf50633_id_table,
691 .probe = pcf50633_probe,
692 .remove = __devexit_p(pcf50633_remove),
693};
694
695static int __init pcf50633_init(void)
696{
697 return i2c_add_driver(&pcf50633_driver);
698}
699
700static void __exit pcf50633_exit(void)
701{
702 i2c_del_driver(&pcf50633_driver);
703}
704
705MODULE_DESCRIPTION("I2C chip driver for NXP PCF50633 PMU");
706MODULE_AUTHOR("Harald Welte <laforge@openmoko.org>");
707MODULE_LICENSE("GPL");
708
709module_init(pcf50633_init);
710module_exit(pcf50633_exit);
diff --git a/drivers/mfd/pcf50633-gpio.c b/drivers/mfd/pcf50633-gpio.c
new file mode 100644
index 00000000000..2fa2eca5c9c
--- /dev/null
+++ b/drivers/mfd/pcf50633-gpio.c
@@ -0,0 +1,118 @@
1/* NXP PCF50633 GPIO Driver
2 *
3 * (C) 2006-2008 by Openmoko, Inc.
4 * Author: Balaji Rao <balajirrao@openmoko.org>
5 * All rights reserved.
6 *
7 * Broken down from monstrous PCF50633 driver mainly by
8 * Harald Welte, Andy Green and Werner Almesberger
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 */
16
17#include <linux/kernel.h>
18
19#include <linux/mfd/pcf50633/core.h>
20#include <linux/mfd/pcf50633/gpio.h>
21
22enum pcf50633_regulator_id {
23 PCF50633_REGULATOR_AUTO,
24 PCF50633_REGULATOR_DOWN1,
25 PCF50633_REGULATOR_DOWN2,
26 PCF50633_REGULATOR_LDO1,
27 PCF50633_REGULATOR_LDO2,
28 PCF50633_REGULATOR_LDO3,
29 PCF50633_REGULATOR_LDO4,
30 PCF50633_REGULATOR_LDO5,
31 PCF50633_REGULATOR_LDO6,
32 PCF50633_REGULATOR_HCLDO,
33 PCF50633_REGULATOR_MEMLDO,
34};
35
36#define PCF50633_REG_AUTOOUT 0x1a
37#define PCF50633_REG_DOWN1OUT 0x1e
38#define PCF50633_REG_DOWN2OUT 0x22
39#define PCF50633_REG_MEMLDOOUT 0x26
40#define PCF50633_REG_LDO1OUT 0x2d
41#define PCF50633_REG_LDO2OUT 0x2f
42#define PCF50633_REG_LDO3OUT 0x31
43#define PCF50633_REG_LDO4OUT 0x33
44#define PCF50633_REG_LDO5OUT 0x35
45#define PCF50633_REG_LDO6OUT 0x37
46#define PCF50633_REG_HCLDOOUT 0x39
47
48static const u8 pcf50633_regulator_registers[PCF50633_NUM_REGULATORS] = {
49 [PCF50633_REGULATOR_AUTO] = PCF50633_REG_AUTOOUT,
50 [PCF50633_REGULATOR_DOWN1] = PCF50633_REG_DOWN1OUT,
51 [PCF50633_REGULATOR_DOWN2] = PCF50633_REG_DOWN2OUT,
52 [PCF50633_REGULATOR_MEMLDO] = PCF50633_REG_MEMLDOOUT,
53 [PCF50633_REGULATOR_LDO1] = PCF50633_REG_LDO1OUT,
54 [PCF50633_REGULATOR_LDO2] = PCF50633_REG_LDO2OUT,
55 [PCF50633_REGULATOR_LDO3] = PCF50633_REG_LDO3OUT,
56 [PCF50633_REGULATOR_LDO4] = PCF50633_REG_LDO4OUT,
57 [PCF50633_REGULATOR_LDO5] = PCF50633_REG_LDO5OUT,
58 [PCF50633_REGULATOR_LDO6] = PCF50633_REG_LDO6OUT,
59 [PCF50633_REGULATOR_HCLDO] = PCF50633_REG_HCLDOOUT,
60};
61
62int pcf50633_gpio_set(struct pcf50633 *pcf, int gpio, u8 val)
63{
64 u8 reg;
65
66 reg = gpio - PCF50633_GPIO1 + PCF50633_REG_GPIO1CFG;
67
68 return pcf50633_reg_set_bit_mask(pcf, reg, 0x07, val);
69}
70EXPORT_SYMBOL_GPL(pcf50633_gpio_set);
71
72u8 pcf50633_gpio_get(struct pcf50633 *pcf, int gpio)
73{
74 u8 reg, val;
75
76 reg = gpio - PCF50633_GPIO1 + PCF50633_REG_GPIO1CFG;
77 val = pcf50633_reg_read(pcf, reg) & 0x07;
78
79 return val;
80}
81EXPORT_SYMBOL_GPL(pcf50633_gpio_get);
82
83int pcf50633_gpio_invert_set(struct pcf50633 *pcf, int gpio, int invert)
84{
85 u8 val, reg;
86
87 reg = gpio - PCF50633_GPIO1 + PCF50633_REG_GPIO1CFG;
88 val = !!invert << 3;
89
90 return pcf50633_reg_set_bit_mask(pcf, reg, 1 << 3, val);
91}
92EXPORT_SYMBOL_GPL(pcf50633_gpio_invert_set);
93
94int pcf50633_gpio_invert_get(struct pcf50633 *pcf, int gpio)
95{
96 u8 reg, val;
97
98 reg = gpio - PCF50633_GPIO1 + PCF50633_REG_GPIO1CFG;
99 val = pcf50633_reg_read(pcf, reg);
100
101 return val & (1 << 3);
102}
103EXPORT_SYMBOL_GPL(pcf50633_gpio_invert_get);
104
105int pcf50633_gpio_power_supply_set(struct pcf50633 *pcf,
106 int gpio, int regulator, int on)
107{
108 u8 reg, val, mask;
109
110 /* the *ENA register is always one after the *OUT register */
111 reg = pcf50633_regulator_registers[regulator] + 1;
112
113 val = !!on << (gpio - PCF50633_GPIO1);
114 mask = 1 << (gpio - PCF50633_GPIO1);
115
116 return pcf50633_reg_set_bit_mask(pcf, reg, mask, val);
117}
118EXPORT_SYMBOL_GPL(pcf50633_gpio_power_supply_set);
diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c
index 170f9d47c2f..0e5761f1263 100644
--- a/drivers/mfd/sm501.c
+++ b/drivers/mfd/sm501.c
@@ -41,6 +41,7 @@ struct sm501_gpio_chip {
41 struct gpio_chip gpio; 41 struct gpio_chip gpio;
42 struct sm501_gpio *ourgpio; /* to get back to parent. */ 42 struct sm501_gpio *ourgpio; /* to get back to parent. */
43 void __iomem *regbase; 43 void __iomem *regbase;
44 void __iomem *control; /* address of control reg. */
44}; 45};
45 46
46struct sm501_gpio { 47struct sm501_gpio {
@@ -908,6 +909,25 @@ static int sm501_gpio_get(struct gpio_chip *chip, unsigned offset)
908 return result & 1UL; 909 return result & 1UL;
909} 910}
910 911
912static void sm501_gpio_ensure_gpio(struct sm501_gpio_chip *smchip,
913 unsigned long bit)
914{
915 unsigned long ctrl;
916
917 /* check and modify if this pin is not set as gpio. */
918
919 if (readl(smchip->control) & bit) {
920 dev_info(sm501_gpio_to_dev(smchip->ourgpio)->dev,
921 "changing mode of gpio, bit %08lx\n", bit);
922
923 ctrl = readl(smchip->control);
924 ctrl &= ~bit;
925 writel(ctrl, smchip->control);
926
927 sm501_sync_regs(sm501_gpio_to_dev(smchip->ourgpio));
928 }
929}
930
911static void sm501_gpio_set(struct gpio_chip *chip, unsigned offset, int value) 931static void sm501_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
912 932
913{ 933{
@@ -929,6 +949,8 @@ static void sm501_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
929 writel(val, regs); 949 writel(val, regs);
930 950
931 sm501_sync_regs(sm501_gpio_to_dev(smgpio)); 951 sm501_sync_regs(sm501_gpio_to_dev(smgpio));
952 sm501_gpio_ensure_gpio(smchip, bit);
953
932 spin_unlock_irqrestore(&smgpio->lock, save); 954 spin_unlock_irqrestore(&smgpio->lock, save);
933} 955}
934 956
@@ -941,8 +963,8 @@ static int sm501_gpio_input(struct gpio_chip *chip, unsigned offset)
941 unsigned long save; 963 unsigned long save;
942 unsigned long ddr; 964 unsigned long ddr;
943 965
944 dev_info(sm501_gpio_to_dev(smgpio)->dev, "%s(%p,%d)\n", 966 dev_dbg(sm501_gpio_to_dev(smgpio)->dev, "%s(%p,%d)\n",
945 __func__, chip, offset); 967 __func__, chip, offset);
946 968
947 spin_lock_irqsave(&smgpio->lock, save); 969 spin_lock_irqsave(&smgpio->lock, save);
948 970
@@ -950,6 +972,8 @@ static int sm501_gpio_input(struct gpio_chip *chip, unsigned offset)
950 writel(ddr & ~bit, regs + SM501_GPIO_DDR_LOW); 972 writel(ddr & ~bit, regs + SM501_GPIO_DDR_LOW);
951 973
952 sm501_sync_regs(sm501_gpio_to_dev(smgpio)); 974 sm501_sync_regs(sm501_gpio_to_dev(smgpio));
975 sm501_gpio_ensure_gpio(smchip, bit);
976
953 spin_unlock_irqrestore(&smgpio->lock, save); 977 spin_unlock_irqrestore(&smgpio->lock, save);
954 978
955 return 0; 979 return 0;
@@ -1012,9 +1036,11 @@ static int __devinit sm501_gpio_register_chip(struct sm501_devdata *sm,
1012 if (base > 0) 1036 if (base > 0)
1013 base += 32; 1037 base += 32;
1014 chip->regbase = gpio->regs + SM501_GPIO_DATA_HIGH; 1038 chip->regbase = gpio->regs + SM501_GPIO_DATA_HIGH;
1039 chip->control = sm->regs + SM501_GPIO63_32_CONTROL;
1015 gchip->label = "SM501-HIGH"; 1040 gchip->label = "SM501-HIGH";
1016 } else { 1041 } else {
1017 chip->regbase = gpio->regs + SM501_GPIO_DATA_LOW; 1042 chip->regbase = gpio->regs + SM501_GPIO_DATA_LOW;
1043 chip->control = sm->regs + SM501_GPIO31_0_CONTROL;
1018 gchip->label = "SM501-LOW"; 1044 gchip->label = "SM501-LOW";
1019 } 1045 }
1020 1046
diff --git a/drivers/mfd/twl4030-core.c b/drivers/mfd/twl4030-core.c
index b59c385cbc1..e7ab0035d30 100644
--- a/drivers/mfd/twl4030-core.c
+++ b/drivers/mfd/twl4030-core.c
@@ -38,6 +38,9 @@
38#include <linux/i2c.h> 38#include <linux/i2c.h>
39#include <linux/i2c/twl4030.h> 39#include <linux/i2c/twl4030.h>
40 40
41#ifdef CONFIG_ARM
42#include <mach/cpu.h>
43#endif
41 44
42/* 45/*
43 * The TWL4030 "Triton 2" is one of a family of a multi-function "Power 46 * The TWL4030 "Triton 2" is one of a family of a multi-function "Power
@@ -646,7 +649,7 @@ static inline int __init unprotect_pm_master(void)
646 return e; 649 return e;
647} 650}
648 651
649static void __init clocks_init(void) 652static void __init clocks_init(struct device *dev)
650{ 653{
651 int e = 0; 654 int e = 0;
652 struct clk *osc; 655 struct clk *osc;
@@ -655,9 +658,9 @@ static void __init clocks_init(void)
655 658
656#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) 659#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
657 if (cpu_is_omap2430()) 660 if (cpu_is_omap2430())
658 osc = clk_get(NULL, "osc_ck"); 661 osc = clk_get(dev, "osc_ck");
659 else 662 else
660 osc = clk_get(NULL, "osc_sys_ck"); 663 osc = clk_get(dev, "osc_sys_ck");
661 664
662 if (IS_ERR(osc)) { 665 if (IS_ERR(osc)) {
663 printk(KERN_WARNING "Skipping twl4030 internal clock init and " 666 printk(KERN_WARNING "Skipping twl4030 internal clock init and "
@@ -773,7 +776,7 @@ twl4030_probe(struct i2c_client *client, const struct i2c_device_id *id)
773 inuse = true; 776 inuse = true;
774 777
775 /* setup clock framework */ 778 /* setup clock framework */
776 clocks_init(); 779 clocks_init(&client->dev);
777 780
778 /* Maybe init the T2 Interrupt subsystem */ 781 /* Maybe init the T2 Interrupt subsystem */
779 if (client->irq 782 if (client->irq
diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
index 89218f7cfaa..6576170de96 100644
--- a/drivers/misc/sgi-xp/xpc_main.c
+++ b/drivers/misc/sgi-xp/xpc_main.c
@@ -318,7 +318,7 @@ xpc_hb_checker(void *ignore)
318 318
319 /* this thread was marked active by xpc_hb_init() */ 319 /* this thread was marked active by xpc_hb_init() */
320 320
321 set_cpus_allowed_ptr(current, &cpumask_of_cpu(XPC_HB_CHECK_CPU)); 321 set_cpus_allowed_ptr(current, cpumask_of(XPC_HB_CHECK_CPU));
322 322
323 /* set our heartbeating to other partitions into motion */ 323 /* set our heartbeating to other partitions into motion */
324 xpc_hb_check_timeout = jiffies + (xpc_hb_check_interval * HZ); 324 xpc_hb_check_timeout = jiffies + (xpc_hb_check_interval * HZ);
diff --git a/drivers/net/3c503.c b/drivers/net/3c503.c
index c092c392922..5b91a85fe10 100644
--- a/drivers/net/3c503.c
+++ b/drivers/net/3c503.c
@@ -177,6 +177,7 @@ static const struct net_device_ops el2_netdev_ops = {
177 .ndo_get_stats = eip_get_stats, 177 .ndo_get_stats = eip_get_stats,
178 .ndo_set_multicast_list = eip_set_multicast_list, 178 .ndo_set_multicast_list = eip_set_multicast_list,
179 .ndo_validate_addr = eth_validate_addr, 179 .ndo_validate_addr = eth_validate_addr,
180 .ndo_set_mac_address = eth_mac_addr,
180 .ndo_change_mtu = eth_change_mtu, 181 .ndo_change_mtu = eth_change_mtu,
181#ifdef CONFIG_NET_POLL_CONTROLLER 182#ifdef CONFIG_NET_POLL_CONTROLLER
182 .ndo_poll_controller = eip_poll, 183 .ndo_poll_controller = eip_poll,
diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c
index 665e7fdf27a..cdbbb6226fc 100644
--- a/drivers/net/3c59x.c
+++ b/drivers/net/3c59x.c
@@ -3109,6 +3109,8 @@ static void acpi_set_WOL(struct net_device *dev)
3109 struct vortex_private *vp = netdev_priv(dev); 3109 struct vortex_private *vp = netdev_priv(dev);
3110 void __iomem *ioaddr = vp->ioaddr; 3110 void __iomem *ioaddr = vp->ioaddr;
3111 3111
3112 device_set_wakeup_enable(vp->gendev, vp->enable_wol);
3113
3112 if (vp->enable_wol) { 3114 if (vp->enable_wol) {
3113 /* Power up on: 1==Downloaded Filter, 2==Magic Packets, 4==Link Status. */ 3115 /* Power up on: 1==Downloaded Filter, 2==Magic Packets, 4==Link Status. */
3114 EL3WINDOW(7); 3116 EL3WINDOW(7);
diff --git a/drivers/net/8139cp.c b/drivers/net/8139cp.c
index dd7ac8290ae..4e19ae3ce6b 100644
--- a/drivers/net/8139cp.c
+++ b/drivers/net/8139cp.c
@@ -1821,6 +1821,7 @@ static const struct net_device_ops cp_netdev_ops = {
1821 .ndo_open = cp_open, 1821 .ndo_open = cp_open,
1822 .ndo_stop = cp_close, 1822 .ndo_stop = cp_close,
1823 .ndo_validate_addr = eth_validate_addr, 1823 .ndo_validate_addr = eth_validate_addr,
1824 .ndo_set_mac_address = eth_mac_addr,
1824 .ndo_set_multicast_list = cp_set_rx_mode, 1825 .ndo_set_multicast_list = cp_set_rx_mode,
1825 .ndo_get_stats = cp_get_stats, 1826 .ndo_get_stats = cp_get_stats,
1826 .ndo_do_ioctl = cp_ioctl, 1827 .ndo_do_ioctl = cp_ioctl,
@@ -1832,6 +1833,7 @@ static const struct net_device_ops cp_netdev_ops = {
1832#ifdef BROKEN 1833#ifdef BROKEN
1833 .ndo_change_mtu = cp_change_mtu, 1834 .ndo_change_mtu = cp_change_mtu,
1834#endif 1835#endif
1836
1835#ifdef CONFIG_NET_POLL_CONTROLLER 1837#ifdef CONFIG_NET_POLL_CONTROLLER
1836 .ndo_poll_controller = cp_poll_controller, 1838 .ndo_poll_controller = cp_poll_controller,
1837#endif 1839#endif
diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c
index fe370f80579..a5b24202d56 100644
--- a/drivers/net/8139too.c
+++ b/drivers/net/8139too.c
@@ -917,6 +917,7 @@ static const struct net_device_ops rtl8139_netdev_ops = {
917 .ndo_stop = rtl8139_close, 917 .ndo_stop = rtl8139_close,
918 .ndo_get_stats = rtl8139_get_stats, 918 .ndo_get_stats = rtl8139_get_stats,
919 .ndo_validate_addr = eth_validate_addr, 919 .ndo_validate_addr = eth_validate_addr,
920 .ndo_set_mac_address = eth_mac_addr,
920 .ndo_start_xmit = rtl8139_start_xmit, 921 .ndo_start_xmit = rtl8139_start_xmit,
921 .ndo_set_multicast_list = rtl8139_set_rx_mode, 922 .ndo_set_multicast_list = rtl8139_set_rx_mode,
922 .ndo_do_ioctl = netdev_ioctl, 923 .ndo_do_ioctl = netdev_ioctl,
@@ -924,7 +925,6 @@ static const struct net_device_ops rtl8139_netdev_ops = {
924#ifdef CONFIG_NET_POLL_CONTROLLER 925#ifdef CONFIG_NET_POLL_CONTROLLER
925 .ndo_poll_controller = rtl8139_poll_controller, 926 .ndo_poll_controller = rtl8139_poll_controller,
926#endif 927#endif
927
928}; 928};
929 929
930static int __devinit rtl8139_init_one (struct pci_dev *pdev, 930static int __devinit rtl8139_init_one (struct pci_dev *pdev,
diff --git a/drivers/net/8390.c b/drivers/net/8390.c
index fbe609a51e0..ec3e22e6306 100644
--- a/drivers/net/8390.c
+++ b/drivers/net/8390.c
@@ -63,6 +63,7 @@ const struct net_device_ops ei_netdev_ops = {
63 .ndo_get_stats = ei_get_stats, 63 .ndo_get_stats = ei_get_stats,
64 .ndo_set_multicast_list = ei_set_multicast_list, 64 .ndo_set_multicast_list = ei_set_multicast_list,
65 .ndo_validate_addr = eth_validate_addr, 65 .ndo_validate_addr = eth_validate_addr,
66 .ndo_set_mac_address = eth_mac_addr,
66 .ndo_change_mtu = eth_change_mtu, 67 .ndo_change_mtu = eth_change_mtu,
67#ifdef CONFIG_NET_POLL_CONTROLLER 68#ifdef CONFIG_NET_POLL_CONTROLLER
68 .ndo_poll_controller = ei_poll, 69 .ndo_poll_controller = ei_poll,
diff --git a/drivers/net/8390p.c b/drivers/net/8390p.c
index ee70b358a81..da863c91d1d 100644
--- a/drivers/net/8390p.c
+++ b/drivers/net/8390p.c
@@ -68,6 +68,7 @@ const struct net_device_ops eip_netdev_ops = {
68 .ndo_get_stats = eip_get_stats, 68 .ndo_get_stats = eip_get_stats,
69 .ndo_set_multicast_list = eip_set_multicast_list, 69 .ndo_set_multicast_list = eip_set_multicast_list,
70 .ndo_validate_addr = eth_validate_addr, 70 .ndo_validate_addr = eth_validate_addr,
71 .ndo_set_mac_address = eth_mac_addr,
71 .ndo_change_mtu = eth_change_mtu, 72 .ndo_change_mtu = eth_change_mtu,
72#ifdef CONFIG_NET_POLL_CONTROLLER 73#ifdef CONFIG_NET_POLL_CONTROLLER
73 .ndo_poll_controller = eip_poll, 74 .ndo_poll_controller = eip_poll,
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 65afda4a62d..9fe8cb7d43a 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -1600,7 +1600,7 @@ config 8139_OLD_RX_RESET
1600 old RX-reset behavior. If unsure, say N. 1600 old RX-reset behavior. If unsure, say N.
1601 1601
1602config R6040 1602config R6040
1603 tristate "RDC R6040 Fast Ethernet Adapter support (EXPERIMENTAL)" 1603 tristate "RDC R6040 Fast Ethernet Adapter support"
1604 depends on NET_PCI && PCI 1604 depends on NET_PCI && PCI
1605 select CRC32 1605 select CRC32
1606 select MII 1606 select MII
diff --git a/drivers/net/acenic.c b/drivers/net/acenic.c
index 5b396ff6c83..9589d620639 100644
--- a/drivers/net/acenic.c
+++ b/drivers/net/acenic.c
@@ -460,6 +460,7 @@ static const struct net_device_ops ace_netdev_ops = {
460 .ndo_get_stats = ace_get_stats, 460 .ndo_get_stats = ace_get_stats,
461 .ndo_start_xmit = ace_start_xmit, 461 .ndo_start_xmit = ace_start_xmit,
462 .ndo_set_multicast_list = ace_set_multicast_list, 462 .ndo_set_multicast_list = ace_set_multicast_list,
463 .ndo_validate_addr = eth_validate_addr,
463 .ndo_set_mac_address = ace_set_mac_addr, 464 .ndo_set_mac_address = ace_set_mac_addr,
464 .ndo_change_mtu = ace_change_mtu, 465 .ndo_change_mtu = ace_change_mtu,
465#if ACENIC_DO_VLAN 466#if ACENIC_DO_VLAN
diff --git a/drivers/net/arm/etherh.c b/drivers/net/arm/etherh.c
index 6278606d104..745ac188bab 100644
--- a/drivers/net/arm/etherh.c
+++ b/drivers/net/arm/etherh.c
@@ -646,6 +646,7 @@ static const struct net_device_ops etherh_netdev_ops = {
646 .ndo_get_stats = ei_get_stats, 646 .ndo_get_stats = ei_get_stats,
647 .ndo_set_multicast_list = ei_set_multicast_list, 647 .ndo_set_multicast_list = ei_set_multicast_list,
648 .ndo_validate_addr = eth_validate_addr, 648 .ndo_validate_addr = eth_validate_addr,
649 .ndo_set_mac_addr = eth_set_mac_addr,
649 .ndo_change_mtu = eth_change_mtu, 650 .ndo_change_mtu = eth_change_mtu,
650#ifdef CONFIG_NET_POLL_CONTROLLER 651#ifdef CONFIG_NET_POLL_CONTROLLER
651 .ndo_poll_controller = ei_poll, 652 .ndo_poll_controller = ei_poll,
diff --git a/drivers/net/arm/ks8695net.c b/drivers/net/arm/ks8695net.c
index 9ad22d1b00f..1cf2f949c0b 100644
--- a/drivers/net/arm/ks8695net.c
+++ b/drivers/net/arm/ks8695net.c
@@ -1357,6 +1357,7 @@ static const struct net_device_ops ks8695_netdev_ops = {
1357 .ndo_start_xmit = ks8695_start_xmit, 1357 .ndo_start_xmit = ks8695_start_xmit,
1358 .ndo_tx_timeout = ks8695_timeout, 1358 .ndo_tx_timeout = ks8695_timeout,
1359 .ndo_set_mac_address = ks8695_set_mac, 1359 .ndo_set_mac_address = ks8695_set_mac,
1360 .ndo_validate_addr = eth_validate_addr,
1360 .ndo_set_multicast_list = ks8695_set_multicast, 1361 .ndo_set_multicast_list = ks8695_set_multicast,
1361}; 1362};
1362 1363
diff --git a/drivers/net/b44.c b/drivers/net/b44.c
index 6926ebedfdc..5ae131c147f 100644
--- a/drivers/net/b44.c
+++ b/drivers/net/b44.c
@@ -73,8 +73,8 @@
73 (BP)->tx_cons - (BP)->tx_prod - TX_RING_GAP(BP)) 73 (BP)->tx_cons - (BP)->tx_prod - TX_RING_GAP(BP))
74#define NEXT_TX(N) (((N) + 1) & (B44_TX_RING_SIZE - 1)) 74#define NEXT_TX(N) (((N) + 1) & (B44_TX_RING_SIZE - 1))
75 75
76#define RX_PKT_OFFSET 30 76#define RX_PKT_OFFSET (RX_HEADER_LEN + 2)
77#define RX_PKT_BUF_SZ (1536 + RX_PKT_OFFSET + 64) 77#define RX_PKT_BUF_SZ (1536 + RX_PKT_OFFSET)
78 78
79/* minimum number of free TX descriptors required to wake up TX process */ 79/* minimum number of free TX descriptors required to wake up TX process */
80#define B44_TX_WAKEUP_THRESH (B44_TX_RING_SIZE / 4) 80#define B44_TX_WAKEUP_THRESH (B44_TX_RING_SIZE / 4)
@@ -682,7 +682,6 @@ static int b44_alloc_rx_skb(struct b44 *bp, int src_idx, u32 dest_idx_unmasked)
682 } 682 }
683 683
684 rh = (struct rx_header *) skb->data; 684 rh = (struct rx_header *) skb->data;
685 skb_reserve(skb, RX_PKT_OFFSET);
686 685
687 rh->len = 0; 686 rh->len = 0;
688 rh->flags = 0; 687 rh->flags = 0;
@@ -693,13 +692,13 @@ static int b44_alloc_rx_skb(struct b44 *bp, int src_idx, u32 dest_idx_unmasked)
693 if (src_map != NULL) 692 if (src_map != NULL)
694 src_map->skb = NULL; 693 src_map->skb = NULL;
695 694
696 ctrl = (DESC_CTRL_LEN & (RX_PKT_BUF_SZ - RX_PKT_OFFSET)); 695 ctrl = (DESC_CTRL_LEN & RX_PKT_BUF_SZ);
697 if (dest_idx == (B44_RX_RING_SIZE - 1)) 696 if (dest_idx == (B44_RX_RING_SIZE - 1))
698 ctrl |= DESC_CTRL_EOT; 697 ctrl |= DESC_CTRL_EOT;
699 698
700 dp = &bp->rx_ring[dest_idx]; 699 dp = &bp->rx_ring[dest_idx];
701 dp->ctrl = cpu_to_le32(ctrl); 700 dp->ctrl = cpu_to_le32(ctrl);
702 dp->addr = cpu_to_le32((u32) mapping + RX_PKT_OFFSET + bp->dma_offset); 701 dp->addr = cpu_to_le32((u32) mapping + bp->dma_offset);
703 702
704 if (bp->flags & B44_FLAG_RX_RING_HACK) 703 if (bp->flags & B44_FLAG_RX_RING_HACK)
705 b44_sync_dma_desc_for_device(bp->sdev, bp->rx_ring_dma, 704 b44_sync_dma_desc_for_device(bp->sdev, bp->rx_ring_dma,
@@ -809,8 +808,8 @@ static int b44_rx(struct b44 *bp, int budget)
809 ssb_dma_unmap_single(bp->sdev, map, 808 ssb_dma_unmap_single(bp->sdev, map,
810 skb_size, DMA_FROM_DEVICE); 809 skb_size, DMA_FROM_DEVICE);
811 /* Leave out rx_header */ 810 /* Leave out rx_header */
812 skb_put(skb, len + RX_PKT_OFFSET); 811 skb_put(skb, len + RX_PKT_OFFSET);
813 skb_pull(skb, RX_PKT_OFFSET); 812 skb_pull(skb, RX_PKT_OFFSET);
814 } else { 813 } else {
815 struct sk_buff *copy_skb; 814 struct sk_buff *copy_skb;
816 815
diff --git a/drivers/net/cxgb3/adapter.h b/drivers/net/cxgb3/adapter.h
index 5b346f9eaa8..a89d8cc5120 100644
--- a/drivers/net/cxgb3/adapter.h
+++ b/drivers/net/cxgb3/adapter.h
@@ -50,12 +50,17 @@ struct vlan_group;
50struct adapter; 50struct adapter;
51struct sge_qset; 51struct sge_qset;
52 52
53enum { /* rx_offload flags */
54 T3_RX_CSUM = 1 << 0,
55 T3_LRO = 1 << 1,
56};
57
53struct port_info { 58struct port_info {
54 struct adapter *adapter; 59 struct adapter *adapter;
55 struct vlan_group *vlan_grp; 60 struct vlan_group *vlan_grp;
56 struct sge_qset *qs; 61 struct sge_qset *qs;
57 u8 port_id; 62 u8 port_id;
58 u8 rx_csum_offload; 63 u8 rx_offload;
59 u8 nqsets; 64 u8 nqsets;
60 u8 first_qset; 65 u8 first_qset;
61 struct cphy phy; 66 struct cphy phy;
diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c
index 2847f947499..0089746b8d0 100644
--- a/drivers/net/cxgb3/cxgb3_main.c
+++ b/drivers/net/cxgb3/cxgb3_main.c
@@ -546,7 +546,7 @@ static int setup_sge_qsets(struct adapter *adap)
546 pi->qs = &adap->sge.qs[pi->first_qset]; 546 pi->qs = &adap->sge.qs[pi->first_qset];
547 for (j = pi->first_qset; j < pi->first_qset + pi->nqsets; 547 for (j = pi->first_qset; j < pi->first_qset + pi->nqsets;
548 ++j, ++qset_idx) { 548 ++j, ++qset_idx) {
549 set_qset_lro(dev, qset_idx, pi->rx_csum_offload); 549 set_qset_lro(dev, qset_idx, pi->rx_offload & T3_LRO);
550 err = t3_sge_alloc_qset(adap, qset_idx, 1, 550 err = t3_sge_alloc_qset(adap, qset_idx, 1,
551 (adap->flags & USING_MSIX) ? qset_idx + 1 : 551 (adap->flags & USING_MSIX) ? qset_idx + 1 :
552 irq_idx, 552 irq_idx,
@@ -1657,17 +1657,19 @@ static u32 get_rx_csum(struct net_device *dev)
1657{ 1657{
1658 struct port_info *p = netdev_priv(dev); 1658 struct port_info *p = netdev_priv(dev);
1659 1659
1660 return p->rx_csum_offload; 1660 return p->rx_offload & T3_RX_CSUM;
1661} 1661}
1662 1662
1663static int set_rx_csum(struct net_device *dev, u32 data) 1663static int set_rx_csum(struct net_device *dev, u32 data)
1664{ 1664{
1665 struct port_info *p = netdev_priv(dev); 1665 struct port_info *p = netdev_priv(dev);
1666 1666
1667 p->rx_csum_offload = data; 1667 if (data) {
1668 if (!data) { 1668 p->rx_offload |= T3_RX_CSUM;
1669 } else {
1669 int i; 1670 int i;
1670 1671
1672 p->rx_offload &= ~(T3_RX_CSUM | T3_LRO);
1671 for (i = p->first_qset; i < p->first_qset + p->nqsets; i++) 1673 for (i = p->first_qset; i < p->first_qset + p->nqsets; i++)
1672 set_qset_lro(dev, i, 0); 1674 set_qset_lro(dev, i, 0);
1673 } 1675 }
@@ -1830,15 +1832,18 @@ static int cxgb3_set_flags(struct net_device *dev, u32 data)
1830 int i; 1832 int i;
1831 1833
1832 if (data & ETH_FLAG_LRO) { 1834 if (data & ETH_FLAG_LRO) {
1833 if (!pi->rx_csum_offload) 1835 if (!(pi->rx_offload & T3_RX_CSUM))
1834 return -EINVAL; 1836 return -EINVAL;
1835 1837
1838 pi->rx_offload |= T3_LRO;
1836 for (i = pi->first_qset; i < pi->first_qset + pi->nqsets; i++) 1839 for (i = pi->first_qset; i < pi->first_qset + pi->nqsets; i++)
1837 set_qset_lro(dev, i, 1); 1840 set_qset_lro(dev, i, 1);
1838 1841
1839 } else 1842 } else {
1843 pi->rx_offload &= ~T3_LRO;
1840 for (i = pi->first_qset; i < pi->first_qset + pi->nqsets; i++) 1844 for (i = pi->first_qset; i < pi->first_qset + pi->nqsets; i++)
1841 set_qset_lro(dev, i, 0); 1845 set_qset_lro(dev, i, 0);
1846 }
1842 1847
1843 return 0; 1848 return 0;
1844} 1849}
@@ -1926,7 +1931,7 @@ static int cxgb_extension_ioctl(struct net_device *dev, void __user *useraddr)
1926 pi = adap2pinfo(adapter, i); 1931 pi = adap2pinfo(adapter, i);
1927 if (t.qset_idx >= pi->first_qset && 1932 if (t.qset_idx >= pi->first_qset &&
1928 t.qset_idx < pi->first_qset + pi->nqsets && 1933 t.qset_idx < pi->first_qset + pi->nqsets &&
1929 !pi->rx_csum_offload) 1934 !(pi->rx_offload & T3_RX_CSUM))
1930 return -EINVAL; 1935 return -EINVAL;
1931 } 1936 }
1932 1937
@@ -2946,7 +2951,7 @@ static int __devinit init_one(struct pci_dev *pdev,
2946 adapter->port[i] = netdev; 2951 adapter->port[i] = netdev;
2947 pi = netdev_priv(netdev); 2952 pi = netdev_priv(netdev);
2948 pi->adapter = adapter; 2953 pi->adapter = adapter;
2949 pi->rx_csum_offload = 1; 2954 pi->rx_offload = T3_RX_CSUM | T3_LRO;
2950 pi->port_id = i; 2955 pi->port_id = i;
2951 netif_carrier_off(netdev); 2956 netif_carrier_off(netdev);
2952 netif_tx_stop_all_queues(netdev); 2957 netif_tx_stop_all_queues(netdev);
@@ -2955,6 +2960,7 @@ static int __devinit init_one(struct pci_dev *pdev,
2955 netdev->mem_end = mmio_start + mmio_len - 1; 2960 netdev->mem_end = mmio_start + mmio_len - 1;
2956 netdev->features |= NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO; 2961 netdev->features |= NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO;
2957 netdev->features |= NETIF_F_LLTX; 2962 netdev->features |= NETIF_F_LLTX;
2963 netdev->features |= NETIF_F_LRO;
2958 if (pci_using_dac) 2964 if (pci_using_dac)
2959 netdev->features |= NETIF_F_HIGHDMA; 2965 netdev->features |= NETIF_F_HIGHDMA;
2960 2966
diff --git a/drivers/net/cxgb3/sge.c b/drivers/net/cxgb3/sge.c
index 6c641a88947..14f9fb3e879 100644
--- a/drivers/net/cxgb3/sge.c
+++ b/drivers/net/cxgb3/sge.c
@@ -1932,7 +1932,7 @@ static void rx_eth(struct adapter *adap, struct sge_rspq *rq,
1932 skb_pull(skb, sizeof(*p) + pad); 1932 skb_pull(skb, sizeof(*p) + pad);
1933 skb->protocol = eth_type_trans(skb, adap->port[p->iff]); 1933 skb->protocol = eth_type_trans(skb, adap->port[p->iff]);
1934 pi = netdev_priv(skb->dev); 1934 pi = netdev_priv(skb->dev);
1935 if (pi->rx_csum_offload && p->csum_valid && p->csum == htons(0xffff) && 1935 if ((pi->rx_offload & T3_RX_CSUM) && p->csum_valid && p->csum == htons(0xffff) &&
1936 !p->fragment) { 1936 !p->fragment) {
1937 qs->port_stats[SGE_PSTAT_RX_CSUM_GOOD]++; 1937 qs->port_stats[SGE_PSTAT_RX_CSUM_GOOD]++;
1938 skb->ip_summed = CHECKSUM_UNNECESSARY; 1938 skb->ip_summed = CHECKSUM_UNNECESSARY;
diff --git a/drivers/net/e1000e/ich8lan.c b/drivers/net/e1000e/ich8lan.c
index f2a5963b5a9..e415e81ecd3 100644
--- a/drivers/net/e1000e/ich8lan.c
+++ b/drivers/net/e1000e/ich8lan.c
@@ -390,7 +390,8 @@ static s32 e1000_get_variants_ich8lan(struct e1000_adapter *adapter)
390} 390}
391 391
392static DEFINE_MUTEX(nvm_mutex); 392static DEFINE_MUTEX(nvm_mutex);
393static pid_t nvm_owner = -1; 393static pid_t nvm_owner_pid = -1;
394static char nvm_owner_name[TASK_COMM_LEN] = "";
394 395
395/** 396/**
396 * e1000_acquire_swflag_ich8lan - Acquire software control flag 397 * e1000_acquire_swflag_ich8lan - Acquire software control flag
@@ -408,11 +409,15 @@ static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw)
408 might_sleep(); 409 might_sleep();
409 410
410 if (!mutex_trylock(&nvm_mutex)) { 411 if (!mutex_trylock(&nvm_mutex)) {
411 WARN(1, KERN_ERR "e1000e mutex contention. Owned by pid %d\n", 412 WARN(1, KERN_ERR "e1000e mutex contention. Owned by process "
412 nvm_owner); 413 "%s (pid %d), required by process %s (pid %d)\n",
414 nvm_owner_name, nvm_owner_pid,
415 current->comm, current->pid);
416
413 mutex_lock(&nvm_mutex); 417 mutex_lock(&nvm_mutex);
414 } 418 }
415 nvm_owner = current->pid; 419 nvm_owner_pid = current->pid;
420 strncpy(nvm_owner_name, current->comm, TASK_COMM_LEN);
416 421
417 while (timeout) { 422 while (timeout) {
418 extcnf_ctrl = er32(EXTCNF_CTRL); 423 extcnf_ctrl = er32(EXTCNF_CTRL);
@@ -430,7 +435,8 @@ static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw)
430 hw_dbg(hw, "FW or HW has locked the resource for too long.\n"); 435 hw_dbg(hw, "FW or HW has locked the resource for too long.\n");
431 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG; 436 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
432 ew32(EXTCNF_CTRL, extcnf_ctrl); 437 ew32(EXTCNF_CTRL, extcnf_ctrl);
433 nvm_owner = -1; 438 nvm_owner_pid = -1;
439 strcpy(nvm_owner_name, "");
434 mutex_unlock(&nvm_mutex); 440 mutex_unlock(&nvm_mutex);
435 return -E1000_ERR_CONFIG; 441 return -E1000_ERR_CONFIG;
436 } 442 }
@@ -454,7 +460,8 @@ static void e1000_release_swflag_ich8lan(struct e1000_hw *hw)
454 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG; 460 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
455 ew32(EXTCNF_CTRL, extcnf_ctrl); 461 ew32(EXTCNF_CTRL, extcnf_ctrl);
456 462
457 nvm_owner = -1; 463 nvm_owner_pid = -1;
464 strcpy(nvm_owner_name, "");
458 mutex_unlock(&nvm_mutex); 465 mutex_unlock(&nvm_mutex);
459} 466}
460 467
diff --git a/drivers/net/e2100.c b/drivers/net/e2100.c
index 20eb05cddb8..b07ba1924de 100644
--- a/drivers/net/e2100.c
+++ b/drivers/net/e2100.c
@@ -169,6 +169,7 @@ static const struct net_device_ops e21_netdev_ops = {
169 .ndo_get_stats = ei_get_stats, 169 .ndo_get_stats = ei_get_stats,
170 .ndo_set_multicast_list = ei_set_multicast_list, 170 .ndo_set_multicast_list = ei_set_multicast_list,
171 .ndo_validate_addr = eth_validate_addr, 171 .ndo_validate_addr = eth_validate_addr,
172 .ndo_set_mac_address = eth_mac_addr,
172 .ndo_change_mtu = eth_change_mtu, 173 .ndo_change_mtu = eth_change_mtu,
173#ifdef CONFIG_NET_POLL_CONTROLLER 174#ifdef CONFIG_NET_POLL_CONTROLLER
174 .ndo_poll_controller = ei_poll, 175 .ndo_poll_controller = ei_poll,
diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c
index d039e16f276..7d60551d538 100644
--- a/drivers/net/enic/enic_main.c
+++ b/drivers/net/enic/enic_main.c
@@ -1599,6 +1599,7 @@ static const struct net_device_ops enic_netdev_ops = {
1599 .ndo_start_xmit = enic_hard_start_xmit, 1599 .ndo_start_xmit = enic_hard_start_xmit,
1600 .ndo_get_stats = enic_get_stats, 1600 .ndo_get_stats = enic_get_stats,
1601 .ndo_validate_addr = eth_validate_addr, 1601 .ndo_validate_addr = eth_validate_addr,
1602 .ndo_set_mac_address = eth_mac_addr,
1602 .ndo_set_multicast_list = enic_set_multicast_list, 1603 .ndo_set_multicast_list = enic_set_multicast_list,
1603 .ndo_change_mtu = enic_change_mtu, 1604 .ndo_change_mtu = enic_change_mtu,
1604 .ndo_vlan_rx_register = enic_vlan_rx_register, 1605 .ndo_vlan_rx_register = enic_vlan_rx_register,
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
index 5b68dc20168..5b910cf6374 100644
--- a/drivers/net/forcedeth.c
+++ b/drivers/net/forcedeth.c
@@ -13,7 +13,7 @@
13 * Copyright (C) 2004 Andrew de Quincey (wol support) 13 * Copyright (C) 2004 Andrew de Quincey (wol support)
14 * Copyright (C) 2004 Carl-Daniel Hailfinger (invalid MAC handling, insane 14 * Copyright (C) 2004 Carl-Daniel Hailfinger (invalid MAC handling, insane
15 * IRQ rate fixes, bigendian fixes, cleanups, verification) 15 * IRQ rate fixes, bigendian fixes, cleanups, verification)
16 * Copyright (c) 2004,2005,2006,2007,2008 NVIDIA Corporation 16 * Copyright (c) 2004,2005,2006,2007,2008,2009 NVIDIA Corporation
17 * 17 *
18 * This program is free software; you can redistribute it and/or modify 18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by 19 * it under the terms of the GNU General Public License as published by
@@ -39,7 +39,7 @@
39 * DEV_NEED_TIMERIRQ will not harm you on sane hardware, only generating a few 39 * DEV_NEED_TIMERIRQ will not harm you on sane hardware, only generating a few
40 * superfluous timer interrupts from the nic. 40 * superfluous timer interrupts from the nic.
41 */ 41 */
42#define FORCEDETH_VERSION "0.61" 42#define FORCEDETH_VERSION "0.62"
43#define DRV_NAME "forcedeth" 43#define DRV_NAME "forcedeth"
44 44
45#include <linux/module.h> 45#include <linux/module.h>
@@ -2096,14 +2096,15 @@ static int nv_start_xmit(struct sk_buff *skb, struct net_device *dev)
2096 ((skb_shinfo(skb)->frags[i].size & (NV_TX2_TSO_MAX_SIZE-1)) ? 1 : 0); 2096 ((skb_shinfo(skb)->frags[i].size & (NV_TX2_TSO_MAX_SIZE-1)) ? 1 : 0);
2097 } 2097 }
2098 2098
2099 spin_lock_irqsave(&np->lock, flags);
2099 empty_slots = nv_get_empty_tx_slots(np); 2100 empty_slots = nv_get_empty_tx_slots(np);
2100 if (unlikely(empty_slots <= entries)) { 2101 if (unlikely(empty_slots <= entries)) {
2101 spin_lock_irqsave(&np->lock, flags);
2102 netif_stop_queue(dev); 2102 netif_stop_queue(dev);
2103 np->tx_stop = 1; 2103 np->tx_stop = 1;
2104 spin_unlock_irqrestore(&np->lock, flags); 2104 spin_unlock_irqrestore(&np->lock, flags);
2105 return NETDEV_TX_BUSY; 2105 return NETDEV_TX_BUSY;
2106 } 2106 }
2107 spin_unlock_irqrestore(&np->lock, flags);
2107 2108
2108 start_tx = put_tx = np->put_tx.orig; 2109 start_tx = put_tx = np->put_tx.orig;
2109 2110
@@ -2214,14 +2215,15 @@ static int nv_start_xmit_optimized(struct sk_buff *skb, struct net_device *dev)
2214 ((skb_shinfo(skb)->frags[i].size & (NV_TX2_TSO_MAX_SIZE-1)) ? 1 : 0); 2215 ((skb_shinfo(skb)->frags[i].size & (NV_TX2_TSO_MAX_SIZE-1)) ? 1 : 0);
2215 } 2216 }
2216 2217
2218 spin_lock_irqsave(&np->lock, flags);
2217 empty_slots = nv_get_empty_tx_slots(np); 2219 empty_slots = nv_get_empty_tx_slots(np);
2218 if (unlikely(empty_slots <= entries)) { 2220 if (unlikely(empty_slots <= entries)) {
2219 spin_lock_irqsave(&np->lock, flags);
2220 netif_stop_queue(dev); 2221 netif_stop_queue(dev);
2221 np->tx_stop = 1; 2222 np->tx_stop = 1;
2222 spin_unlock_irqrestore(&np->lock, flags); 2223 spin_unlock_irqrestore(&np->lock, flags);
2223 return NETDEV_TX_BUSY; 2224 return NETDEV_TX_BUSY;
2224 } 2225 }
2226 spin_unlock_irqrestore(&np->lock, flags);
2225 2227
2226 start_tx = put_tx = np->put_tx.ex; 2228 start_tx = put_tx = np->put_tx.ex;
2227 start_tx_ctx = np->put_tx_ctx; 2229 start_tx_ctx = np->put_tx_ctx;
@@ -3403,10 +3405,10 @@ static irqreturn_t nv_nic_irq(int foo, void *data)
3403 3405
3404#ifdef CONFIG_FORCEDETH_NAPI 3406#ifdef CONFIG_FORCEDETH_NAPI
3405 if (events & NVREG_IRQ_RX_ALL) { 3407 if (events & NVREG_IRQ_RX_ALL) {
3408 spin_lock(&np->lock);
3406 netif_rx_schedule(&np->napi); 3409 netif_rx_schedule(&np->napi);
3407 3410
3408 /* Disable furthur receive irq's */ 3411 /* Disable furthur receive irq's */
3409 spin_lock(&np->lock);
3410 np->irqmask &= ~NVREG_IRQ_RX_ALL; 3412 np->irqmask &= ~NVREG_IRQ_RX_ALL;
3411 3413
3412 if (np->msi_flags & NV_MSI_X_ENABLED) 3414 if (np->msi_flags & NV_MSI_X_ENABLED)
@@ -3520,10 +3522,10 @@ static irqreturn_t nv_nic_irq_optimized(int foo, void *data)
3520 3522
3521#ifdef CONFIG_FORCEDETH_NAPI 3523#ifdef CONFIG_FORCEDETH_NAPI
3522 if (events & NVREG_IRQ_RX_ALL) { 3524 if (events & NVREG_IRQ_RX_ALL) {
3525 spin_lock(&np->lock);
3523 netif_rx_schedule(&np->napi); 3526 netif_rx_schedule(&np->napi);
3524 3527
3525 /* Disable furthur receive irq's */ 3528 /* Disable furthur receive irq's */
3526 spin_lock(&np->lock);
3527 np->irqmask &= ~NVREG_IRQ_RX_ALL; 3529 np->irqmask &= ~NVREG_IRQ_RX_ALL;
3528 3530
3529 if (np->msi_flags & NV_MSI_X_ENABLED) 3531 if (np->msi_flags & NV_MSI_X_ENABLED)
@@ -6167,19 +6169,19 @@ static struct pci_device_id pci_tbl[] = {
6167 }, 6169 },
6168 { /* MCP79 Ethernet Controller */ 6170 { /* MCP79 Ethernet Controller */
6169 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_36), 6171 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_36),
6170 .driver_data = DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V3|DEV_HAS_STATISTICS_V3|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX|DEV_NEED_TX_LIMIT|DEV_HAS_GEAR_MODE, 6172 .driver_data = DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V3|DEV_HAS_STATISTICS_V3|DEV_HAS_TEST_EXTENDED|DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX|DEV_NEED_TX_LIMIT|DEV_HAS_GEAR_MODE,
6171 }, 6173 },
6172 { /* MCP79 Ethernet Controller */ 6174 { /* MCP79 Ethernet Controller */
6173 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_37), 6175 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_37),
6174 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V3|DEV_HAS_STATISTICS_V3|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX|DEV_NEED_TX_LIMIT|DEV_HAS_GEAR_MODE, 6176 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V3|DEV_HAS_STATISTICS_V3|DEV_HAS_TEST_EXTENDED|DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX|DEV_NEED_TX_LIMIT|DEV_HAS_GEAR_MODE,
6175 }, 6177 },
6176 { /* MCP79 Ethernet Controller */ 6178 { /* MCP79 Ethernet Controller */
6177 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_38), 6179 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_38),
6178 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V3|DEV_HAS_STATISTICS_V3|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX|DEV_NEED_TX_LIMIT|DEV_HAS_GEAR_MODE, 6180 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V3|DEV_HAS_STATISTICS_V3|DEV_HAS_TEST_EXTENDED|DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX|DEV_NEED_TX_LIMIT|DEV_HAS_GEAR_MODE,
6179 }, 6181 },
6180 { /* MCP79 Ethernet Controller */ 6182 { /* MCP79 Ethernet Controller */
6181 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_39), 6183 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_39),
6182 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V3|DEV_HAS_STATISTICS_V3|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX|DEV_NEED_TX_LIMIT|DEV_HAS_GEAR_MODE, 6184 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V3|DEV_HAS_STATISTICS_V3|DEV_HAS_TEST_EXTENDED|DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX|DEV_NEED_TX_LIMIT|DEV_HAS_GEAR_MODE,
6183 }, 6185 },
6184 {0,}, 6186 {0,},
6185}; 6187};
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index 1b8deca8b9f..efcbeb6c867 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -296,6 +296,20 @@ err_out:
296 return err; 296 return err;
297} 297}
298 298
299/* Ioctl MII Interface */
300static int gfar_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
301{
302 struct gfar_private *priv = netdev_priv(dev);
303
304 if (!netif_running(dev))
305 return -EINVAL;
306
307 if (!priv->phydev)
308 return -ENODEV;
309
310 return phy_mii_ioctl(priv->phydev, if_mii(rq), cmd);
311}
312
299/* Set up the ethernet device structure, private data, 313/* Set up the ethernet device structure, private data,
300 * and anything else we need before we start */ 314 * and anything else we need before we start */
301static int gfar_probe(struct of_device *ofdev, 315static int gfar_probe(struct of_device *ofdev,
@@ -366,6 +380,7 @@ static int gfar_probe(struct of_device *ofdev,
366 dev->set_multicast_list = gfar_set_multi; 380 dev->set_multicast_list = gfar_set_multi;
367 381
368 dev->ethtool_ops = &gfar_ethtool_ops; 382 dev->ethtool_ops = &gfar_ethtool_ops;
383 dev->do_ioctl = gfar_ioctl;
369 384
370 if (priv->device_flags & FSL_GIANFAR_DEV_HAS_CSUM) { 385 if (priv->device_flags & FSL_GIANFAR_DEV_HAS_CSUM) {
371 priv->rx_csum_enable = 1; 386 priv->rx_csum_enable = 1;
diff --git a/drivers/net/hamachi.c b/drivers/net/hamachi.c
index 32200227c92..7e8b3c59a7d 100644
--- a/drivers/net/hamachi.c
+++ b/drivers/net/hamachi.c
@@ -576,6 +576,7 @@ static const struct net_device_ops hamachi_netdev_ops = {
576 .ndo_set_multicast_list = set_rx_mode, 576 .ndo_set_multicast_list = set_rx_mode,
577 .ndo_change_mtu = eth_change_mtu, 577 .ndo_change_mtu = eth_change_mtu,
578 .ndo_validate_addr = eth_validate_addr, 578 .ndo_validate_addr = eth_validate_addr,
579 .ndo_set_mac_address = eth_mac_addr,
579 .ndo_tx_timeout = hamachi_tx_timeout, 580 .ndo_tx_timeout = hamachi_tx_timeout,
580 .ndo_do_ioctl = netdev_ioctl, 581 .ndo_do_ioctl = netdev_ioctl,
581}; 582};
diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
index 50f1e172ee8..2d4089894ec 100644
--- a/drivers/net/hamradio/6pack.c
+++ b/drivers/net/hamradio/6pack.c
@@ -717,11 +717,12 @@ static int sixpack_ioctl(struct tty_struct *tty, struct file *file,
717 unsigned int cmd, unsigned long arg) 717 unsigned int cmd, unsigned long arg)
718{ 718{
719 struct sixpack *sp = sp_get(tty); 719 struct sixpack *sp = sp_get(tty);
720 struct net_device *dev = sp->dev; 720 struct net_device *dev;
721 unsigned int tmp, err; 721 unsigned int tmp, err;
722 722
723 if (!sp) 723 if (!sp)
724 return -ENXIO; 724 return -ENXIO;
725 dev = sp->dev;
725 726
726 switch(cmd) { 727 switch(cmd) {
727 case SIOCGIFNAME: 728 case SIOCGIFNAME:
diff --git a/drivers/net/hp-plus.c b/drivers/net/hp-plus.c
index b507dbc16e6..5e070f44663 100644
--- a/drivers/net/hp-plus.c
+++ b/drivers/net/hp-plus.c
@@ -166,6 +166,7 @@ static const struct net_device_ops hpp_netdev_ops = {
166 .ndo_get_stats = eip_get_stats, 166 .ndo_get_stats = eip_get_stats,
167 .ndo_set_multicast_list = eip_set_multicast_list, 167 .ndo_set_multicast_list = eip_set_multicast_list,
168 .ndo_validate_addr = eth_validate_addr, 168 .ndo_validate_addr = eth_validate_addr,
169 .ndo_set_mac_address = eth_mac_addr,
169 .ndo_change_mtu = eth_change_mtu, 170 .ndo_change_mtu = eth_change_mtu,
170#ifdef CONFIG_NET_POLL_CONTROLLER 171#ifdef CONFIG_NET_POLL_CONTROLLER
171 .ndo_poll_controller = eip_poll, 172 .ndo_poll_controller = eip_poll,
diff --git a/drivers/net/hydra.c b/drivers/net/hydra.c
index 9cb38a8d438..8ac0930c183 100644
--- a/drivers/net/hydra.c
+++ b/drivers/net/hydra.c
@@ -103,6 +103,7 @@ static const struct net_device_ops hydra_netdev_ops = {
103 .ndo_get_stats = ei_get_stats, 103 .ndo_get_stats = ei_get_stats,
104 .ndo_set_multicast_list = ei_set_multicast_list, 104 .ndo_set_multicast_list = ei_set_multicast_list,
105 .ndo_validate_addr = eth_validate_addr, 105 .ndo_validate_addr = eth_validate_addr,
106 .ndo_set_mac_address = eth_mac_addr,
106 .ndo_change_mtu = eth_change_mtu, 107 .ndo_change_mtu = eth_change_mtu,
107#ifdef CONFIG_NET_POLL_CONTROLLER 108#ifdef CONFIG_NET_POLL_CONTROLLER
108 .ndo_poll_controller = ei_poll, 109 .ndo_poll_controller = ei_poll,
diff --git a/drivers/net/irda/au1k_ir.c b/drivers/net/irda/au1k_ir.c
index 75a1d0a86de..941164076a2 100644
--- a/drivers/net/irda/au1k_ir.c
+++ b/drivers/net/irda/au1k_ir.c
@@ -594,7 +594,7 @@ static int au1k_irda_rx(struct net_device *dev)
594 update_rx_stats(dev, flags, count); 594 update_rx_stats(dev, flags, count);
595 skb=alloc_skb(count+1,GFP_ATOMIC); 595 skb=alloc_skb(count+1,GFP_ATOMIC);
596 if (skb == NULL) { 596 if (skb == NULL) {
597 aup->stats.rx_dropped++; 597 aup->netdev->stats.rx_dropped++;
598 continue; 598 continue;
599 } 599 }
600 skb_reserve(skb, 1); 600 skb_reserve(skb, 1);
diff --git a/drivers/net/irda/donauboe.c b/drivers/net/irda/donauboe.c
index 687c2d53d4d..6f3e7f71658 100644
--- a/drivers/net/irda/donauboe.c
+++ b/drivers/net/irda/donauboe.c
@@ -1194,13 +1194,13 @@ toshoboe_interrupt (int irq, void *dev_id)
1194 txp = txpc; 1194 txp = txpc;
1195 txpc++; 1195 txpc++;
1196 txpc %= TX_SLOTS; 1196 txpc %= TX_SLOTS;
1197 self->stats.tx_packets++; 1197 self->netdev->stats.tx_packets++;
1198 if (self->ring->tx[txpc].control & OBOE_CTL_TX_HW_OWNS) 1198 if (self->ring->tx[txpc].control & OBOE_CTL_TX_HW_OWNS)
1199 self->ring->tx[txp].control &= ~OBOE_CTL_TX_RTCENTX; 1199 self->ring->tx[txp].control &= ~OBOE_CTL_TX_RTCENTX;
1200 } 1200 }
1201 self->stats.tx_packets--; 1201 self->netdev->stats.tx_packets--;
1202#else 1202#else
1203 self->stats.tx_packets++; 1203 self->netdev->stats.tx_packets++;
1204#endif 1204#endif
1205 toshoboe_start_DMA(self, OBOE_CONFIG0H_ENTX); 1205 toshoboe_start_DMA(self, OBOE_CONFIG0H_ENTX);
1206 } 1206 }
@@ -1280,7 +1280,7 @@ dumpbufs(self->rx_bufs[self->rxs],len,'<');
1280 skb_put (skb, len); 1280 skb_put (skb, len);
1281 skb_copy_to_linear_data(skb, self->rx_bufs[self->rxs], 1281 skb_copy_to_linear_data(skb, self->rx_bufs[self->rxs],
1282 len); 1282 len);
1283 self->stats.rx_packets++; 1283 self->netdev->stats.rx_packets++;
1284 skb->dev = self->netdev; 1284 skb->dev = self->netdev;
1285 skb_reset_mac_header(skb); 1285 skb_reset_mac_header(skb);
1286 skb->protocol = htons (ETH_P_IRDA); 1286 skb->protocol = htons (ETH_P_IRDA);
diff --git a/drivers/net/mac8390.c b/drivers/net/mac8390.c
index 57716e22660..8e884869a05 100644
--- a/drivers/net/mac8390.c
+++ b/drivers/net/mac8390.c
@@ -486,6 +486,7 @@ static const struct net_device_ops mac8390_netdev_ops = {
486 .ndo_get_stats = ei_get_stats, 486 .ndo_get_stats = ei_get_stats,
487 .ndo_set_multicast_list = ei_set_multicast_list, 487 .ndo_set_multicast_list = ei_set_multicast_list,
488 .ndo_validate_addr = eth_validate_addr, 488 .ndo_validate_addr = eth_validate_addr,
489 .ndo_set_mac_address = eth_mac_addr,
489 .ndo_change_mtu = eth_change_mtu, 490 .ndo_change_mtu = eth_change_mtu,
490#ifdef CONFIG_NET_POLL_CONTROLLER 491#ifdef CONFIG_NET_POLL_CONTROLLER
491 .ndo_poll_controller = ei_poll, 492 .ndo_poll_controller = ei_poll,
diff --git a/drivers/net/mlx4/en_netdev.c b/drivers/net/mlx4/en_netdev.c
index 15bb38d9930..9f6644a4403 100644
--- a/drivers/net/mlx4/en_netdev.c
+++ b/drivers/net/mlx4/en_netdev.c
@@ -952,6 +952,7 @@ static const struct net_device_ops mlx4_netdev_ops = {
952 .ndo_get_stats = mlx4_en_get_stats, 952 .ndo_get_stats = mlx4_en_get_stats,
953 .ndo_set_multicast_list = mlx4_en_set_multicast, 953 .ndo_set_multicast_list = mlx4_en_set_multicast,
954 .ndo_set_mac_address = mlx4_en_set_mac, 954 .ndo_set_mac_address = mlx4_en_set_mac,
955 .ndo_validate_addr = eth_validate_addr,
955 .ndo_change_mtu = mlx4_en_change_mtu, 956 .ndo_change_mtu = mlx4_en_change_mtu,
956 .ndo_tx_timeout = mlx4_en_tx_timeout, 957 .ndo_tx_timeout = mlx4_en_tx_timeout,
957 .ndo_vlan_rx_register = mlx4_en_vlan_rx_register, 958 .ndo_vlan_rx_register = mlx4_en_vlan_rx_register,
diff --git a/drivers/net/mlx4/main.c b/drivers/net/mlx4/main.c
index 710c79e7a2d..6ef2490d5c3 100644
--- a/drivers/net/mlx4/main.c
+++ b/drivers/net/mlx4/main.c
@@ -912,8 +912,8 @@ static void mlx4_enable_msi_x(struct mlx4_dev *dev)
912 int i; 912 int i;
913 913
914 if (msi_x) { 914 if (msi_x) {
915 nreq = min(dev->caps.num_eqs - dev->caps.reserved_eqs, 915 nreq = min_t(int, dev->caps.num_eqs - dev->caps.reserved_eqs,
916 num_possible_cpus() + 1); 916 num_possible_cpus() + 1);
917 entries = kcalloc(nreq, sizeof *entries, GFP_KERNEL); 917 entries = kcalloc(nreq, sizeof *entries, GFP_KERNEL);
918 if (!entries) 918 if (!entries)
919 goto no_msi; 919 goto no_msi;
diff --git a/drivers/net/ne-h8300.c b/drivers/net/ne-h8300.c
index b5723917104..7bd6662d5b0 100644
--- a/drivers/net/ne-h8300.c
+++ b/drivers/net/ne-h8300.c
@@ -202,6 +202,7 @@ static const struct net_device_ops ne_netdev_ops = {
202 .ndo_get_stats = ei_get_stats, 202 .ndo_get_stats = ei_get_stats,
203 .ndo_set_multicast_list = ei_set_multicast_list, 203 .ndo_set_multicast_list = ei_set_multicast_list,
204 .ndo_validate_addr = eth_validate_addr, 204 .ndo_validate_addr = eth_validate_addr,
205 .ndo_set_mac_address = eth_mac_addr,
205 .ndo_change_mtu = eth_change_mtu, 206 .ndo_change_mtu = eth_change_mtu,
206#ifdef CONFIG_NET_POLL_CONTROLLER 207#ifdef CONFIG_NET_POLL_CONTROLLER
207 .ndo_poll_controller = ei_poll, 208 .ndo_poll_controller = ei_poll,
diff --git a/drivers/net/ne2k-pci.c b/drivers/net/ne2k-pci.c
index 62f20ba211c..f090d3b9ec9 100644
--- a/drivers/net/ne2k-pci.c
+++ b/drivers/net/ne2k-pci.c
@@ -208,6 +208,7 @@ static const struct net_device_ops ne2k_netdev_ops = {
208 .ndo_get_stats = ei_get_stats, 208 .ndo_get_stats = ei_get_stats,
209 .ndo_set_multicast_list = ei_set_multicast_list, 209 .ndo_set_multicast_list = ei_set_multicast_list,
210 .ndo_validate_addr = eth_validate_addr, 210 .ndo_validate_addr = eth_validate_addr,
211 .ndo_set_mac_address = eth_mac_addr,
211 .ndo_change_mtu = eth_change_mtu, 212 .ndo_change_mtu = eth_change_mtu,
212#ifdef CONFIG_NET_POLL_CONTROLLER 213#ifdef CONFIG_NET_POLL_CONTROLLER
213 .ndo_poll_controller = ei_poll, 214 .ndo_poll_controller = ei_poll,
diff --git a/drivers/net/ns83820.c b/drivers/net/ns83820.c
index 42021aca1dd..e80294d8cc1 100644
--- a/drivers/net/ns83820.c
+++ b/drivers/net/ns83820.c
@@ -1956,6 +1956,7 @@ static const struct net_device_ops netdev_ops = {
1956 .ndo_change_mtu = ns83820_change_mtu, 1956 .ndo_change_mtu = ns83820_change_mtu,
1957 .ndo_set_multicast_list = ns83820_set_multicast, 1957 .ndo_set_multicast_list = ns83820_set_multicast,
1958 .ndo_validate_addr = eth_validate_addr, 1958 .ndo_validate_addr = eth_validate_addr,
1959 .ndo_set_mac_address = eth_mac_addr,
1959 .ndo_tx_timeout = ns83820_tx_timeout, 1960 .ndo_tx_timeout = ns83820_tx_timeout,
1960#ifdef NS83820_VLAN_ACCEL_SUPPORT 1961#ifdef NS83820_VLAN_ACCEL_SUPPORT
1961 .ndo_vlan_rx_register = ns83820_vlan_rx_register, 1962 .ndo_vlan_rx_register = ns83820_vlan_rx_register,
diff --git a/drivers/net/qlge/qlge.h b/drivers/net/qlge/qlge.h
index 459663a4023..c1dadadfab1 100644
--- a/drivers/net/qlge/qlge.h
+++ b/drivers/net/qlge/qlge.h
@@ -28,11 +28,11 @@
28 } while (0) 28 } while (0)
29 29
30#define QLGE_VENDOR_ID 0x1077 30#define QLGE_VENDOR_ID 0x1077
31#define QLGE_DEVICE_ID1 0x8012 31#define QLGE_DEVICE_ID 0x8012
32#define QLGE_DEVICE_ID 0x8000
33 32
34#define MAX_RX_RINGS 128 33#define MAX_CPUS 8
35#define MAX_TX_RINGS 128 34#define MAX_TX_RINGS MAX_CPUS
35#define MAX_RX_RINGS ((MAX_CPUS * 2) + 1)
36 36
37#define NUM_TX_RING_ENTRIES 256 37#define NUM_TX_RING_ENTRIES 256
38#define NUM_RX_RING_ENTRIES 256 38#define NUM_RX_RING_ENTRIES 256
@@ -45,6 +45,7 @@
45#define MAX_SPLIT_SIZE 1023 45#define MAX_SPLIT_SIZE 1023
46#define QLGE_SB_PAD 32 46#define QLGE_SB_PAD 32
47 47
48#define MAX_CQ 128
48#define DFLT_COALESCE_WAIT 100 /* 100 usec wait for coalescing */ 49#define DFLT_COALESCE_WAIT 100 /* 100 usec wait for coalescing */
49#define MAX_INTER_FRAME_WAIT 10 /* 10 usec max interframe-wait for coalescing */ 50#define MAX_INTER_FRAME_WAIT 10 /* 10 usec max interframe-wait for coalescing */
50#define DFLT_INTER_FRAME_WAIT (MAX_INTER_FRAME_WAIT/2) 51#define DFLT_INTER_FRAME_WAIT (MAX_INTER_FRAME_WAIT/2)
@@ -961,8 +962,7 @@ struct ib_mac_iocb_rsp {
961#define IB_MAC_IOCB_RSP_DS 0x40 /* data is in small buffer */ 962#define IB_MAC_IOCB_RSP_DS 0x40 /* data is in small buffer */
962#define IB_MAC_IOCB_RSP_DL 0x80 /* data is in large buffer */ 963#define IB_MAC_IOCB_RSP_DL 0x80 /* data is in large buffer */
963 __le32 data_len; /* */ 964 __le32 data_len; /* */
964 __le32 data_addr_lo; /* */ 965 __le64 data_addr; /* */
965 __le32 data_addr_hi; /* */
966 __le32 rss; /* */ 966 __le32 rss; /* */
967 __le16 vlan_id; /* 12 bits */ 967 __le16 vlan_id; /* 12 bits */
968#define IB_MAC_IOCB_RSP_C 0x1000 /* VLAN CFI bit */ 968#define IB_MAC_IOCB_RSP_C 0x1000 /* VLAN CFI bit */
@@ -976,8 +976,7 @@ struct ib_mac_iocb_rsp {
976#define IB_MAC_IOCB_RSP_HS 0x40 976#define IB_MAC_IOCB_RSP_HS 0x40
977#define IB_MAC_IOCB_RSP_HL 0x80 977#define IB_MAC_IOCB_RSP_HL 0x80
978 __le32 hdr_len; /* */ 978 __le32 hdr_len; /* */
979 __le32 hdr_addr_lo; /* */ 979 __le64 hdr_addr; /* */
980 __le32 hdr_addr_hi; /* */
981} __attribute((packed)); 980} __attribute((packed));
982 981
983struct ib_ae_iocb_rsp { 982struct ib_ae_iocb_rsp {
@@ -1042,10 +1041,8 @@ struct wqicb {
1042 __le16 cq_id_rss; 1041 __le16 cq_id_rss;
1043#define Q_CQ_ID_RSS_RV 0x8000 1042#define Q_CQ_ID_RSS_RV 0x8000
1044 __le16 rid; 1043 __le16 rid;
1045 __le32 addr_lo; 1044 __le64 addr;
1046 __le32 addr_hi; 1045 __le64 cnsmr_idx_addr;
1047 __le32 cnsmr_idx_addr_lo;
1048 __le32 cnsmr_idx_addr_hi;
1049} __attribute((packed)); 1046} __attribute((packed));
1050 1047
1051/* 1048/*
@@ -1070,18 +1067,14 @@ struct cqicb {
1070#define LEN_CPP_64 0x0002 1067#define LEN_CPP_64 0x0002
1071#define LEN_CPP_128 0x0003 1068#define LEN_CPP_128 0x0003
1072 __le16 rid; 1069 __le16 rid;
1073 __le32 addr_lo; 1070 __le64 addr;
1074 __le32 addr_hi; 1071 __le64 prod_idx_addr;
1075 __le32 prod_idx_addr_lo;
1076 __le32 prod_idx_addr_hi;
1077 __le16 pkt_delay; 1072 __le16 pkt_delay;
1078 __le16 irq_delay; 1073 __le16 irq_delay;
1079 __le32 lbq_addr_lo; 1074 __le64 lbq_addr;
1080 __le32 lbq_addr_hi;
1081 __le16 lbq_buf_size; 1075 __le16 lbq_buf_size;
1082 __le16 lbq_len; /* entry count */ 1076 __le16 lbq_len; /* entry count */
1083 __le32 sbq_addr_lo; 1077 __le64 sbq_addr;
1084 __le32 sbq_addr_hi;
1085 __le16 sbq_buf_size; 1078 __le16 sbq_buf_size;
1086 __le16 sbq_len; /* entry count */ 1079 __le16 sbq_len; /* entry count */
1087} __attribute((packed)); 1080} __attribute((packed));
@@ -1145,7 +1138,7 @@ struct tx_ring {
1145 struct wqicb wqicb; /* structure used to inform chip of new queue */ 1138 struct wqicb wqicb; /* structure used to inform chip of new queue */
1146 void *wq_base; /* pci_alloc:virtual addr for tx */ 1139 void *wq_base; /* pci_alloc:virtual addr for tx */
1147 dma_addr_t wq_base_dma; /* pci_alloc:dma addr for tx */ 1140 dma_addr_t wq_base_dma; /* pci_alloc:dma addr for tx */
1148 u32 *cnsmr_idx_sh_reg; /* shadow copy of consumer idx */ 1141 __le32 *cnsmr_idx_sh_reg; /* shadow copy of consumer idx */
1149 dma_addr_t cnsmr_idx_sh_reg_dma; /* dma-shadow copy of consumer */ 1142 dma_addr_t cnsmr_idx_sh_reg_dma; /* dma-shadow copy of consumer */
1150 u32 wq_size; /* size in bytes of queue area */ 1143 u32 wq_size; /* size in bytes of queue area */
1151 u32 wq_len; /* number of entries in queue */ 1144 u32 wq_len; /* number of entries in queue */
@@ -1181,7 +1174,7 @@ struct rx_ring {
1181 u32 cq_size; 1174 u32 cq_size;
1182 u32 cq_len; 1175 u32 cq_len;
1183 u16 cq_id; 1176 u16 cq_id;
1184 volatile __le32 *prod_idx_sh_reg; /* Shadowed producer register. */ 1177 __le32 *prod_idx_sh_reg; /* Shadowed producer register. */
1185 dma_addr_t prod_idx_sh_reg_dma; 1178 dma_addr_t prod_idx_sh_reg_dma;
1186 void __iomem *cnsmr_idx_db_reg; /* PCI doorbell mem area + 0 */ 1179 void __iomem *cnsmr_idx_db_reg; /* PCI doorbell mem area + 0 */
1187 u32 cnsmr_idx; /* current sw idx */ 1180 u32 cnsmr_idx; /* current sw idx */
@@ -1402,9 +1395,11 @@ struct ql_adapter {
1402 int rx_ring_count; 1395 int rx_ring_count;
1403 int ring_mem_size; 1396 int ring_mem_size;
1404 void *ring_mem; 1397 void *ring_mem;
1405 struct rx_ring *rx_ring; 1398
1399 struct rx_ring rx_ring[MAX_RX_RINGS];
1400 struct tx_ring tx_ring[MAX_TX_RINGS];
1401
1406 int rx_csum; 1402 int rx_csum;
1407 struct tx_ring *tx_ring;
1408 u32 default_rx_queue; 1403 u32 default_rx_queue;
1409 1404
1410 u16 rx_coalesce_usecs; /* cqicb->int_delay */ 1405 u16 rx_coalesce_usecs; /* cqicb->int_delay */
@@ -1459,6 +1454,24 @@ static inline void ql_write_db_reg(u32 val, void __iomem *addr)
1459 mmiowb(); 1454 mmiowb();
1460} 1455}
1461 1456
1457/*
1458 * Shadow Registers:
1459 * Outbound queues have a consumer index that is maintained by the chip.
1460 * Inbound queues have a producer index that is maintained by the chip.
1461 * For lower overhead, these registers are "shadowed" to host memory
1462 * which allows the device driver to track the queue progress without
1463 * PCI reads. When an entry is placed on an inbound queue, the chip will
1464 * update the relevant index register and then copy the value to the
1465 * shadow register in host memory.
1466 */
1467static inline u32 ql_read_sh_reg(__le32 *addr)
1468{
1469 u32 reg;
1470 reg = le32_to_cpu(*addr);
1471 rmb();
1472 return reg;
1473}
1474
1462extern char qlge_driver_name[]; 1475extern char qlge_driver_name[];
1463extern const char qlge_driver_version[]; 1476extern const char qlge_driver_version[];
1464extern const struct ethtool_ops qlge_ethtool_ops; 1477extern const struct ethtool_ops qlge_ethtool_ops;
diff --git a/drivers/net/qlge/qlge_dbg.c b/drivers/net/qlge/qlge_dbg.c
index 3f5e02d2e4a..379b895ed6e 100644
--- a/drivers/net/qlge/qlge_dbg.c
+++ b/drivers/net/qlge/qlge_dbg.c
@@ -435,14 +435,10 @@ void ql_dump_wqicb(struct wqicb *wqicb)
435 printk(KERN_ERR PFX "wqicb->cq_id_rss = %d.\n", 435 printk(KERN_ERR PFX "wqicb->cq_id_rss = %d.\n",
436 le16_to_cpu(wqicb->cq_id_rss)); 436 le16_to_cpu(wqicb->cq_id_rss));
437 printk(KERN_ERR PFX "wqicb->rid = 0x%x.\n", le16_to_cpu(wqicb->rid)); 437 printk(KERN_ERR PFX "wqicb->rid = 0x%x.\n", le16_to_cpu(wqicb->rid));
438 printk(KERN_ERR PFX "wqicb->wq_addr_lo = 0x%.08x.\n", 438 printk(KERN_ERR PFX "wqicb->wq_addr = 0x%llx.\n",
439 le32_to_cpu(wqicb->addr_lo)); 439 (unsigned long long) le64_to_cpu(wqicb->addr));
440 printk(KERN_ERR PFX "wqicb->wq_addr_hi = 0x%.08x.\n", 440 printk(KERN_ERR PFX "wqicb->wq_cnsmr_idx_addr = 0x%llx.\n",
441 le32_to_cpu(wqicb->addr_hi)); 441 (unsigned long long) le64_to_cpu(wqicb->cnsmr_idx_addr));
442 printk(KERN_ERR PFX "wqicb->wq_cnsmr_idx_addr_lo = 0x%.08x.\n",
443 le32_to_cpu(wqicb->cnsmr_idx_addr_lo));
444 printk(KERN_ERR PFX "wqicb->wq_cnsmr_idx_addr_hi = 0x%.08x.\n",
445 le32_to_cpu(wqicb->cnsmr_idx_addr_hi));
446} 442}
447 443
448void ql_dump_tx_ring(struct tx_ring *tx_ring) 444void ql_dump_tx_ring(struct tx_ring *tx_ring)
@@ -455,10 +451,11 @@ void ql_dump_tx_ring(struct tx_ring *tx_ring)
455 printk(KERN_ERR PFX "tx_ring->base = %p.\n", tx_ring->wq_base); 451 printk(KERN_ERR PFX "tx_ring->base = %p.\n", tx_ring->wq_base);
456 printk(KERN_ERR PFX "tx_ring->base_dma = 0x%llx.\n", 452 printk(KERN_ERR PFX "tx_ring->base_dma = 0x%llx.\n",
457 (unsigned long long) tx_ring->wq_base_dma); 453 (unsigned long long) tx_ring->wq_base_dma);
458 printk(KERN_ERR PFX "tx_ring->cnsmr_idx_sh_reg = %p.\n", 454 printk(KERN_ERR PFX
459 tx_ring->cnsmr_idx_sh_reg); 455 "tx_ring->cnsmr_idx_sh_reg, addr = 0x%p, value = %d.\n",
460 printk(KERN_ERR PFX "tx_ring->cnsmr_idx_sh_reg_dma = 0x%llx.\n", 456 tx_ring->cnsmr_idx_sh_reg,
461 (unsigned long long) tx_ring->cnsmr_idx_sh_reg_dma); 457 tx_ring->cnsmr_idx_sh_reg
458 ? ql_read_sh_reg(tx_ring->cnsmr_idx_sh_reg) : 0);
462 printk(KERN_ERR PFX "tx_ring->size = %d.\n", tx_ring->wq_size); 459 printk(KERN_ERR PFX "tx_ring->size = %d.\n", tx_ring->wq_size);
463 printk(KERN_ERR PFX "tx_ring->len = %d.\n", tx_ring->wq_len); 460 printk(KERN_ERR PFX "tx_ring->len = %d.\n", tx_ring->wq_len);
464 printk(KERN_ERR PFX "tx_ring->prod_idx_db_reg = %p.\n", 461 printk(KERN_ERR PFX "tx_ring->prod_idx_db_reg = %p.\n",
@@ -510,30 +507,22 @@ void ql_dump_cqicb(struct cqicb *cqicb)
510 printk(KERN_ERR PFX "cqicb->msix_vect = %d.\n", cqicb->msix_vect); 507 printk(KERN_ERR PFX "cqicb->msix_vect = %d.\n", cqicb->msix_vect);
511 printk(KERN_ERR PFX "cqicb->flags = %x.\n", cqicb->flags); 508 printk(KERN_ERR PFX "cqicb->flags = %x.\n", cqicb->flags);
512 printk(KERN_ERR PFX "cqicb->len = %d.\n", le16_to_cpu(cqicb->len)); 509 printk(KERN_ERR PFX "cqicb->len = %d.\n", le16_to_cpu(cqicb->len));
513 printk(KERN_ERR PFX "cqicb->addr_lo = %x.\n", 510 printk(KERN_ERR PFX "cqicb->addr = 0x%llx.\n",
514 le32_to_cpu(cqicb->addr_lo)); 511 (unsigned long long) le64_to_cpu(cqicb->addr));
515 printk(KERN_ERR PFX "cqicb->addr_hi = %x.\n", 512 printk(KERN_ERR PFX "cqicb->prod_idx_addr = 0x%llx.\n",
516 le32_to_cpu(cqicb->addr_hi)); 513 (unsigned long long) le64_to_cpu(cqicb->prod_idx_addr));
517 printk(KERN_ERR PFX "cqicb->prod_idx_addr_lo = %x.\n",
518 le32_to_cpu(cqicb->prod_idx_addr_lo));
519 printk(KERN_ERR PFX "cqicb->prod_idx_addr_hi = %x.\n",
520 le32_to_cpu(cqicb->prod_idx_addr_hi));
521 printk(KERN_ERR PFX "cqicb->pkt_delay = 0x%.04x.\n", 514 printk(KERN_ERR PFX "cqicb->pkt_delay = 0x%.04x.\n",
522 le16_to_cpu(cqicb->pkt_delay)); 515 le16_to_cpu(cqicb->pkt_delay));
523 printk(KERN_ERR PFX "cqicb->irq_delay = 0x%.04x.\n", 516 printk(KERN_ERR PFX "cqicb->irq_delay = 0x%.04x.\n",
524 le16_to_cpu(cqicb->irq_delay)); 517 le16_to_cpu(cqicb->irq_delay));
525 printk(KERN_ERR PFX "cqicb->lbq_addr_lo = %x.\n", 518 printk(KERN_ERR PFX "cqicb->lbq_addr = 0x%llx.\n",
526 le32_to_cpu(cqicb->lbq_addr_lo)); 519 (unsigned long long) le64_to_cpu(cqicb->lbq_addr));
527 printk(KERN_ERR PFX "cqicb->lbq_addr_hi = %x.\n",
528 le32_to_cpu(cqicb->lbq_addr_hi));
529 printk(KERN_ERR PFX "cqicb->lbq_buf_size = 0x%.04x.\n", 520 printk(KERN_ERR PFX "cqicb->lbq_buf_size = 0x%.04x.\n",
530 le16_to_cpu(cqicb->lbq_buf_size)); 521 le16_to_cpu(cqicb->lbq_buf_size));
531 printk(KERN_ERR PFX "cqicb->lbq_len = 0x%.04x.\n", 522 printk(KERN_ERR PFX "cqicb->lbq_len = 0x%.04x.\n",
532 le16_to_cpu(cqicb->lbq_len)); 523 le16_to_cpu(cqicb->lbq_len));
533 printk(KERN_ERR PFX "cqicb->sbq_addr_lo = %x.\n", 524 printk(KERN_ERR PFX "cqicb->sbq_addr = 0x%llx.\n",
534 le32_to_cpu(cqicb->sbq_addr_lo)); 525 (unsigned long long) le64_to_cpu(cqicb->sbq_addr));
535 printk(KERN_ERR PFX "cqicb->sbq_addr_hi = %x.\n",
536 le32_to_cpu(cqicb->sbq_addr_hi));
537 printk(KERN_ERR PFX "cqicb->sbq_buf_size = 0x%.04x.\n", 526 printk(KERN_ERR PFX "cqicb->sbq_buf_size = 0x%.04x.\n",
538 le16_to_cpu(cqicb->sbq_buf_size)); 527 le16_to_cpu(cqicb->sbq_buf_size));
539 printk(KERN_ERR PFX "cqicb->sbq_len = 0x%.04x.\n", 528 printk(KERN_ERR PFX "cqicb->sbq_len = 0x%.04x.\n",
@@ -558,9 +547,10 @@ void ql_dump_rx_ring(struct rx_ring *rx_ring)
558 printk(KERN_ERR PFX "rx_ring->cq_size = %d.\n", rx_ring->cq_size); 547 printk(KERN_ERR PFX "rx_ring->cq_size = %d.\n", rx_ring->cq_size);
559 printk(KERN_ERR PFX "rx_ring->cq_len = %d.\n", rx_ring->cq_len); 548 printk(KERN_ERR PFX "rx_ring->cq_len = %d.\n", rx_ring->cq_len);
560 printk(KERN_ERR PFX 549 printk(KERN_ERR PFX
561 "rx_ring->prod_idx_sh_reg, addr = %p, value = %d.\n", 550 "rx_ring->prod_idx_sh_reg, addr = 0x%p, value = %d.\n",
562 rx_ring->prod_idx_sh_reg, 551 rx_ring->prod_idx_sh_reg,
563 rx_ring->prod_idx_sh_reg ? *(rx_ring->prod_idx_sh_reg) : 0); 552 rx_ring->prod_idx_sh_reg
553 ? ql_read_sh_reg(rx_ring->prod_idx_sh_reg) : 0);
564 printk(KERN_ERR PFX "rx_ring->prod_idx_sh_reg_dma = %llx.\n", 554 printk(KERN_ERR PFX "rx_ring->prod_idx_sh_reg_dma = %llx.\n",
565 (unsigned long long) rx_ring->prod_idx_sh_reg_dma); 555 (unsigned long long) rx_ring->prod_idx_sh_reg_dma);
566 printk(KERN_ERR PFX "rx_ring->cnsmr_idx_db_reg = %p.\n", 556 printk(KERN_ERR PFX "rx_ring->cnsmr_idx_db_reg = %p.\n",
@@ -809,10 +799,8 @@ void ql_dump_ib_mac_rsp(struct ib_mac_iocb_rsp *ib_mac_rsp)
809 799
810 printk(KERN_ERR PFX "data_len = %d\n", 800 printk(KERN_ERR PFX "data_len = %d\n",
811 le32_to_cpu(ib_mac_rsp->data_len)); 801 le32_to_cpu(ib_mac_rsp->data_len));
812 printk(KERN_ERR PFX "data_addr_hi = 0x%x\n", 802 printk(KERN_ERR PFX "data_addr = 0x%llx\n",
813 le32_to_cpu(ib_mac_rsp->data_addr_hi)); 803 (unsigned long long) le64_to_cpu(ib_mac_rsp->data_addr));
814 printk(KERN_ERR PFX "data_addr_lo = 0x%x\n",
815 le32_to_cpu(ib_mac_rsp->data_addr_lo));
816 if (ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_RSS_MASK) 804 if (ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_RSS_MASK)
817 printk(KERN_ERR PFX "rss = %x\n", 805 printk(KERN_ERR PFX "rss = %x\n",
818 le32_to_cpu(ib_mac_rsp->rss)); 806 le32_to_cpu(ib_mac_rsp->rss));
@@ -828,10 +816,8 @@ void ql_dump_ib_mac_rsp(struct ib_mac_iocb_rsp *ib_mac_rsp)
828 if (ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HV) { 816 if (ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HV) {
829 printk(KERN_ERR PFX "hdr length = %d.\n", 817 printk(KERN_ERR PFX "hdr length = %d.\n",
830 le32_to_cpu(ib_mac_rsp->hdr_len)); 818 le32_to_cpu(ib_mac_rsp->hdr_len));
831 printk(KERN_ERR PFX "hdr addr_hi = 0x%x.\n", 819 printk(KERN_ERR PFX "hdr addr = 0x%llx.\n",
832 le32_to_cpu(ib_mac_rsp->hdr_addr_hi)); 820 (unsigned long long) le64_to_cpu(ib_mac_rsp->hdr_addr));
833 printk(KERN_ERR PFX "hdr addr_lo = 0x%x.\n",
834 le32_to_cpu(ib_mac_rsp->hdr_addr_lo));
835 } 821 }
836} 822}
837#endif 823#endif
diff --git a/drivers/net/qlge/qlge_main.c b/drivers/net/qlge/qlge_main.c
index f4c016012f1..45421c8b601 100644
--- a/drivers/net/qlge/qlge_main.c
+++ b/drivers/net/qlge/qlge_main.c
@@ -76,7 +76,6 @@ MODULE_PARM_DESC(irq_type, "0 = MSI-X, 1 = MSI, 2 = Legacy.");
76 76
77static struct pci_device_id qlge_pci_tbl[] __devinitdata = { 77static struct pci_device_id qlge_pci_tbl[] __devinitdata = {
78 {PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, QLGE_DEVICE_ID)}, 78 {PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, QLGE_DEVICE_ID)},
79 {PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, QLGE_DEVICE_ID1)},
80 /* required last entry */ 79 /* required last entry */
81 {0,} 80 {0,}
82}; 81};
@@ -127,12 +126,12 @@ static int ql_sem_trylock(struct ql_adapter *qdev, u32 sem_mask)
127 126
128int ql_sem_spinlock(struct ql_adapter *qdev, u32 sem_mask) 127int ql_sem_spinlock(struct ql_adapter *qdev, u32 sem_mask)
129{ 128{
130 unsigned int seconds = 3; 129 unsigned int wait_count = 30;
131 do { 130 do {
132 if (!ql_sem_trylock(qdev, sem_mask)) 131 if (!ql_sem_trylock(qdev, sem_mask))
133 return 0; 132 return 0;
134 ssleep(1); 133 udelay(100);
135 } while (--seconds); 134 } while (--wait_count);
136 return -ETIMEDOUT; 135 return -ETIMEDOUT;
137} 136}
138 137
@@ -1545,7 +1544,7 @@ static void ql_process_chip_ae_intr(struct ql_adapter *qdev,
1545static int ql_clean_outbound_rx_ring(struct rx_ring *rx_ring) 1544static int ql_clean_outbound_rx_ring(struct rx_ring *rx_ring)
1546{ 1545{
1547 struct ql_adapter *qdev = rx_ring->qdev; 1546 struct ql_adapter *qdev = rx_ring->qdev;
1548 u32 prod = le32_to_cpu(*rx_ring->prod_idx_sh_reg); 1547 u32 prod = ql_read_sh_reg(rx_ring->prod_idx_sh_reg);
1549 struct ob_mac_iocb_rsp *net_rsp = NULL; 1548 struct ob_mac_iocb_rsp *net_rsp = NULL;
1550 int count = 0; 1549 int count = 0;
1551 1550
@@ -1571,7 +1570,7 @@ static int ql_clean_outbound_rx_ring(struct rx_ring *rx_ring)
1571 } 1570 }
1572 count++; 1571 count++;
1573 ql_update_cq(rx_ring); 1572 ql_update_cq(rx_ring);
1574 prod = le32_to_cpu(*rx_ring->prod_idx_sh_reg); 1573 prod = ql_read_sh_reg(rx_ring->prod_idx_sh_reg);
1575 } 1574 }
1576 ql_write_cq_idx(rx_ring); 1575 ql_write_cq_idx(rx_ring);
1577 if (netif_queue_stopped(qdev->ndev) && net_rsp != NULL) { 1576 if (netif_queue_stopped(qdev->ndev) && net_rsp != NULL) {
@@ -1591,7 +1590,7 @@ static int ql_clean_outbound_rx_ring(struct rx_ring *rx_ring)
1591static int ql_clean_inbound_rx_ring(struct rx_ring *rx_ring, int budget) 1590static int ql_clean_inbound_rx_ring(struct rx_ring *rx_ring, int budget)
1592{ 1591{
1593 struct ql_adapter *qdev = rx_ring->qdev; 1592 struct ql_adapter *qdev = rx_ring->qdev;
1594 u32 prod = le32_to_cpu(*rx_ring->prod_idx_sh_reg); 1593 u32 prod = ql_read_sh_reg(rx_ring->prod_idx_sh_reg);
1595 struct ql_net_rsp_iocb *net_rsp; 1594 struct ql_net_rsp_iocb *net_rsp;
1596 int count = 0; 1595 int count = 0;
1597 1596
@@ -1624,7 +1623,7 @@ static int ql_clean_inbound_rx_ring(struct rx_ring *rx_ring, int budget)
1624 } 1623 }
1625 count++; 1624 count++;
1626 ql_update_cq(rx_ring); 1625 ql_update_cq(rx_ring);
1627 prod = le32_to_cpu(*rx_ring->prod_idx_sh_reg); 1626 prod = ql_read_sh_reg(rx_ring->prod_idx_sh_reg);
1628 if (count == budget) 1627 if (count == budget)
1629 break; 1628 break;
1630 } 1629 }
@@ -1787,7 +1786,7 @@ static irqreturn_t qlge_isr(int irq, void *dev_id)
1787 * Check the default queue and wake handler if active. 1786 * Check the default queue and wake handler if active.
1788 */ 1787 */
1789 rx_ring = &qdev->rx_ring[0]; 1788 rx_ring = &qdev->rx_ring[0];
1790 if (le32_to_cpu(*rx_ring->prod_idx_sh_reg) != rx_ring->cnsmr_idx) { 1789 if (ql_read_sh_reg(rx_ring->prod_idx_sh_reg) != rx_ring->cnsmr_idx) {
1791 QPRINTK(qdev, INTR, INFO, "Waking handler for rx_ring[0].\n"); 1790 QPRINTK(qdev, INTR, INFO, "Waking handler for rx_ring[0].\n");
1792 ql_disable_completion_interrupt(qdev, intr_context->intr); 1791 ql_disable_completion_interrupt(qdev, intr_context->intr);
1793 queue_delayed_work_on(smp_processor_id(), qdev->q_workqueue, 1792 queue_delayed_work_on(smp_processor_id(), qdev->q_workqueue,
@@ -1801,7 +1800,7 @@ static irqreturn_t qlge_isr(int irq, void *dev_id)
1801 */ 1800 */
1802 for (i = 1; i < qdev->rx_ring_count; i++) { 1801 for (i = 1; i < qdev->rx_ring_count; i++) {
1803 rx_ring = &qdev->rx_ring[i]; 1802 rx_ring = &qdev->rx_ring[i];
1804 if (le32_to_cpu(*rx_ring->prod_idx_sh_reg) != 1803 if (ql_read_sh_reg(rx_ring->prod_idx_sh_reg) !=
1805 rx_ring->cnsmr_idx) { 1804 rx_ring->cnsmr_idx) {
1806 QPRINTK(qdev, INTR, INFO, 1805 QPRINTK(qdev, INTR, INFO,
1807 "Waking handler for rx_ring[%d].\n", i); 1806 "Waking handler for rx_ring[%d].\n", i);
@@ -2356,28 +2355,6 @@ static void ql_tx_ring_clean(struct ql_adapter *qdev)
2356 } 2355 }
2357} 2356}
2358 2357
2359static void ql_free_ring_cb(struct ql_adapter *qdev)
2360{
2361 kfree(qdev->ring_mem);
2362}
2363
2364static int ql_alloc_ring_cb(struct ql_adapter *qdev)
2365{
2366 /* Allocate space for tx/rx ring control blocks. */
2367 qdev->ring_mem_size =
2368 (qdev->tx_ring_count * sizeof(struct tx_ring)) +
2369 (qdev->rx_ring_count * sizeof(struct rx_ring));
2370 qdev->ring_mem = kmalloc(qdev->ring_mem_size, GFP_KERNEL);
2371 if (qdev->ring_mem == NULL) {
2372 return -ENOMEM;
2373 } else {
2374 qdev->rx_ring = qdev->ring_mem;
2375 qdev->tx_ring = qdev->ring_mem +
2376 (qdev->rx_ring_count * sizeof(struct rx_ring));
2377 }
2378 return 0;
2379}
2380
2381static void ql_free_mem_resources(struct ql_adapter *qdev) 2358static void ql_free_mem_resources(struct ql_adapter *qdev)
2382{ 2359{
2383 int i; 2360 int i;
@@ -2467,12 +2444,9 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring)
2467 bq_len = (rx_ring->cq_len == 65536) ? 0 : (u16) rx_ring->cq_len; 2444 bq_len = (rx_ring->cq_len == 65536) ? 0 : (u16) rx_ring->cq_len;
2468 cqicb->len = cpu_to_le16(bq_len | LEN_V | LEN_CPP_CONT); 2445 cqicb->len = cpu_to_le16(bq_len | LEN_V | LEN_CPP_CONT);
2469 2446
2470 cqicb->addr_lo = cpu_to_le32(rx_ring->cq_base_dma); 2447 cqicb->addr = cpu_to_le64(rx_ring->cq_base_dma);
2471 cqicb->addr_hi = cpu_to_le32((u64) rx_ring->cq_base_dma >> 32);
2472 2448
2473 cqicb->prod_idx_addr_lo = cpu_to_le32(rx_ring->prod_idx_sh_reg_dma); 2449 cqicb->prod_idx_addr = cpu_to_le64(rx_ring->prod_idx_sh_reg_dma);
2474 cqicb->prod_idx_addr_hi =
2475 cpu_to_le32((u64) rx_ring->prod_idx_sh_reg_dma >> 32);
2476 2450
2477 /* 2451 /*
2478 * Set up the control block load flags. 2452 * Set up the control block load flags.
@@ -2483,10 +2457,8 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring)
2483 if (rx_ring->lbq_len) { 2457 if (rx_ring->lbq_len) {
2484 cqicb->flags |= FLAGS_LL; /* Load lbq values */ 2458 cqicb->flags |= FLAGS_LL; /* Load lbq values */
2485 *((u64 *) rx_ring->lbq_base_indirect) = rx_ring->lbq_base_dma; 2459 *((u64 *) rx_ring->lbq_base_indirect) = rx_ring->lbq_base_dma;
2486 cqicb->lbq_addr_lo = 2460 cqicb->lbq_addr =
2487 cpu_to_le32(rx_ring->lbq_base_indirect_dma); 2461 cpu_to_le64(rx_ring->lbq_base_indirect_dma);
2488 cqicb->lbq_addr_hi =
2489 cpu_to_le32((u64) rx_ring->lbq_base_indirect_dma >> 32);
2490 bq_len = (rx_ring->lbq_buf_size == 65536) ? 0 : 2462 bq_len = (rx_ring->lbq_buf_size == 65536) ? 0 :
2491 (u16) rx_ring->lbq_buf_size; 2463 (u16) rx_ring->lbq_buf_size;
2492 cqicb->lbq_buf_size = cpu_to_le16(bq_len); 2464 cqicb->lbq_buf_size = cpu_to_le16(bq_len);
@@ -2501,10 +2473,8 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring)
2501 if (rx_ring->sbq_len) { 2473 if (rx_ring->sbq_len) {
2502 cqicb->flags |= FLAGS_LS; /* Load sbq values */ 2474 cqicb->flags |= FLAGS_LS; /* Load sbq values */
2503 *((u64 *) rx_ring->sbq_base_indirect) = rx_ring->sbq_base_dma; 2475 *((u64 *) rx_ring->sbq_base_indirect) = rx_ring->sbq_base_dma;
2504 cqicb->sbq_addr_lo = 2476 cqicb->sbq_addr =
2505 cpu_to_le32(rx_ring->sbq_base_indirect_dma); 2477 cpu_to_le64(rx_ring->sbq_base_indirect_dma);
2506 cqicb->sbq_addr_hi =
2507 cpu_to_le32((u64) rx_ring->sbq_base_indirect_dma >> 32);
2508 cqicb->sbq_buf_size = 2478 cqicb->sbq_buf_size =
2509 cpu_to_le16(((rx_ring->sbq_buf_size / 2) + 8) & 0xfffffff8); 2479 cpu_to_le16(((rx_ring->sbq_buf_size / 2) + 8) & 0xfffffff8);
2510 bq_len = (rx_ring->sbq_len == 65536) ? 0 : 2480 bq_len = (rx_ring->sbq_len == 65536) ? 0 :
@@ -2611,12 +2581,9 @@ static int ql_start_tx_ring(struct ql_adapter *qdev, struct tx_ring *tx_ring)
2611 Q_FLAGS_LB | Q_FLAGS_LI | Q_FLAGS_LO); 2581 Q_FLAGS_LB | Q_FLAGS_LI | Q_FLAGS_LO);
2612 wqicb->cq_id_rss = cpu_to_le16(tx_ring->cq_id); 2582 wqicb->cq_id_rss = cpu_to_le16(tx_ring->cq_id);
2613 wqicb->rid = 0; 2583 wqicb->rid = 0;
2614 wqicb->addr_lo = cpu_to_le32(tx_ring->wq_base_dma); 2584 wqicb->addr = cpu_to_le64(tx_ring->wq_base_dma);
2615 wqicb->addr_hi = cpu_to_le32((u64) tx_ring->wq_base_dma >> 32);
2616 2585
2617 wqicb->cnsmr_idx_addr_lo = cpu_to_le32(tx_ring->cnsmr_idx_sh_reg_dma); 2586 wqicb->cnsmr_idx_addr = cpu_to_le64(tx_ring->cnsmr_idx_sh_reg_dma);
2618 wqicb->cnsmr_idx_addr_hi =
2619 cpu_to_le32((u64) tx_ring->cnsmr_idx_sh_reg_dma >> 32);
2620 2587
2621 ql_init_tx_ring(qdev, tx_ring); 2588 ql_init_tx_ring(qdev, tx_ring);
2622 2589
@@ -2746,14 +2713,14 @@ static void ql_resolve_queues_to_irqs(struct ql_adapter *qdev)
2746 * Outbound queue is for outbound completions only. 2713 * Outbound queue is for outbound completions only.
2747 */ 2714 */
2748 intr_context->handler = qlge_msix_tx_isr; 2715 intr_context->handler = qlge_msix_tx_isr;
2749 sprintf(intr_context->name, "%s-txq-%d", 2716 sprintf(intr_context->name, "%s-tx-%d",
2750 qdev->ndev->name, i); 2717 qdev->ndev->name, i);
2751 } else { 2718 } else {
2752 /* 2719 /*
2753 * Inbound queues handle unicast frames only. 2720 * Inbound queues handle unicast frames only.
2754 */ 2721 */
2755 intr_context->handler = qlge_msix_rx_isr; 2722 intr_context->handler = qlge_msix_rx_isr;
2756 sprintf(intr_context->name, "%s-rxq-%d", 2723 sprintf(intr_context->name, "%s-rx-%d",
2757 qdev->ndev->name, i); 2724 qdev->ndev->name, i);
2758 } 2725 }
2759 } 2726 }
@@ -3247,7 +3214,6 @@ static int qlge_close(struct net_device *ndev)
3247 msleep(1); 3214 msleep(1);
3248 ql_adapter_down(qdev); 3215 ql_adapter_down(qdev);
3249 ql_release_adapter_resources(qdev); 3216 ql_release_adapter_resources(qdev);
3250 ql_free_ring_cb(qdev);
3251 return 0; 3217 return 0;
3252} 3218}
3253 3219
@@ -3273,8 +3239,8 @@ static int ql_configure_rings(struct ql_adapter *qdev)
3273 * This limitation can be removed when requested. 3239 * This limitation can be removed when requested.
3274 */ 3240 */
3275 3241
3276 if (cpu_cnt > 8) 3242 if (cpu_cnt > MAX_CPUS)
3277 cpu_cnt = 8; 3243 cpu_cnt = MAX_CPUS;
3278 3244
3279 /* 3245 /*
3280 * rx_ring[0] is always the default queue. 3246 * rx_ring[0] is always the default queue.
@@ -3294,9 +3260,6 @@ static int ql_configure_rings(struct ql_adapter *qdev)
3294 */ 3260 */
3295 qdev->rx_ring_count = qdev->tx_ring_count + qdev->rss_ring_count + 1; 3261 qdev->rx_ring_count = qdev->tx_ring_count + qdev->rss_ring_count + 1;
3296 3262
3297 if (ql_alloc_ring_cb(qdev))
3298 return -ENOMEM;
3299
3300 for (i = 0; i < qdev->tx_ring_count; i++) { 3263 for (i = 0; i < qdev->tx_ring_count; i++) {
3301 tx_ring = &qdev->tx_ring[i]; 3264 tx_ring = &qdev->tx_ring[i];
3302 memset((void *)tx_ring, 0, sizeof(tx_ring)); 3265 memset((void *)tx_ring, 0, sizeof(tx_ring));
@@ -3393,7 +3356,6 @@ static int qlge_open(struct net_device *ndev)
3393 3356
3394error_up: 3357error_up:
3395 ql_release_adapter_resources(qdev); 3358 ql_release_adapter_resources(qdev);
3396 ql_free_ring_cb(qdev);
3397 return err; 3359 return err;
3398} 3360}
3399 3361
diff --git a/drivers/net/r6040.c b/drivers/net/r6040.c
index cf3a082bc89..72fd9e97c19 100644
--- a/drivers/net/r6040.c
+++ b/drivers/net/r6040.c
@@ -49,8 +49,8 @@
49#include <asm/processor.h> 49#include <asm/processor.h>
50 50
51#define DRV_NAME "r6040" 51#define DRV_NAME "r6040"
52#define DRV_VERSION "0.20" 52#define DRV_VERSION "0.21"
53#define DRV_RELDATE "07Jan2009" 53#define DRV_RELDATE "09Jan2009"
54 54
55/* PHY CHIP Address */ 55/* PHY CHIP Address */
56#define PHY1_ADDR 1 /* For MAC1 */ 56#define PHY1_ADDR 1 /* For MAC1 */
@@ -457,22 +457,12 @@ static void r6040_down(struct net_device *dev)
457 iowrite16(adrp[0], ioaddr + MID_0L); 457 iowrite16(adrp[0], ioaddr + MID_0L);
458 iowrite16(adrp[1], ioaddr + MID_0M); 458 iowrite16(adrp[1], ioaddr + MID_0M);
459 iowrite16(adrp[2], ioaddr + MID_0H); 459 iowrite16(adrp[2], ioaddr + MID_0H);
460 free_irq(dev->irq, dev);
461
462 /* Free RX buffer */
463 r6040_free_rxbufs(dev);
464
465 /* Free TX buffer */
466 r6040_free_txbufs(dev);
467
468 /* Free Descriptor memory */
469 pci_free_consistent(pdev, RX_DESC_SIZE, lp->rx_ring, lp->rx_ring_dma);
470 pci_free_consistent(pdev, TX_DESC_SIZE, lp->tx_ring, lp->tx_ring_dma);
471} 460}
472 461
473static int r6040_close(struct net_device *dev) 462static int r6040_close(struct net_device *dev)
474{ 463{
475 struct r6040_private *lp = netdev_priv(dev); 464 struct r6040_private *lp = netdev_priv(dev);
465 struct pci_dev *pdev = lp->pdev;
476 466
477 /* deleted timer */ 467 /* deleted timer */
478 del_timer_sync(&lp->timer); 468 del_timer_sync(&lp->timer);
@@ -481,8 +471,28 @@ static int r6040_close(struct net_device *dev)
481 napi_disable(&lp->napi); 471 napi_disable(&lp->napi);
482 netif_stop_queue(dev); 472 netif_stop_queue(dev);
483 r6040_down(dev); 473 r6040_down(dev);
474
475 free_irq(dev->irq, dev);
476
477 /* Free RX buffer */
478 r6040_free_rxbufs(dev);
479
480 /* Free TX buffer */
481 r6040_free_txbufs(dev);
482
484 spin_unlock_irq(&lp->lock); 483 spin_unlock_irq(&lp->lock);
485 484
485 /* Free Descriptor memory */
486 if (lp->rx_ring) {
487 pci_free_consistent(pdev, RX_DESC_SIZE, lp->rx_ring, lp->rx_ring_dma);
488 lp->rx_ring = 0;
489 }
490
491 if (lp->tx_ring) {
492 pci_free_consistent(pdev, TX_DESC_SIZE, lp->tx_ring, lp->tx_ring_dma);
493 lp->tx_ring = 0;
494 }
495
486 return 0; 496 return 0;
487} 497}
488 498
@@ -1049,6 +1059,7 @@ static const struct net_device_ops r6040_netdev_ops = {
1049 .ndo_set_multicast_list = r6040_multicast_list, 1059 .ndo_set_multicast_list = r6040_multicast_list,
1050 .ndo_change_mtu = eth_change_mtu, 1060 .ndo_change_mtu = eth_change_mtu,
1051 .ndo_validate_addr = eth_validate_addr, 1061 .ndo_validate_addr = eth_validate_addr,
1062 .ndo_set_mac_address = eth_mac_addr,
1052 .ndo_do_ioctl = r6040_ioctl, 1063 .ndo_do_ioctl = r6040_ioctl,
1053 .ndo_tx_timeout = r6040_tx_timeout, 1064 .ndo_tx_timeout = r6040_tx_timeout,
1054#ifdef CONFIG_NET_POLL_CONTROLLER 1065#ifdef CONFIG_NET_POLL_CONTROLLER
@@ -1143,8 +1154,10 @@ static int __devinit r6040_init_one(struct pci_dev *pdev,
1143 1154
1144 /* Some bootloader/BIOSes do not initialize 1155 /* Some bootloader/BIOSes do not initialize
1145 * MAC address, warn about that */ 1156 * MAC address, warn about that */
1146 if (!(adrp[0] || adrp[1] || adrp[2])) 1157 if (!(adrp[0] || adrp[1] || adrp[2])) {
1147 printk(KERN_WARNING DRV_NAME ": MAC address not initialized\n"); 1158 printk(KERN_WARNING DRV_NAME ": MAC address not initialized, generating random\n");
1159 random_ether_addr(dev->dev_addr);
1160 }
1148 1161
1149 /* Link new device into r6040_root_dev */ 1162 /* Link new device into r6040_root_dev */
1150 lp->pdev = pdev; 1163 lp->pdev = pdev;
diff --git a/drivers/net/sc92031.c b/drivers/net/sc92031.c
index 42fd3127660..8b75bef4a84 100644
--- a/drivers/net/sc92031.c
+++ b/drivers/net/sc92031.c
@@ -1408,6 +1408,7 @@ static const struct net_device_ops sc92031_netdev_ops = {
1408 .ndo_set_multicast_list = sc92031_set_multicast_list, 1408 .ndo_set_multicast_list = sc92031_set_multicast_list,
1409 .ndo_change_mtu = eth_change_mtu, 1409 .ndo_change_mtu = eth_change_mtu,
1410 .ndo_validate_addr = eth_validate_addr, 1410 .ndo_validate_addr = eth_validate_addr,
1411 .ndo_set_mac_address = eth_mac_addr,
1411 .ndo_tx_timeout = sc92031_tx_timeout, 1412 .ndo_tx_timeout = sc92031_tx_timeout,
1412#ifdef CONFIG_NET_POLL_CONTROLLER 1413#ifdef CONFIG_NET_POLL_CONTROLLER
1413 .ndo_poll_controller = sc92031_poll_controller, 1414 .ndo_poll_controller = sc92031_poll_controller,
diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c
index 7673fd92eaf..101c00a7bb7 100644
--- a/drivers/net/sfc/efx.c
+++ b/drivers/net/sfc/efx.c
@@ -854,20 +854,27 @@ static void efx_fini_io(struct efx_nic *efx)
854 * interrupts across them. */ 854 * interrupts across them. */
855static int efx_wanted_rx_queues(void) 855static int efx_wanted_rx_queues(void)
856{ 856{
857 cpumask_t core_mask; 857 cpumask_var_t core_mask;
858 int count; 858 int count;
859 int cpu; 859 int cpu;
860 860
861 cpus_clear(core_mask); 861 if (!alloc_cpumask_var(&core_mask, GFP_KERNEL)) {
862 printk(KERN_WARNING
863 "efx.c: allocation failure, irq balancing hobbled\n");
864 return 1;
865 }
866
867 cpumask_clear(core_mask);
862 count = 0; 868 count = 0;
863 for_each_online_cpu(cpu) { 869 for_each_online_cpu(cpu) {
864 if (!cpu_isset(cpu, core_mask)) { 870 if (!cpumask_test_cpu(cpu, core_mask)) {
865 ++count; 871 ++count;
866 cpus_or(core_mask, core_mask, 872 cpumask_or(core_mask, core_mask,
867 topology_core_siblings(cpu)); 873 topology_core_cpumask(cpu));
868 } 874 }
869 } 875 }
870 876
877 free_cpumask_var(core_mask);
871 return count; 878 return count;
872} 879}
873 880
diff --git a/drivers/net/sfc/tenxpress.c b/drivers/net/sfc/tenxpress.c
index b9768760fae..9ecb77da954 100644
--- a/drivers/net/sfc/tenxpress.c
+++ b/drivers/net/sfc/tenxpress.c
@@ -636,10 +636,11 @@ static void tenxpress_phy_fini(struct efx_nic *efx)
636{ 636{
637 int reg; 637 int reg;
638 638
639 if (efx->phy_type == PHY_TYPE_SFT9001B) { 639 if (efx->phy_type == PHY_TYPE_SFT9001B)
640 device_remove_file(&efx->pci_dev->dev, 640 device_remove_file(&efx->pci_dev->dev,
641 &dev_attr_phy_short_reach); 641 &dev_attr_phy_short_reach);
642 } else { 642
643 if (efx->phy_type == PHY_TYPE_SFX7101) {
643 /* Power down the LNPGA */ 644 /* Power down the LNPGA */
644 reg = (1 << PMA_PMD_LNPGA_POWERDOWN_LBN); 645 reg = (1 << PMA_PMD_LNPGA_POWERDOWN_LBN);
645 mdio_clause45_write(efx, efx->mii.phy_id, MDIO_MMD_PMAPMD, 646 mdio_clause45_write(efx, efx->mii.phy_id, MDIO_MMD_PMAPMD,
diff --git a/drivers/net/sis900.c b/drivers/net/sis900.c
index 4acd41a093a..6cbefcae9ac 100644
--- a/drivers/net/sis900.c
+++ b/drivers/net/sis900.c
@@ -389,6 +389,7 @@ static const struct net_device_ops sis900_netdev_ops = {
389 .ndo_set_multicast_list = set_rx_mode, 389 .ndo_set_multicast_list = set_rx_mode,
390 .ndo_change_mtu = eth_change_mtu, 390 .ndo_change_mtu = eth_change_mtu,
391 .ndo_validate_addr = eth_validate_addr, 391 .ndo_validate_addr = eth_validate_addr,
392 .ndo_set_mac_address = eth_mac_addr,
392 .ndo_do_ioctl = mii_ioctl, 393 .ndo_do_ioctl = mii_ioctl,
393 .ndo_tx_timeout = sis900_tx_timeout, 394 .ndo_tx_timeout = sis900_tx_timeout,
394#ifdef CONFIG_NET_POLL_CONTROLLER 395#ifdef CONFIG_NET_POLL_CONTROLLER
diff --git a/drivers/net/smc-mca.c b/drivers/net/smc-mca.c
index 404b80e5ba1..8d36d40649e 100644
--- a/drivers/net/smc-mca.c
+++ b/drivers/net/smc-mca.c
@@ -192,6 +192,7 @@ static const struct net_device_ops ultramca_netdev_ops = {
192 .ndo_get_stats = ei_get_stats, 192 .ndo_get_stats = ei_get_stats,
193 .ndo_set_multicast_list = ei_set_multicast_list, 193 .ndo_set_multicast_list = ei_set_multicast_list,
194 .ndo_validate_addr = eth_validate_addr, 194 .ndo_validate_addr = eth_validate_addr,
195 .ndo_set_mac_address = eth_mac_addr,
195 .ndo_change_mtu = eth_change_mtu, 196 .ndo_change_mtu = eth_change_mtu,
196#ifdef CONFIG_NET_POLL_CONTROLLER 197#ifdef CONFIG_NET_POLL_CONTROLLER
197 .ndo_poll_controller = ei_poll, 198 .ndo_poll_controller = ei_poll,
diff --git a/drivers/net/smc-ultra.c b/drivers/net/smc-ultra.c
index b3866089a20..2033fee3143 100644
--- a/drivers/net/smc-ultra.c
+++ b/drivers/net/smc-ultra.c
@@ -196,6 +196,7 @@ static const struct net_device_ops ultra_netdev_ops = {
196 .ndo_get_stats = ei_get_stats, 196 .ndo_get_stats = ei_get_stats,
197 .ndo_set_multicast_list = ei_set_multicast_list, 197 .ndo_set_multicast_list = ei_set_multicast_list,
198 .ndo_validate_addr = eth_validate_addr, 198 .ndo_validate_addr = eth_validate_addr,
199 .ndo_set_mac_address = eth_mac_addr,
199 .ndo_change_mtu = eth_change_mtu, 200 .ndo_change_mtu = eth_change_mtu,
200#ifdef CONFIG_NET_POLL_CONTROLLER 201#ifdef CONFIG_NET_POLL_CONTROLLER
201 .ndo_poll_controller = ei_poll, 202 .ndo_poll_controller = ei_poll,
diff --git a/drivers/net/smsc911x.c b/drivers/net/smsc911x.c
index dc3f1108884..f513bdf1c88 100644
--- a/drivers/net/smsc911x.c
+++ b/drivers/net/smsc911x.c
@@ -144,6 +144,7 @@ static inline u32 smsc911x_reg_read(struct smsc911x_data *pdata, u32 reg)
144 } 144 }
145 145
146 BUG(); 146 BUG();
147 return 0;
147} 148}
148 149
149static inline void smsc911x_reg_write(struct smsc911x_data *pdata, u32 reg, 150static inline void smsc911x_reg_write(struct smsc911x_data *pdata, u32 reg,
@@ -1740,6 +1741,7 @@ static const struct net_device_ops smsc911x_netdev_ops = {
1740 .ndo_set_multicast_list = smsc911x_set_multicast_list, 1741 .ndo_set_multicast_list = smsc911x_set_multicast_list,
1741 .ndo_do_ioctl = smsc911x_do_ioctl, 1742 .ndo_do_ioctl = smsc911x_do_ioctl,
1742 .ndo_validate_addr = eth_validate_addr, 1743 .ndo_validate_addr = eth_validate_addr,
1744 .ndo_set_mac_address = eth_mac_addr,
1743#ifdef CONFIG_NET_POLL_CONTROLLER 1745#ifdef CONFIG_NET_POLL_CONTROLLER
1744 .ndo_poll_controller = smsc911x_poll_controller, 1746 .ndo_poll_controller = smsc911x_poll_controller,
1745#endif 1747#endif
@@ -1967,7 +1969,7 @@ static int __devinit smsc911x_drv_probe(struct platform_device *pdev)
1967 smsc911x_reg_write(pdata, INT_STS, 0xFFFFFFFF); 1969 smsc911x_reg_write(pdata, INT_STS, 0xFFFFFFFF);
1968 1970
1969 retval = request_irq(dev->irq, smsc911x_irqhandler, IRQF_DISABLED, 1971 retval = request_irq(dev->irq, smsc911x_irqhandler, IRQF_DISABLED,
1970 SMSC_CHIPNAME, dev); 1972 dev->name, dev);
1971 if (retval) { 1973 if (retval) {
1972 SMSC_WARNING(PROBE, 1974 SMSC_WARNING(PROBE,
1973 "Unable to claim requested irq: %d", dev->irq); 1975 "Unable to claim requested irq: %d", dev->irq);
diff --git a/drivers/net/smsc9420.c b/drivers/net/smsc9420.c
index 27e017d9696..c14a4c6452c 100644
--- a/drivers/net/smsc9420.c
+++ b/drivers/net/smsc9420.c
@@ -1551,6 +1551,7 @@ static const struct net_device_ops smsc9420_netdev_ops = {
1551 .ndo_set_multicast_list = smsc9420_set_multicast_list, 1551 .ndo_set_multicast_list = smsc9420_set_multicast_list,
1552 .ndo_do_ioctl = smsc9420_do_ioctl, 1552 .ndo_do_ioctl = smsc9420_do_ioctl,
1553 .ndo_validate_addr = eth_validate_addr, 1553 .ndo_validate_addr = eth_validate_addr,
1554 .ndo_set_mac_address = eth_mac_addr,
1554#ifdef CONFIG_NET_POLL_CONTROLLER 1555#ifdef CONFIG_NET_POLL_CONTROLLER
1555 .ndo_poll_controller = smsc9420_poll_controller, 1556 .ndo_poll_controller = smsc9420_poll_controller,
1556#endif /* CONFIG_NET_POLL_CONTROLLER */ 1557#endif /* CONFIG_NET_POLL_CONTROLLER */
diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c
index 7d5a1303e30..11441225bf4 100644
--- a/drivers/net/ucc_geth.c
+++ b/drivers/net/ucc_geth.c
@@ -442,40 +442,30 @@ static void magic_packet_detection_enable(struct ucc_geth_private *ugeth)
442{ 442{
443 struct ucc_fast_private *uccf; 443 struct ucc_fast_private *uccf;
444 struct ucc_geth __iomem *ug_regs; 444 struct ucc_geth __iomem *ug_regs;
445 u32 maccfg2, uccm;
446 445
447 uccf = ugeth->uccf; 446 uccf = ugeth->uccf;
448 ug_regs = ugeth->ug_regs; 447 ug_regs = ugeth->ug_regs;
449 448
450 /* Enable interrupts for magic packet detection */ 449 /* Enable interrupts for magic packet detection */
451 uccm = in_be32(uccf->p_uccm); 450 setbits32(uccf->p_uccm, UCC_GETH_UCCE_MPD);
452 uccm |= UCCE_MPD;
453 out_be32(uccf->p_uccm, uccm);
454 451
455 /* Enable magic packet detection */ 452 /* Enable magic packet detection */
456 maccfg2 = in_be32(&ug_regs->maccfg2); 453 setbits32(&ug_regs->maccfg2, MACCFG2_MPE);
457 maccfg2 |= MACCFG2_MPE;
458 out_be32(&ug_regs->maccfg2, maccfg2);
459} 454}
460 455
461static void magic_packet_detection_disable(struct ucc_geth_private *ugeth) 456static void magic_packet_detection_disable(struct ucc_geth_private *ugeth)
462{ 457{
463 struct ucc_fast_private *uccf; 458 struct ucc_fast_private *uccf;
464 struct ucc_geth __iomem *ug_regs; 459 struct ucc_geth __iomem *ug_regs;
465 u32 maccfg2, uccm;
466 460
467 uccf = ugeth->uccf; 461 uccf = ugeth->uccf;
468 ug_regs = ugeth->ug_regs; 462 ug_regs = ugeth->ug_regs;
469 463
470 /* Disable interrupts for magic packet detection */ 464 /* Disable interrupts for magic packet detection */
471 uccm = in_be32(uccf->p_uccm); 465 clrbits32(uccf->p_uccm, UCC_GETH_UCCE_MPD);
472 uccm &= ~UCCE_MPD;
473 out_be32(uccf->p_uccm, uccm);
474 466
475 /* Disable magic packet detection */ 467 /* Disable magic packet detection */
476 maccfg2 = in_be32(&ug_regs->maccfg2); 468 clrbits32(&ug_regs->maccfg2, MACCFG2_MPE);
477 maccfg2 &= ~MACCFG2_MPE;
478 out_be32(&ug_regs->maccfg2, maccfg2);
479} 469}
480#endif /* MAGIC_PACKET */ 470#endif /* MAGIC_PACKET */
481 471
@@ -585,7 +575,8 @@ static void get_statistics(struct ucc_geth_private *ugeth,
585 575
586 /* Hardware only if user handed pointer and driver actually 576 /* Hardware only if user handed pointer and driver actually
587 gathers hardware statistics */ 577 gathers hardware statistics */
588 if (hardware_statistics && (in_be32(&uf_regs->upsmr) & UPSMR_HSE)) { 578 if (hardware_statistics &&
579 (in_be32(&uf_regs->upsmr) & UCC_GETH_UPSMR_HSE)) {
589 hardware_statistics->tx64 = in_be32(&ug_regs->tx64); 580 hardware_statistics->tx64 = in_be32(&ug_regs->tx64);
590 hardware_statistics->tx127 = in_be32(&ug_regs->tx127); 581 hardware_statistics->tx127 = in_be32(&ug_regs->tx127);
591 hardware_statistics->tx255 = in_be32(&ug_regs->tx255); 582 hardware_statistics->tx255 = in_be32(&ug_regs->tx255);
@@ -1181,9 +1172,7 @@ int init_flow_control_params(u32 automatic_flow_control_mode,
1181 out_be32(uempr_register, value); 1172 out_be32(uempr_register, value);
1182 1173
1183 /* Set UPSMR register */ 1174 /* Set UPSMR register */
1184 value = in_be32(upsmr_register); 1175 setbits32(upsmr_register, automatic_flow_control_mode);
1185 value |= automatic_flow_control_mode;
1186 out_be32(upsmr_register, value);
1187 1176
1188 value = in_be32(maccfg1_register); 1177 value = in_be32(maccfg1_register);
1189 if (rx_flow_control_enable) 1178 if (rx_flow_control_enable)
@@ -1200,14 +1189,11 @@ static int init_hw_statistics_gathering_mode(int enable_hardware_statistics,
1200 u32 __iomem *upsmr_register, 1189 u32 __iomem *upsmr_register,
1201 u16 __iomem *uescr_register) 1190 u16 __iomem *uescr_register)
1202{ 1191{
1203 u32 upsmr_value = 0;
1204 u16 uescr_value = 0; 1192 u16 uescr_value = 0;
1193
1205 /* Enable hardware statistics gathering if requested */ 1194 /* Enable hardware statistics gathering if requested */
1206 if (enable_hardware_statistics) { 1195 if (enable_hardware_statistics)
1207 upsmr_value = in_be32(upsmr_register); 1196 setbits32(upsmr_register, UCC_GETH_UPSMR_HSE);
1208 upsmr_value |= UPSMR_HSE;
1209 out_be32(upsmr_register, upsmr_value);
1210 }
1211 1197
1212 /* Clear hardware statistics counters */ 1198 /* Clear hardware statistics counters */
1213 uescr_value = in_be16(uescr_register); 1199 uescr_value = in_be16(uescr_register);
@@ -1233,23 +1219,17 @@ static int init_firmware_statistics_gathering_mode(int
1233{ 1219{
1234 /* Note: this function does not check if */ 1220 /* Note: this function does not check if */
1235 /* the parameters it receives are NULL */ 1221 /* the parameters it receives are NULL */
1236 u16 temoder_value;
1237 u32 remoder_value;
1238 1222
1239 if (enable_tx_firmware_statistics) { 1223 if (enable_tx_firmware_statistics) {
1240 out_be32(tx_rmon_base_ptr, 1224 out_be32(tx_rmon_base_ptr,
1241 tx_firmware_statistics_structure_address); 1225 tx_firmware_statistics_structure_address);
1242 temoder_value = in_be16(temoder_register); 1226 setbits16(temoder_register, TEMODER_TX_RMON_STATISTICS_ENABLE);
1243 temoder_value |= TEMODER_TX_RMON_STATISTICS_ENABLE;
1244 out_be16(temoder_register, temoder_value);
1245 } 1227 }
1246 1228
1247 if (enable_rx_firmware_statistics) { 1229 if (enable_rx_firmware_statistics) {
1248 out_be32(rx_rmon_base_ptr, 1230 out_be32(rx_rmon_base_ptr,
1249 rx_firmware_statistics_structure_address); 1231 rx_firmware_statistics_structure_address);
1250 remoder_value = in_be32(remoder_register); 1232 setbits32(remoder_register, REMODER_RX_RMON_STATISTICS_ENABLE);
1251 remoder_value |= REMODER_RX_RMON_STATISTICS_ENABLE;
1252 out_be32(remoder_register, remoder_value);
1253 } 1233 }
1254 1234
1255 return 0; 1235 return 0;
@@ -1316,15 +1296,12 @@ static int init_check_frame_length_mode(int length_check,
1316static int init_preamble_length(u8 preamble_length, 1296static int init_preamble_length(u8 preamble_length,
1317 u32 __iomem *maccfg2_register) 1297 u32 __iomem *maccfg2_register)
1318{ 1298{
1319 u32 value = 0;
1320
1321 if ((preamble_length < 3) || (preamble_length > 7)) 1299 if ((preamble_length < 3) || (preamble_length > 7))
1322 return -EINVAL; 1300 return -EINVAL;
1323 1301
1324 value = in_be32(maccfg2_register); 1302 clrsetbits_be32(maccfg2_register, MACCFG2_PREL_MASK,
1325 value &= ~MACCFG2_PREL_MASK; 1303 preamble_length << MACCFG2_PREL_SHIFT);
1326 value |= (preamble_length << MACCFG2_PREL_SHIFT); 1304
1327 out_be32(maccfg2_register, value);
1328 return 0; 1305 return 0;
1329} 1306}
1330 1307
@@ -1337,19 +1314,19 @@ static int init_rx_parameters(int reject_broadcast,
1337 value = in_be32(upsmr_register); 1314 value = in_be32(upsmr_register);
1338 1315
1339 if (reject_broadcast) 1316 if (reject_broadcast)
1340 value |= UPSMR_BRO; 1317 value |= UCC_GETH_UPSMR_BRO;
1341 else 1318 else
1342 value &= ~UPSMR_BRO; 1319 value &= ~UCC_GETH_UPSMR_BRO;
1343 1320
1344 if (receive_short_frames) 1321 if (receive_short_frames)
1345 value |= UPSMR_RSH; 1322 value |= UCC_GETH_UPSMR_RSH;
1346 else 1323 else
1347 value &= ~UPSMR_RSH; 1324 value &= ~UCC_GETH_UPSMR_RSH;
1348 1325
1349 if (promiscuous) 1326 if (promiscuous)
1350 value |= UPSMR_PRO; 1327 value |= UCC_GETH_UPSMR_PRO;
1351 else 1328 else
1352 value &= ~UPSMR_PRO; 1329 value &= ~UCC_GETH_UPSMR_PRO;
1353 1330
1354 out_be32(upsmr_register, value); 1331 out_be32(upsmr_register, value);
1355 1332
@@ -1410,26 +1387,27 @@ static int adjust_enet_interface(struct ucc_geth_private *ugeth)
1410 1387
1411 /* Set UPSMR */ 1388 /* Set UPSMR */
1412 upsmr = in_be32(&uf_regs->upsmr); 1389 upsmr = in_be32(&uf_regs->upsmr);
1413 upsmr &= ~(UPSMR_RPM | UPSMR_R10M | UPSMR_TBIM | UPSMR_RMM); 1390 upsmr &= ~(UCC_GETH_UPSMR_RPM | UCC_GETH_UPSMR_R10M |
1391 UCC_GETH_UPSMR_TBIM | UCC_GETH_UPSMR_RMM);
1414 if ((ugeth->phy_interface == PHY_INTERFACE_MODE_RMII) || 1392 if ((ugeth->phy_interface == PHY_INTERFACE_MODE_RMII) ||
1415 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII) || 1393 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII) ||
1416 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII_ID) || 1394 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII_ID) ||
1417 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII_RXID) || 1395 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII_RXID) ||
1418 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID) || 1396 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID) ||
1419 (ugeth->phy_interface == PHY_INTERFACE_MODE_RTBI)) { 1397 (ugeth->phy_interface == PHY_INTERFACE_MODE_RTBI)) {
1420 upsmr |= UPSMR_RPM; 1398 upsmr |= UCC_GETH_UPSMR_RPM;
1421 switch (ugeth->max_speed) { 1399 switch (ugeth->max_speed) {
1422 case SPEED_10: 1400 case SPEED_10:
1423 upsmr |= UPSMR_R10M; 1401 upsmr |= UCC_GETH_UPSMR_R10M;
1424 /* FALLTHROUGH */ 1402 /* FALLTHROUGH */
1425 case SPEED_100: 1403 case SPEED_100:
1426 if (ugeth->phy_interface != PHY_INTERFACE_MODE_RTBI) 1404 if (ugeth->phy_interface != PHY_INTERFACE_MODE_RTBI)
1427 upsmr |= UPSMR_RMM; 1405 upsmr |= UCC_GETH_UPSMR_RMM;
1428 } 1406 }
1429 } 1407 }
1430 if ((ugeth->phy_interface == PHY_INTERFACE_MODE_TBI) || 1408 if ((ugeth->phy_interface == PHY_INTERFACE_MODE_TBI) ||
1431 (ugeth->phy_interface == PHY_INTERFACE_MODE_RTBI)) { 1409 (ugeth->phy_interface == PHY_INTERFACE_MODE_RTBI)) {
1432 upsmr |= UPSMR_TBIM; 1410 upsmr |= UCC_GETH_UPSMR_TBIM;
1433 } 1411 }
1434 out_be32(&uf_regs->upsmr, upsmr); 1412 out_be32(&uf_regs->upsmr, upsmr);
1435 1413
@@ -1517,9 +1495,9 @@ static void adjust_link(struct net_device *dev)
1517 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID) || 1495 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID) ||
1518 (ugeth->phy_interface == PHY_INTERFACE_MODE_RTBI)) { 1496 (ugeth->phy_interface == PHY_INTERFACE_MODE_RTBI)) {
1519 if (phydev->speed == SPEED_10) 1497 if (phydev->speed == SPEED_10)
1520 upsmr |= UPSMR_R10M; 1498 upsmr |= UCC_GETH_UPSMR_R10M;
1521 else 1499 else
1522 upsmr &= ~(UPSMR_R10M); 1500 upsmr &= ~UCC_GETH_UPSMR_R10M;
1523 } 1501 }
1524 break; 1502 break;
1525 default: 1503 default:
@@ -1602,10 +1580,8 @@ static int ugeth_graceful_stop_tx(struct ucc_geth_private *ugeth)
1602 uccf = ugeth->uccf; 1580 uccf = ugeth->uccf;
1603 1581
1604 /* Mask GRACEFUL STOP TX interrupt bit and clear it */ 1582 /* Mask GRACEFUL STOP TX interrupt bit and clear it */
1605 temp = in_be32(uccf->p_uccm); 1583 clrbits32(uccf->p_uccm, UCC_GETH_UCCE_GRA);
1606 temp &= ~UCCE_GRA; 1584 out_be32(uccf->p_ucce, UCC_GETH_UCCE_GRA); /* clear by writing 1 */
1607 out_be32(uccf->p_uccm, temp);
1608 out_be32(uccf->p_ucce, UCCE_GRA); /* clear by writing 1 */
1609 1585
1610 /* Issue host command */ 1586 /* Issue host command */
1611 cecr_subblock = 1587 cecr_subblock =
@@ -1617,7 +1593,7 @@ static int ugeth_graceful_stop_tx(struct ucc_geth_private *ugeth)
1617 do { 1593 do {
1618 msleep(10); 1594 msleep(10);
1619 temp = in_be32(uccf->p_ucce); 1595 temp = in_be32(uccf->p_ucce);
1620 } while (!(temp & UCCE_GRA) && --i); 1596 } while (!(temp & UCC_GETH_UCCE_GRA) && --i);
1621 1597
1622 uccf->stopped_tx = 1; 1598 uccf->stopped_tx = 1;
1623 1599
@@ -1975,12 +1951,9 @@ static void ucc_geth_set_multi(struct net_device *dev)
1975 uf_regs = ugeth->uccf->uf_regs; 1951 uf_regs = ugeth->uccf->uf_regs;
1976 1952
1977 if (dev->flags & IFF_PROMISC) { 1953 if (dev->flags & IFF_PROMISC) {
1978 1954 setbits32(&uf_regs->upsmr, UCC_GETH_UPSMR_PRO);
1979 out_be32(&uf_regs->upsmr, in_be32(&uf_regs->upsmr) | UPSMR_PRO);
1980
1981 } else { 1955 } else {
1982 1956 clrbits32(&uf_regs->upsmr, UCC_GETH_UPSMR_PRO);
1983 out_be32(&uf_regs->upsmr, in_be32(&uf_regs->upsmr)&~UPSMR_PRO);
1984 1957
1985 p_82xx_addr_filt = 1958 p_82xx_addr_filt =
1986 (struct ucc_geth_82xx_address_filtering_pram __iomem *) ugeth-> 1959 (struct ucc_geth_82xx_address_filtering_pram __iomem *) ugeth->
@@ -2020,7 +1993,6 @@ static void ucc_geth_stop(struct ucc_geth_private *ugeth)
2020{ 1993{
2021 struct ucc_geth __iomem *ug_regs = ugeth->ug_regs; 1994 struct ucc_geth __iomem *ug_regs = ugeth->ug_regs;
2022 struct phy_device *phydev = ugeth->phydev; 1995 struct phy_device *phydev = ugeth->phydev;
2023 u32 tempval;
2024 1996
2025 ugeth_vdbg("%s: IN", __func__); 1997 ugeth_vdbg("%s: IN", __func__);
2026 1998
@@ -2037,9 +2009,7 @@ static void ucc_geth_stop(struct ucc_geth_private *ugeth)
2037 out_be32(ugeth->uccf->p_ucce, 0xffffffff); 2009 out_be32(ugeth->uccf->p_ucce, 0xffffffff);
2038 2010
2039 /* Disable Rx and Tx */ 2011 /* Disable Rx and Tx */
2040 tempval = in_be32(&ug_regs->maccfg1); 2012 clrbits32(&ug_regs->maccfg1, MACCFG1_ENABLE_RX | MACCFG1_ENABLE_TX);
2041 tempval &= ~(MACCFG1_ENABLE_RX | MACCFG1_ENABLE_TX);
2042 out_be32(&ug_regs->maccfg1, tempval);
2043 2013
2044 ucc_geth_memclean(ugeth); 2014 ucc_geth_memclean(ugeth);
2045} 2015}
@@ -2153,10 +2123,10 @@ static int ucc_struct_init(struct ucc_geth_private *ugeth)
2153 /* Generate uccm_mask for receive */ 2123 /* Generate uccm_mask for receive */
2154 uf_info->uccm_mask = ug_info->eventRegMask & UCCE_OTHER;/* Errors */ 2124 uf_info->uccm_mask = ug_info->eventRegMask & UCCE_OTHER;/* Errors */
2155 for (i = 0; i < ug_info->numQueuesRx; i++) 2125 for (i = 0; i < ug_info->numQueuesRx; i++)
2156 uf_info->uccm_mask |= (UCCE_RXBF_SINGLE_MASK << i); 2126 uf_info->uccm_mask |= (UCC_GETH_UCCE_RXF0 << i);
2157 2127
2158 for (i = 0; i < ug_info->numQueuesTx; i++) 2128 for (i = 0; i < ug_info->numQueuesTx; i++)
2159 uf_info->uccm_mask |= (UCCE_TXBF_SINGLE_MASK << i); 2129 uf_info->uccm_mask |= (UCC_GETH_UCCE_TXB0 << i);
2160 /* Initialize the general fast UCC block. */ 2130 /* Initialize the general fast UCC block. */
2161 if (ucc_fast_init(uf_info, &ugeth->uccf)) { 2131 if (ucc_fast_init(uf_info, &ugeth->uccf)) {
2162 if (netif_msg_probe(ugeth)) 2132 if (netif_msg_probe(ugeth))
@@ -2185,7 +2155,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2185 struct ucc_geth __iomem *ug_regs; 2155 struct ucc_geth __iomem *ug_regs;
2186 int ret_val = -EINVAL; 2156 int ret_val = -EINVAL;
2187 u32 remoder = UCC_GETH_REMODER_INIT; 2157 u32 remoder = UCC_GETH_REMODER_INIT;
2188 u32 init_enet_pram_offset, cecr_subblock, command, maccfg1; 2158 u32 init_enet_pram_offset, cecr_subblock, command;
2189 u32 ifstat, i, j, size, l2qt, l3qt, length; 2159 u32 ifstat, i, j, size, l2qt, l3qt, length;
2190 u16 temoder = UCC_GETH_TEMODER_INIT; 2160 u16 temoder = UCC_GETH_TEMODER_INIT;
2191 u16 test; 2161 u16 test;
@@ -2281,10 +2251,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2281 &uf_regs->upsmr, 2251 &uf_regs->upsmr,
2282 &ug_regs->uempr, &ug_regs->maccfg1); 2252 &ug_regs->uempr, &ug_regs->maccfg1);
2283 2253
2284 maccfg1 = in_be32(&ug_regs->maccfg1); 2254 setbits32(&ug_regs->maccfg1, MACCFG1_ENABLE_RX | MACCFG1_ENABLE_TX);
2285 maccfg1 |= MACCFG1_ENABLE_RX;
2286 maccfg1 |= MACCFG1_ENABLE_TX;
2287 out_be32(&ug_regs->maccfg1, maccfg1);
2288 2255
2289 /* Set IPGIFG */ 2256 /* Set IPGIFG */
2290 /* For more details see the hardware spec. */ 2257 /* For more details see the hardware spec. */
@@ -3274,7 +3241,6 @@ static int ucc_geth_tx(struct net_device *dev, u8 txQ)
3274static int ucc_geth_poll(struct napi_struct *napi, int budget) 3241static int ucc_geth_poll(struct napi_struct *napi, int budget)
3275{ 3242{
3276 struct ucc_geth_private *ugeth = container_of(napi, struct ucc_geth_private, napi); 3243 struct ucc_geth_private *ugeth = container_of(napi, struct ucc_geth_private, napi);
3277 struct net_device *dev = ugeth->dev;
3278 struct ucc_geth_info *ug_info; 3244 struct ucc_geth_info *ug_info;
3279 int howmany, i; 3245 int howmany, i;
3280 3246
@@ -3285,14 +3251,8 @@ static int ucc_geth_poll(struct napi_struct *napi, int budget)
3285 howmany += ucc_geth_rx(ugeth, i, budget - howmany); 3251 howmany += ucc_geth_rx(ugeth, i, budget - howmany);
3286 3252
3287 if (howmany < budget) { 3253 if (howmany < budget) {
3288 struct ucc_fast_private *uccf;
3289 u32 uccm;
3290
3291 netif_rx_complete(napi); 3254 netif_rx_complete(napi);
3292 uccf = ugeth->uccf; 3255 setbits32(ugeth->uccf->p_uccm, UCCE_RX_EVENTS);
3293 uccm = in_be32(uccf->p_uccm);
3294 uccm |= UCCE_RX_EVENTS;
3295 out_be32(uccf->p_uccm, uccm);
3296 } 3256 }
3297 3257
3298 return howmany; 3258 return howmany;
@@ -3332,7 +3292,7 @@ static irqreturn_t ucc_geth_irq_handler(int irq, void *info)
3332 /* Tx event processing */ 3292 /* Tx event processing */
3333 if (ucce & UCCE_TX_EVENTS) { 3293 if (ucce & UCCE_TX_EVENTS) {
3334 spin_lock(&ugeth->lock); 3294 spin_lock(&ugeth->lock);
3335 tx_mask = UCCE_TXBF_SINGLE_MASK; 3295 tx_mask = UCC_GETH_UCCE_TXB0;
3336 for (i = 0; i < ug_info->numQueuesTx; i++) { 3296 for (i = 0; i < ug_info->numQueuesTx; i++) {
3337 if (ucce & tx_mask) 3297 if (ucce & tx_mask)
3338 ucc_geth_tx(dev, i); 3298 ucc_geth_tx(dev, i);
@@ -3344,12 +3304,10 @@ static irqreturn_t ucc_geth_irq_handler(int irq, void *info)
3344 3304
3345 /* Errors and other events */ 3305 /* Errors and other events */
3346 if (ucce & UCCE_OTHER) { 3306 if (ucce & UCCE_OTHER) {
3347 if (ucce & UCCE_BSY) { 3307 if (ucce & UCC_GETH_UCCE_BSY)
3348 dev->stats.rx_errors++; 3308 dev->stats.rx_errors++;
3349 } 3309 if (ucce & UCC_GETH_UCCE_TXE)
3350 if (ucce & UCCE_TXE) {
3351 dev->stats.tx_errors++; 3310 dev->stats.tx_errors++;
3352 }
3353 } 3311 }
3354 3312
3355 return IRQ_HANDLED; 3313 return IRQ_HANDLED;
diff --git a/drivers/net/ucc_geth.h b/drivers/net/ucc_geth.h
index d74d2f7cb73..8f699cb773e 100644
--- a/drivers/net/ucc_geth.h
+++ b/drivers/net/ucc_geth.h
@@ -162,92 +162,27 @@ struct ucc_geth {
162 boundary */ 162 boundary */
163 163
164/* UCC GETH Event Register */ 164/* UCC GETH Event Register */
165#define UCCE_MPD 0x80000000 /* Magic packet 165#define UCCE_TXB (UCC_GETH_UCCE_TXB7 | UCC_GETH_UCCE_TXB6 | \
166 detection */ 166 UCC_GETH_UCCE_TXB5 | UCC_GETH_UCCE_TXB4 | \
167#define UCCE_SCAR 0x40000000 167 UCC_GETH_UCCE_TXB3 | UCC_GETH_UCCE_TXB2 | \
168#define UCCE_GRA 0x20000000 /* Tx graceful 168 UCC_GETH_UCCE_TXB1 | UCC_GETH_UCCE_TXB0)
169 stop 169
170 complete */ 170#define UCCE_RXB (UCC_GETH_UCCE_RXB7 | UCC_GETH_UCCE_RXB6 | \
171#define UCCE_CBPR 0x10000000 171 UCC_GETH_UCCE_RXB5 | UCC_GETH_UCCE_RXB4 | \
172#define UCCE_BSY 0x08000000 172 UCC_GETH_UCCE_RXB3 | UCC_GETH_UCCE_RXB2 | \
173#define UCCE_RXC 0x04000000 173 UCC_GETH_UCCE_RXB1 | UCC_GETH_UCCE_RXB0)
174#define UCCE_TXC 0x02000000 174
175#define UCCE_TXE 0x01000000 175#define UCCE_RXF (UCC_GETH_UCCE_RXF7 | UCC_GETH_UCCE_RXF6 | \
176#define UCCE_TXB7 0x00800000 176 UCC_GETH_UCCE_RXF5 | UCC_GETH_UCCE_RXF4 | \
177#define UCCE_TXB6 0x00400000 177 UCC_GETH_UCCE_RXF3 | UCC_GETH_UCCE_RXF2 | \
178#define UCCE_TXB5 0x00200000 178 UCC_GETH_UCCE_RXF1 | UCC_GETH_UCCE_RXF0)
179#define UCCE_TXB4 0x00100000 179
180#define UCCE_TXB3 0x00080000 180#define UCCE_OTHER (UCC_GETH_UCCE_SCAR | UCC_GETH_UCCE_GRA | \
181#define UCCE_TXB2 0x00040000 181 UCC_GETH_UCCE_CBPR | UCC_GETH_UCCE_BSY | \
182#define UCCE_TXB1 0x00020000 182 UCC_GETH_UCCE_RXC | UCC_GETH_UCCE_TXC | UCC_GETH_UCCE_TXE)
183#define UCCE_TXB0 0x00010000 183
184#define UCCE_RXB7 0x00008000 184#define UCCE_RX_EVENTS (UCCE_RXF | UCC_GETH_UCCE_BSY)
185#define UCCE_RXB6 0x00004000 185#define UCCE_TX_EVENTS (UCCE_TXB | UCC_GETH_UCCE_TXE)
186#define UCCE_RXB5 0x00002000
187#define UCCE_RXB4 0x00001000
188#define UCCE_RXB3 0x00000800
189#define UCCE_RXB2 0x00000400
190#define UCCE_RXB1 0x00000200
191#define UCCE_RXB0 0x00000100
192#define UCCE_RXF7 0x00000080
193#define UCCE_RXF6 0x00000040
194#define UCCE_RXF5 0x00000020
195#define UCCE_RXF4 0x00000010
196#define UCCE_RXF3 0x00000008
197#define UCCE_RXF2 0x00000004
198#define UCCE_RXF1 0x00000002
199#define UCCE_RXF0 0x00000001
200
201#define UCCE_RXBF_SINGLE_MASK (UCCE_RXF0)
202#define UCCE_TXBF_SINGLE_MASK (UCCE_TXB0)
203
204#define UCCE_TXB (UCCE_TXB7 | UCCE_TXB6 | UCCE_TXB5 | UCCE_TXB4 |\
205 UCCE_TXB3 | UCCE_TXB2 | UCCE_TXB1 | UCCE_TXB0)
206#define UCCE_RXB (UCCE_RXB7 | UCCE_RXB6 | UCCE_RXB5 | UCCE_RXB4 |\
207 UCCE_RXB3 | UCCE_RXB2 | UCCE_RXB1 | UCCE_RXB0)
208#define UCCE_RXF (UCCE_RXF7 | UCCE_RXF6 | UCCE_RXF5 | UCCE_RXF4 |\
209 UCCE_RXF3 | UCCE_RXF2 | UCCE_RXF1 | UCCE_RXF0)
210#define UCCE_OTHER (UCCE_SCAR | UCCE_GRA | UCCE_CBPR | UCCE_BSY |\
211 UCCE_RXC | UCCE_TXC | UCCE_TXE)
212
213#define UCCE_RX_EVENTS (UCCE_RXF | UCCE_BSY)
214#define UCCE_TX_EVENTS (UCCE_TXB | UCCE_TXE)
215
216/* UCC GETH UPSMR (Protocol Specific Mode Register) */
217#define UPSMR_ECM 0x04000000 /* Enable CAM
218 Miss or
219 Enable
220 Filtering
221 Miss */
222#define UPSMR_HSE 0x02000000 /* Hardware
223 Statistics
224 Enable */
225#define UPSMR_PRO 0x00400000 /* Promiscuous*/
226#define UPSMR_CAP 0x00200000 /* CAM polarity
227 */
228#define UPSMR_RSH 0x00100000 /* Receive
229 Short Frames
230 */
231#define UPSMR_RPM 0x00080000 /* Reduced Pin
232 Mode
233 interfaces */
234#define UPSMR_R10M 0x00040000 /* RGMII/RMII
235 10 Mode */
236#define UPSMR_RLPB 0x00020000 /* RMII
237 Loopback
238 Mode */
239#define UPSMR_TBIM 0x00010000 /* Ten-bit
240 Interface
241 Mode */
242#define UPSMR_RMM 0x00001000 /* RMII/RGMII
243 Mode */
244#define UPSMR_CAM 0x00000400 /* CAM Address
245 Matching */
246#define UPSMR_BRO 0x00000200 /* Broadcast
247 Address */
248#define UPSMR_RES1 0x00002000 /* Reserved
249 feild - must
250 be 1 */
251 186
252/* UCC GETH MACCFG1 (MAC Configuration 1 Register) */ 187/* UCC GETH MACCFG1 (MAC Configuration 1 Register) */
253#define MACCFG1_FLOW_RX 0x00000020 /* Flow Control 188#define MACCFG1_FLOW_RX 0x00000020 /* Flow Control
@@ -945,9 +880,10 @@ struct ucc_geth_hardware_statistics {
945#define UCC_GETH_REMODER_INIT 0 /* bits that must be 880#define UCC_GETH_REMODER_INIT 0 /* bits that must be
946 set */ 881 set */
947#define UCC_GETH_TEMODER_INIT 0xC000 /* bits that must */ 882#define UCC_GETH_TEMODER_INIT 0xC000 /* bits that must */
948#define UCC_GETH_UPSMR_INIT (UPSMR_RES1) /* Start value 883
949 for this 884/* Initial value for UPSMR */
950 register */ 885#define UCC_GETH_UPSMR_INIT UCC_GETH_UPSMR_RES1
886
951#define UCC_GETH_MACCFG1_INIT 0 887#define UCC_GETH_MACCFG1_INIT 0
952#define UCC_GETH_MACCFG2_INIT (MACCFG2_RESERVED_1) 888#define UCC_GETH_MACCFG2_INIT (MACCFG2_RESERVED_1)
953 889
diff --git a/drivers/net/via-rhine.c b/drivers/net/via-rhine.c
index ac07cc6e3cb..3b8e6325427 100644
--- a/drivers/net/via-rhine.c
+++ b/drivers/net/via-rhine.c
@@ -622,6 +622,7 @@ static const struct net_device_ops rhine_netdev_ops = {
622 .ndo_get_stats = rhine_get_stats, 622 .ndo_get_stats = rhine_get_stats,
623 .ndo_set_multicast_list = rhine_set_rx_mode, 623 .ndo_set_multicast_list = rhine_set_rx_mode,
624 .ndo_validate_addr = eth_validate_addr, 624 .ndo_validate_addr = eth_validate_addr,
625 .ndo_set_mac_address = eth_mac_addr,
625 .ndo_do_ioctl = netdev_ioctl, 626 .ndo_do_ioctl = netdev_ioctl,
626 .ndo_tx_timeout = rhine_tx_timeout, 627 .ndo_tx_timeout = rhine_tx_timeout,
627#ifdef CONFIG_NET_POLL_CONTROLLER 628#ifdef CONFIG_NET_POLL_CONTROLLER
diff --git a/drivers/net/via-velocity.c b/drivers/net/via-velocity.c
index 58e25d090ae..a75f91dc315 100644
--- a/drivers/net/via-velocity.c
+++ b/drivers/net/via-velocity.c
@@ -855,6 +855,7 @@ static const struct net_device_ops velocity_netdev_ops = {
855 .ndo_start_xmit = velocity_xmit, 855 .ndo_start_xmit = velocity_xmit,
856 .ndo_get_stats = velocity_get_stats, 856 .ndo_get_stats = velocity_get_stats,
857 .ndo_validate_addr = eth_validate_addr, 857 .ndo_validate_addr = eth_validate_addr,
858 .ndo_set_mac_address = eth_mac_addr,
858 .ndo_set_multicast_list = velocity_set_multi, 859 .ndo_set_multicast_list = velocity_set_multi,
859 .ndo_change_mtu = velocity_change_mtu, 860 .ndo_change_mtu = velocity_change_mtu,
860 .ndo_do_ioctl = velocity_ioctl, 861 .ndo_do_ioctl = velocity_ioctl,
diff --git a/drivers/net/wd.c b/drivers/net/wd.c
index 3c1edda08d3..d8322d2d1e2 100644
--- a/drivers/net/wd.c
+++ b/drivers/net/wd.c
@@ -155,6 +155,7 @@ static const struct net_device_ops wd_netdev_ops = {
155 .ndo_get_stats = ei_get_stats, 155 .ndo_get_stats = ei_get_stats,
156 .ndo_set_multicast_list = ei_set_multicast_list, 156 .ndo_set_multicast_list = ei_set_multicast_list,
157 .ndo_validate_addr = eth_validate_addr, 157 .ndo_validate_addr = eth_validate_addr,
158 .ndo_set_mac_address = eth_mac_addr,
158 .ndo_change_mtu = eth_change_mtu, 159 .ndo_change_mtu = eth_change_mtu,
159#ifdef CONFIG_NET_POLL_CONTROLLER 160#ifdef CONFIG_NET_POLL_CONTROLLER
160 .ndo_poll_controller = ei_poll, 161 .ndo_poll_controller = ei_poll,
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c
index 3dba8367944..4e0007d2003 100644
--- a/drivers/net/wireless/libertas/main.c
+++ b/drivers/net/wireless/libertas/main.c
@@ -1369,7 +1369,7 @@ EXPORT_SYMBOL_GPL(lbs_start_card);
1369 1369
1370void lbs_stop_card(struct lbs_private *priv) 1370void lbs_stop_card(struct lbs_private *priv)
1371{ 1371{
1372 struct net_device *dev = priv->dev; 1372 struct net_device *dev;
1373 struct cmd_ctrl_node *cmdnode; 1373 struct cmd_ctrl_node *cmdnode;
1374 unsigned long flags; 1374 unsigned long flags;
1375 1375
@@ -1377,9 +1377,10 @@ void lbs_stop_card(struct lbs_private *priv)
1377 1377
1378 if (!priv) 1378 if (!priv)
1379 goto out; 1379 goto out;
1380 dev = priv->dev;
1380 1381
1381 netif_stop_queue(priv->dev); 1382 netif_stop_queue(dev);
1382 netif_carrier_off(priv->dev); 1383 netif_carrier_off(dev);
1383 1384
1384 lbs_debugfs_remove_one(priv); 1385 lbs_debugfs_remove_one(priv);
1385 if (priv->mesh_tlv) { 1386 if (priv->mesh_tlv) {
diff --git a/drivers/net/yellowfin.c b/drivers/net/yellowfin.c
index cf971292277..2f1645dcb8c 100644
--- a/drivers/net/yellowfin.c
+++ b/drivers/net/yellowfin.c
@@ -362,6 +362,7 @@ static const struct net_device_ops netdev_ops = {
362 .ndo_set_multicast_list = set_rx_mode, 362 .ndo_set_multicast_list = set_rx_mode,
363 .ndo_change_mtu = eth_change_mtu, 363 .ndo_change_mtu = eth_change_mtu,
364 .ndo_validate_addr = eth_validate_addr, 364 .ndo_validate_addr = eth_validate_addr,
365 .ndo_set_mac_address = eth_mac_addr,
365 .ndo_do_ioctl = netdev_ioctl, 366 .ndo_do_ioctl = netdev_ioctl,
366 .ndo_tx_timeout = yellowfin_tx_timeout, 367 .ndo_tx_timeout = yellowfin_tx_timeout,
367}; 368};
diff --git a/drivers/net/zorro8390.c b/drivers/net/zorro8390.c
index affd904deaf..37c84e3b8be 100644
--- a/drivers/net/zorro8390.c
+++ b/drivers/net/zorro8390.c
@@ -147,6 +147,7 @@ static const struct net_device_ops zorro8390_netdev_ops = {
147 .ndo_get_stats = ei_get_stats, 147 .ndo_get_stats = ei_get_stats,
148 .ndo_set_multicast_list = ei_set_multicast_list, 148 .ndo_set_multicast_list = ei_set_multicast_list,
149 .ndo_validate_addr = eth_validate_addr, 149 .ndo_validate_addr = eth_validate_addr,
150 .ndo_set_mac_address = eth_mac_addr,
150 .ndo_change_mtu = eth_change_mtu, 151 .ndo_change_mtu = eth_change_mtu,
151#ifdef CONFIG_NET_POLL_CONTROLLER 152#ifdef CONFIG_NET_POLL_CONTROLLER
152 .ndo_poll_controller = ei_poll, 153 .ndo_poll_controller = ei_poll,
diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
index 9da5a4b8113..c3ea5fa7d05 100644
--- a/drivers/oprofile/buffer_sync.c
+++ b/drivers/oprofile/buffer_sync.c
@@ -38,7 +38,7 @@
38 38
39static LIST_HEAD(dying_tasks); 39static LIST_HEAD(dying_tasks);
40static LIST_HEAD(dead_tasks); 40static LIST_HEAD(dead_tasks);
41static cpumask_t marked_cpus = CPU_MASK_NONE; 41static cpumask_var_t marked_cpus;
42static DEFINE_SPINLOCK(task_mortuary); 42static DEFINE_SPINLOCK(task_mortuary);
43static void process_task_mortuary(void); 43static void process_task_mortuary(void);
44 44
@@ -456,10 +456,10 @@ static void mark_done(int cpu)
456{ 456{
457 int i; 457 int i;
458 458
459 cpu_set(cpu, marked_cpus); 459 cpumask_set_cpu(cpu, marked_cpus);
460 460
461 for_each_online_cpu(i) { 461 for_each_online_cpu(i) {
462 if (!cpu_isset(i, marked_cpus)) 462 if (!cpumask_test_cpu(i, marked_cpus))
463 return; 463 return;
464 } 464 }
465 465
@@ -468,7 +468,7 @@ static void mark_done(int cpu)
468 */ 468 */
469 process_task_mortuary(); 469 process_task_mortuary();
470 470
471 cpus_clear(marked_cpus); 471 cpumask_clear(marked_cpus);
472} 472}
473 473
474 474
@@ -565,6 +565,20 @@ void sync_buffer(int cpu)
565 mutex_unlock(&buffer_mutex); 565 mutex_unlock(&buffer_mutex);
566} 566}
567 567
568int __init buffer_sync_init(void)
569{
570 if (!alloc_cpumask_var(&marked_cpus, GFP_KERNEL))
571 return -ENOMEM;
572
573 cpumask_clear(marked_cpus);
574 return 0;
575}
576
577void __exit buffer_sync_cleanup(void)
578{
579 free_cpumask_var(marked_cpus);
580}
581
568/* The function can be used to add a buffer worth of data directly to 582/* The function can be used to add a buffer worth of data directly to
569 * the kernel buffer. The buffer is assumed to be a circular buffer. 583 * the kernel buffer. The buffer is assumed to be a circular buffer.
570 * Take the entries from index start and end at index end, wrapping 584 * Take the entries from index start and end at index end, wrapping
diff --git a/drivers/oprofile/buffer_sync.h b/drivers/oprofile/buffer_sync.h
index 3110732c183..0ebf5db6267 100644
--- a/drivers/oprofile/buffer_sync.h
+++ b/drivers/oprofile/buffer_sync.h
@@ -19,4 +19,8 @@ void sync_stop(void);
19/* sync the given CPU's buffer */ 19/* sync the given CPU's buffer */
20void sync_buffer(int cpu); 20void sync_buffer(int cpu);
21 21
22/* initialize/destroy the buffer system. */
23int buffer_sync_init(void);
24void buffer_sync_cleanup(void);
25
22#endif /* OPROFILE_BUFFER_SYNC_H */ 26#endif /* OPROFILE_BUFFER_SYNC_H */
diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
index 3cffce90f82..ced39f60229 100644
--- a/drivers/oprofile/oprof.c
+++ b/drivers/oprofile/oprof.c
@@ -183,6 +183,10 @@ static int __init oprofile_init(void)
183{ 183{
184 int err; 184 int err;
185 185
186 err = buffer_sync_init();
187 if (err)
188 return err;
189
186 err = oprofile_arch_init(&oprofile_ops); 190 err = oprofile_arch_init(&oprofile_ops);
187 191
188 if (err < 0 || timer) { 192 if (err < 0 || timer) {
@@ -191,8 +195,10 @@ static int __init oprofile_init(void)
191 } 195 }
192 196
193 err = oprofilefs_register(); 197 err = oprofilefs_register();
194 if (err) 198 if (err) {
195 oprofile_arch_exit(); 199 oprofile_arch_exit();
200 buffer_sync_cleanup();
201 }
196 202
197 return err; 203 return err;
198} 204}
@@ -202,6 +208,7 @@ static void __exit oprofile_exit(void)
202{ 208{
203 oprofilefs_unregister(); 209 oprofilefs_unregister();
204 oprofile_arch_exit(); 210 oprofile_arch_exit();
211 buffer_sync_cleanup();
205} 212}
206 213
207 214
diff --git a/drivers/parisc/superio.c b/drivers/parisc/superio.c
index 1e93c837514..4fa3bb2ddfe 100644
--- a/drivers/parisc/superio.c
+++ b/drivers/parisc/superio.c
@@ -405,7 +405,6 @@ static void __init superio_serial_init(void)
405 serial_port.type = PORT_16550A; 405 serial_port.type = PORT_16550A;
406 serial_port.uartclk = 115200*16; 406 serial_port.uartclk = 115200*16;
407 serial_port.fifosize = 16; 407 serial_port.fifosize = 16;
408 spin_lock_init(&serial_port.lock);
409 408
410 /* serial port #1 */ 409 /* serial port #1 */
411 serial_port.iobase = sio_dev.sp1_base; 410 serial_port.iobase = sio_dev.sp1_base;
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index 235fb7a5a8a..3dfecb20d5e 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -438,7 +438,8 @@ static struct intel_iommu *device_to_iommu(u8 bus, u8 devfn)
438 continue; 438 continue;
439 439
440 for (i = 0; i < drhd->devices_cnt; i++) 440 for (i = 0; i < drhd->devices_cnt; i++)
441 if (drhd->devices[i]->bus->number == bus && 441 if (drhd->devices[i] &&
442 drhd->devices[i]->bus->number == bus &&
442 drhd->devices[i]->devfn == devfn) 443 drhd->devices[i]->devfn == devfn)
443 return drhd->iommu; 444 return drhd->iommu;
444 445
diff --git a/drivers/pci/intr_remapping.c b/drivers/pci/intr_remapping.c
index f78371b2252..5a57753ea9f 100644
--- a/drivers/pci/intr_remapping.c
+++ b/drivers/pci/intr_remapping.c
@@ -6,6 +6,7 @@
6#include <linux/irq.h> 6#include <linux/irq.h>
7#include <asm/io_apic.h> 7#include <asm/io_apic.h>
8#include <asm/smp.h> 8#include <asm/smp.h>
9#include <asm/cpu.h>
9#include <linux/intel-iommu.h> 10#include <linux/intel-iommu.h>
10#include "intr_remapping.h" 11#include "intr_remapping.h"
11 12
diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index 668472405a5..33da1127992 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -82,4 +82,10 @@ config BATTERY_DA9030
82 Say Y here to enable support for batteries charger integrated into 82 Say Y here to enable support for batteries charger integrated into
83 DA9030 PMIC. 83 DA9030 PMIC.
84 84
85config CHARGER_PCF50633
86 tristate "NXP PCF50633 MBC"
87 depends on MFD_PCF50633
88 help
89 Say Y to include support for NXP PCF50633 Main Battery Charger.
90
85endif # POWER_SUPPLY 91endif # POWER_SUPPLY
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index eebb15505a4..2fcf41d13e5 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -25,3 +25,4 @@ obj-$(CONFIG_BATTERY_TOSA) += tosa_battery.o
25obj-$(CONFIG_BATTERY_WM97XX) += wm97xx_battery.o 25obj-$(CONFIG_BATTERY_WM97XX) += wm97xx_battery.o
26obj-$(CONFIG_BATTERY_BQ27x00) += bq27x00_battery.o 26obj-$(CONFIG_BATTERY_BQ27x00) += bq27x00_battery.o
27obj-$(CONFIG_BATTERY_DA9030) += da9030_battery.o 27obj-$(CONFIG_BATTERY_DA9030) += da9030_battery.o
28obj-$(CONFIG_CHARGER_PCF50633) += pcf50633-charger.o \ No newline at end of file
diff --git a/drivers/power/pcf50633-charger.c b/drivers/power/pcf50633-charger.c
new file mode 100644
index 00000000000..e988ec130fc
--- /dev/null
+++ b/drivers/power/pcf50633-charger.c
@@ -0,0 +1,358 @@
1/* NXP PCF50633 Main Battery Charger Driver
2 *
3 * (C) 2006-2008 by Openmoko, Inc.
4 * Author: Balaji Rao <balajirrao@openmoko.org>
5 * All rights reserved.
6 *
7 * Broken down from monstrous PCF50633 driver mainly by
8 * Harald Welte, Andy Green and Werner Almesberger
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 */
16
17#include <linux/kernel.h>
18#include <linux/module.h>
19#include <linux/init.h>
20#include <linux/types.h>
21#include <linux/device.h>
22#include <linux/sysfs.h>
23#include <linux/platform_device.h>
24#include <linux/power_supply.h>
25
26#include <linux/mfd/pcf50633/core.h>
27#include <linux/mfd/pcf50633/mbc.h>
28
29struct pcf50633_mbc {
30 struct pcf50633 *pcf;
31
32 int adapter_active;
33 int adapter_online;
34 int usb_active;
35 int usb_online;
36
37 struct power_supply usb;
38 struct power_supply adapter;
39};
40
41int pcf50633_mbc_usb_curlim_set(struct pcf50633 *pcf, int ma)
42{
43 struct pcf50633_mbc *mbc = platform_get_drvdata(pcf->mbc_pdev);
44 int ret = 0;
45 u8 bits;
46
47 if (ma >= 1000)
48 bits = PCF50633_MBCC7_USB_1000mA;
49 else if (ma >= 500)
50 bits = PCF50633_MBCC7_USB_500mA;
51 else if (ma >= 100)
52 bits = PCF50633_MBCC7_USB_100mA;
53 else
54 bits = PCF50633_MBCC7_USB_SUSPEND;
55
56 ret = pcf50633_reg_set_bit_mask(pcf, PCF50633_REG_MBCC7,
57 PCF50633_MBCC7_USB_MASK, bits);
58 if (ret)
59 dev_err(pcf->dev, "error setting usb curlim to %d mA\n", ma);
60 else
61 dev_info(pcf->dev, "usb curlim to %d mA\n", ma);
62
63 power_supply_changed(&mbc->usb);
64
65 return ret;
66}
67EXPORT_SYMBOL_GPL(pcf50633_mbc_usb_curlim_set);
68
69int pcf50633_mbc_get_status(struct pcf50633 *pcf)
70{
71 struct pcf50633_mbc *mbc = platform_get_drvdata(pcf->mbc_pdev);
72 int status = 0;
73
74 if (mbc->usb_online)
75 status |= PCF50633_MBC_USB_ONLINE;
76 if (mbc->usb_active)
77 status |= PCF50633_MBC_USB_ACTIVE;
78 if (mbc->adapter_online)
79 status |= PCF50633_MBC_ADAPTER_ONLINE;
80 if (mbc->adapter_active)
81 status |= PCF50633_MBC_ADAPTER_ACTIVE;
82
83 return status;
84}
85EXPORT_SYMBOL_GPL(pcf50633_mbc_get_status);
86
87void pcf50633_mbc_set_status(struct pcf50633 *pcf, int what, int status)
88{
89 struct pcf50633_mbc *mbc = platform_get_drvdata(pcf->mbc_pdev);
90
91 if (what & PCF50633_MBC_USB_ONLINE)
92 mbc->usb_online = !!status;
93 if (what & PCF50633_MBC_USB_ACTIVE)
94 mbc->usb_active = !!status;
95 if (what & PCF50633_MBC_ADAPTER_ONLINE)
96 mbc->adapter_online = !!status;
97 if (what & PCF50633_MBC_ADAPTER_ACTIVE)
98 mbc->adapter_active = !!status;
99}
100EXPORT_SYMBOL_GPL(pcf50633_mbc_set_status);
101
102static ssize_t
103show_chgmode(struct device *dev, struct device_attribute *attr, char *buf)
104{
105 struct pcf50633_mbc *mbc = dev_get_drvdata(dev);
106
107 u8 mbcs2 = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCS2);
108 u8 chgmod = (mbcs2 & PCF50633_MBCS2_MBC_MASK);
109
110 return sprintf(buf, "%d\n", chgmod);
111}
112static DEVICE_ATTR(chgmode, S_IRUGO, show_chgmode, NULL);
113
114static ssize_t
115show_usblim(struct device *dev, struct device_attribute *attr, char *buf)
116{
117 struct pcf50633_mbc *mbc = dev_get_drvdata(dev);
118 u8 usblim = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCC7) &
119 PCF50633_MBCC7_USB_MASK;
120 unsigned int ma;
121
122 if (usblim == PCF50633_MBCC7_USB_1000mA)
123 ma = 1000;
124 else if (usblim == PCF50633_MBCC7_USB_500mA)
125 ma = 500;
126 else if (usblim == PCF50633_MBCC7_USB_100mA)
127 ma = 100;
128 else
129 ma = 0;
130
131 return sprintf(buf, "%u\n", ma);
132}
133
134static ssize_t set_usblim(struct device *dev,
135 struct device_attribute *attr, const char *buf, size_t count)
136{
137 struct pcf50633_mbc *mbc = dev_get_drvdata(dev);
138 unsigned long ma;
139 int ret;
140
141 ret = strict_strtoul(buf, 10, &ma);
142 if (ret)
143 return -EINVAL;
144
145 pcf50633_mbc_usb_curlim_set(mbc->pcf, ma);
146
147 return count;
148}
149
150static DEVICE_ATTR(usb_curlim, S_IRUGO | S_IWUSR, show_usblim, set_usblim);
151
152static struct attribute *pcf50633_mbc_sysfs_entries[] = {
153 &dev_attr_chgmode.attr,
154 &dev_attr_usb_curlim.attr,
155 NULL,
156};
157
158static struct attribute_group mbc_attr_group = {
159 .name = NULL, /* put in device directory */
160 .attrs = pcf50633_mbc_sysfs_entries,
161};
162
163static void
164pcf50633_mbc_irq_handler(int irq, void *data)
165{
166 struct pcf50633_mbc *mbc = data;
167
168 /* USB */
169 if (irq == PCF50633_IRQ_USBINS) {
170 mbc->usb_online = 1;
171 } else if (irq == PCF50633_IRQ_USBREM) {
172 mbc->usb_online = 0;
173 mbc->usb_active = 0;
174 pcf50633_mbc_usb_curlim_set(mbc->pcf, 0);
175 }
176
177 /* Adapter */
178 if (irq == PCF50633_IRQ_ADPINS) {
179 mbc->adapter_online = 1;
180 mbc->adapter_active = 1;
181 } else if (irq == PCF50633_IRQ_ADPREM) {
182 mbc->adapter_online = 0;
183 mbc->adapter_active = 0;
184 }
185
186 if (irq == PCF50633_IRQ_BATFULL) {
187 mbc->usb_active = 0;
188 mbc->adapter_active = 0;
189 }
190
191 power_supply_changed(&mbc->usb);
192 power_supply_changed(&mbc->adapter);
193
194 if (mbc->pcf->pdata->mbc_event_callback)
195 mbc->pcf->pdata->mbc_event_callback(mbc->pcf, irq);
196}
197
198static int adapter_get_property(struct power_supply *psy,
199 enum power_supply_property psp,
200 union power_supply_propval *val)
201{
202 struct pcf50633_mbc *mbc = container_of(psy, struct pcf50633_mbc, usb);
203 int ret = 0;
204
205 switch (psp) {
206 case POWER_SUPPLY_PROP_ONLINE:
207 val->intval = mbc->adapter_online;
208 break;
209 default:
210 ret = -EINVAL;
211 break;
212 }
213 return ret;
214}
215
216static int usb_get_property(struct power_supply *psy,
217 enum power_supply_property psp,
218 union power_supply_propval *val)
219{
220 struct pcf50633_mbc *mbc = container_of(psy, struct pcf50633_mbc, usb);
221 int ret = 0;
222
223 switch (psp) {
224 case POWER_SUPPLY_PROP_ONLINE:
225 val->intval = mbc->usb_online;
226 break;
227 default:
228 ret = -EINVAL;
229 break;
230 }
231 return ret;
232}
233
234static enum power_supply_property power_props[] = {
235 POWER_SUPPLY_PROP_ONLINE,
236};
237
238static const u8 mbc_irq_handlers[] = {
239 PCF50633_IRQ_ADPINS,
240 PCF50633_IRQ_ADPREM,
241 PCF50633_IRQ_USBINS,
242 PCF50633_IRQ_USBREM,
243 PCF50633_IRQ_BATFULL,
244 PCF50633_IRQ_CHGHALT,
245 PCF50633_IRQ_THLIMON,
246 PCF50633_IRQ_THLIMOFF,
247 PCF50633_IRQ_USBLIMON,
248 PCF50633_IRQ_USBLIMOFF,
249 PCF50633_IRQ_LOWSYS,
250 PCF50633_IRQ_LOWBAT,
251};
252
253static int __devinit pcf50633_mbc_probe(struct platform_device *pdev)
254{
255 struct pcf50633_mbc *mbc;
256 struct pcf50633_subdev_pdata *pdata = pdev->dev.platform_data;
257 int ret;
258 int i;
259 u8 mbcs1;
260
261 mbc = kzalloc(sizeof(*mbc), GFP_KERNEL);
262 if (!mbc)
263 return -ENOMEM;
264
265 platform_set_drvdata(pdev, mbc);
266 mbc->pcf = pdata->pcf;
267
268 /* Set up IRQ handlers */
269 for (i = 0; i < ARRAY_SIZE(mbc_irq_handlers); i++)
270 pcf50633_register_irq(mbc->pcf, mbc_irq_handlers[i],
271 pcf50633_mbc_irq_handler, mbc);
272
273 /* Create power supplies */
274 mbc->adapter.name = "adapter";
275 mbc->adapter.type = POWER_SUPPLY_TYPE_MAINS;
276 mbc->adapter.properties = power_props;
277 mbc->adapter.num_properties = ARRAY_SIZE(power_props);
278 mbc->adapter.get_property = &adapter_get_property;
279 mbc->adapter.supplied_to = mbc->pcf->pdata->batteries;
280 mbc->adapter.num_supplicants = mbc->pcf->pdata->num_batteries;
281
282 mbc->usb.name = "usb";
283 mbc->usb.type = POWER_SUPPLY_TYPE_USB;
284 mbc->usb.properties = power_props;
285 mbc->usb.num_properties = ARRAY_SIZE(power_props);
286 mbc->usb.get_property = usb_get_property;
287 mbc->usb.supplied_to = mbc->pcf->pdata->batteries;
288 mbc->usb.num_supplicants = mbc->pcf->pdata->num_batteries;
289
290 ret = power_supply_register(&pdev->dev, &mbc->adapter);
291 if (ret) {
292 dev_err(mbc->pcf->dev, "failed to register adapter\n");
293 kfree(mbc);
294 return ret;
295 }
296
297 ret = power_supply_register(&pdev->dev, &mbc->usb);
298 if (ret) {
299 dev_err(mbc->pcf->dev, "failed to register usb\n");
300 power_supply_unregister(&mbc->adapter);
301 kfree(mbc);
302 return ret;
303 }
304
305 ret = sysfs_create_group(&pdev->dev.kobj, &mbc_attr_group);
306 if (ret)
307 dev_err(mbc->pcf->dev, "failed to create sysfs entries\n");
308
309 mbcs1 = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCS1);
310 if (mbcs1 & PCF50633_MBCS1_USBPRES)
311 pcf50633_mbc_irq_handler(PCF50633_IRQ_USBINS, mbc);
312 if (mbcs1 & PCF50633_MBCS1_ADAPTPRES)
313 pcf50633_mbc_irq_handler(PCF50633_IRQ_ADPINS, mbc);
314
315 return 0;
316}
317
318static int __devexit pcf50633_mbc_remove(struct platform_device *pdev)
319{
320 struct pcf50633_mbc *mbc = platform_get_drvdata(pdev);
321 int i;
322
323 /* Remove IRQ handlers */
324 for (i = 0; i < ARRAY_SIZE(mbc_irq_handlers); i++)
325 pcf50633_free_irq(mbc->pcf, mbc_irq_handlers[i]);
326
327 power_supply_unregister(&mbc->usb);
328 power_supply_unregister(&mbc->adapter);
329
330 kfree(mbc);
331
332 return 0;
333}
334
335static struct platform_driver pcf50633_mbc_driver = {
336 .driver = {
337 .name = "pcf50633-mbc",
338 },
339 .probe = pcf50633_mbc_probe,
340 .remove = __devexit_p(pcf50633_mbc_remove),
341};
342
343static int __init pcf50633_mbc_init(void)
344{
345 return platform_driver_register(&pcf50633_mbc_driver);
346}
347module_init(pcf50633_mbc_init);
348
349static void __exit pcf50633_mbc_exit(void)
350{
351 platform_driver_unregister(&pcf50633_mbc_driver);
352}
353module_exit(pcf50633_mbc_exit);
354
355MODULE_AUTHOR("Balaji Rao <balajirrao@openmoko.org>");
356MODULE_DESCRIPTION("PCF50633 mbc driver");
357MODULE_LICENSE("GPL");
358MODULE_ALIAS("platform:pcf50633-mbc");
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 39360e2a454..e7e0cf102d6 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -73,4 +73,11 @@ config REGULATOR_DA903X
73 Say y here to support the BUCKs and LDOs regulators found on 73 Say y here to support the BUCKs and LDOs regulators found on
74 Dialog Semiconductor DA9030/DA9034 PMIC. 74 Dialog Semiconductor DA9030/DA9034 PMIC.
75 75
76config REGULATOR_PCF50633
77 tristate "PCF50633 regulator driver"
78 depends on MFD_PCF50633
79 help
80 Say Y here to support the voltage regulators and convertors
81 on PCF50633
82
76endif 83endif
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 254d40c02ee..61b30c6ddec 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -11,5 +11,6 @@ obj-$(CONFIG_REGULATOR_BQ24022) += bq24022.o
11obj-$(CONFIG_REGULATOR_WM8350) += wm8350-regulator.o 11obj-$(CONFIG_REGULATOR_WM8350) += wm8350-regulator.o
12obj-$(CONFIG_REGULATOR_WM8400) += wm8400-regulator.o 12obj-$(CONFIG_REGULATOR_WM8400) += wm8400-regulator.o
13obj-$(CONFIG_REGULATOR_DA903X) += da903x.o 13obj-$(CONFIG_REGULATOR_DA903X) += da903x.o
14obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o
14 15
15ccflags-$(CONFIG_REGULATOR_DEBUG) += -DDEBUG 16ccflags-$(CONFIG_REGULATOR_DEBUG) += -DDEBUG
diff --git a/drivers/regulator/pcf50633-regulator.c b/drivers/regulator/pcf50633-regulator.c
new file mode 100644
index 00000000000..4cc85ec6e12
--- /dev/null
+++ b/drivers/regulator/pcf50633-regulator.c
@@ -0,0 +1,329 @@
1/* NXP PCF50633 PMIC Driver
2 *
3 * (C) 2006-2008 by Openmoko, Inc.
4 * Author: Balaji Rao <balajirrao@openmoko.org>
5 * All rights reserved.
6 *
7 * Broken down from monstrous PCF50633 driver mainly by
8 * Harald Welte and Andy Green and Werner Almesberger
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 */
16
17#include <linux/kernel.h>
18#include <linux/module.h>
19#include <linux/init.h>
20#include <linux/device.h>
21#include <linux/err.h>
22#include <linux/platform_device.h>
23
24#include <linux/mfd/pcf50633/core.h>
25#include <linux/mfd/pcf50633/pmic.h>
26
27#define PCF50633_REGULATOR(_name, _id) \
28 { \
29 .name = _name, \
30 .id = _id, \
31 .ops = &pcf50633_regulator_ops, \
32 .type = REGULATOR_VOLTAGE, \
33 .owner = THIS_MODULE, \
34 }
35
36static const u8 pcf50633_regulator_registers[PCF50633_NUM_REGULATORS] = {
37 [PCF50633_REGULATOR_AUTO] = PCF50633_REG_AUTOOUT,
38 [PCF50633_REGULATOR_DOWN1] = PCF50633_REG_DOWN1OUT,
39 [PCF50633_REGULATOR_DOWN2] = PCF50633_REG_DOWN2OUT,
40 [PCF50633_REGULATOR_MEMLDO] = PCF50633_REG_MEMLDOOUT,
41 [PCF50633_REGULATOR_LDO1] = PCF50633_REG_LDO1OUT,
42 [PCF50633_REGULATOR_LDO2] = PCF50633_REG_LDO2OUT,
43 [PCF50633_REGULATOR_LDO3] = PCF50633_REG_LDO3OUT,
44 [PCF50633_REGULATOR_LDO4] = PCF50633_REG_LDO4OUT,
45 [PCF50633_REGULATOR_LDO5] = PCF50633_REG_LDO5OUT,
46 [PCF50633_REGULATOR_LDO6] = PCF50633_REG_LDO6OUT,
47 [PCF50633_REGULATOR_HCLDO] = PCF50633_REG_HCLDOOUT,
48};
49
50/* Bits from voltage value */
51static u8 auto_voltage_bits(unsigned int millivolts)
52{
53 if (millivolts < 1800)
54 return 0;
55 if (millivolts > 3800)
56 return 0xff;
57
58 millivolts -= 625;
59
60 return millivolts / 25;
61}
62
63static u8 down_voltage_bits(unsigned int millivolts)
64{
65 if (millivolts < 625)
66 return 0;
67 else if (millivolts > 3000)
68 return 0xff;
69
70 millivolts -= 625;
71
72 return millivolts / 25;
73}
74
75static u8 ldo_voltage_bits(unsigned int millivolts)
76{
77 if (millivolts < 900)
78 return 0;
79 else if (millivolts > 3600)
80 return 0x1f;
81
82 millivolts -= 900;
83 return millivolts / 100;
84}
85
86/* Obtain voltage value from bits */
87static unsigned int auto_voltage_value(u8 bits)
88{
89 if (bits < 0x2f)
90 return 0;
91
92 return 625 + (bits * 25);
93}
94
95
96static unsigned int down_voltage_value(u8 bits)
97{
98 return 625 + (bits * 25);
99}
100
101
102static unsigned int ldo_voltage_value(u8 bits)
103{
104 bits &= 0x1f;
105
106 return 900 + (bits * 100);
107}
108
109static int pcf50633_regulator_set_voltage(struct regulator_dev *rdev,
110 int min_uV, int max_uV)
111{
112 struct pcf50633 *pcf;
113 int regulator_id, millivolts;
114 u8 volt_bits, regnr;
115
116 pcf = rdev_get_drvdata(rdev);
117
118 regulator_id = rdev_get_id(rdev);
119 if (regulator_id >= PCF50633_NUM_REGULATORS)
120 return -EINVAL;
121
122 millivolts = min_uV / 1000;
123
124 regnr = pcf50633_regulator_registers[regulator_id];
125
126 switch (regulator_id) {
127 case PCF50633_REGULATOR_AUTO:
128 volt_bits = auto_voltage_bits(millivolts);
129 break;
130 case PCF50633_REGULATOR_DOWN1:
131 volt_bits = down_voltage_bits(millivolts);
132 break;
133 case PCF50633_REGULATOR_DOWN2:
134 volt_bits = down_voltage_bits(millivolts);
135 break;
136 case PCF50633_REGULATOR_LDO1:
137 case PCF50633_REGULATOR_LDO2:
138 case PCF50633_REGULATOR_LDO3:
139 case PCF50633_REGULATOR_LDO4:
140 case PCF50633_REGULATOR_LDO5:
141 case PCF50633_REGULATOR_LDO6:
142 case PCF50633_REGULATOR_HCLDO:
143 volt_bits = ldo_voltage_bits(millivolts);
144 break;
145 default:
146 return -EINVAL;
147 }
148
149 return pcf50633_reg_write(pcf, regnr, volt_bits);
150}
151
152static int pcf50633_regulator_get_voltage(struct regulator_dev *rdev)
153{
154 struct pcf50633 *pcf;
155 int regulator_id, millivolts, volt_bits;
156 u8 regnr;
157
158 pcf = rdev_get_drvdata(rdev);;
159
160 regulator_id = rdev_get_id(rdev);
161 if (regulator_id >= PCF50633_NUM_REGULATORS)
162 return -EINVAL;
163
164 regnr = pcf50633_regulator_registers[regulator_id];
165
166 volt_bits = pcf50633_reg_read(pcf, regnr);
167 if (volt_bits < 0)
168 return -1;
169
170 switch (regulator_id) {
171 case PCF50633_REGULATOR_AUTO:
172 millivolts = auto_voltage_value(volt_bits);
173 break;
174 case PCF50633_REGULATOR_DOWN1:
175 millivolts = down_voltage_value(volt_bits);
176 break;
177 case PCF50633_REGULATOR_DOWN2:
178 millivolts = down_voltage_value(volt_bits);
179 break;
180 case PCF50633_REGULATOR_LDO1:
181 case PCF50633_REGULATOR_LDO2:
182 case PCF50633_REGULATOR_LDO3:
183 case PCF50633_REGULATOR_LDO4:
184 case PCF50633_REGULATOR_LDO5:
185 case PCF50633_REGULATOR_LDO6:
186 case PCF50633_REGULATOR_HCLDO:
187 millivolts = ldo_voltage_value(volt_bits);
188 break;
189 default:
190 return -EINVAL;
191 }
192
193 return millivolts * 1000;
194}
195
196static int pcf50633_regulator_enable(struct regulator_dev *rdev)
197{
198 struct pcf50633 *pcf = rdev_get_drvdata(rdev);
199 int regulator_id;
200 u8 regnr;
201
202 regulator_id = rdev_get_id(rdev);
203 if (regulator_id >= PCF50633_NUM_REGULATORS)
204 return -EINVAL;
205
206 /* The *ENA register is always one after the *OUT register */
207 regnr = pcf50633_regulator_registers[regulator_id] + 1;
208
209 return pcf50633_reg_set_bit_mask(pcf, regnr, PCF50633_REGULATOR_ON,
210 PCF50633_REGULATOR_ON);
211}
212
213static int pcf50633_regulator_disable(struct regulator_dev *rdev)
214{
215 struct pcf50633 *pcf = rdev_get_drvdata(rdev);
216 int regulator_id;
217 u8 regnr;
218
219 regulator_id = rdev_get_id(rdev);
220 if (regulator_id >= PCF50633_NUM_REGULATORS)
221 return -EINVAL;
222
223 /* the *ENA register is always one after the *OUT register */
224 regnr = pcf50633_regulator_registers[regulator_id] + 1;
225
226 return pcf50633_reg_set_bit_mask(pcf, regnr,
227 PCF50633_REGULATOR_ON, 0);
228}
229
230static int pcf50633_regulator_is_enabled(struct regulator_dev *rdev)
231{
232 struct pcf50633 *pcf = rdev_get_drvdata(rdev);
233 int regulator_id = rdev_get_id(rdev);
234 u8 regnr;
235
236 regulator_id = rdev_get_id(rdev);
237 if (regulator_id >= PCF50633_NUM_REGULATORS)
238 return -EINVAL;
239
240 /* the *ENA register is always one after the *OUT register */
241 regnr = pcf50633_regulator_registers[regulator_id] + 1;
242
243 return pcf50633_reg_read(pcf, regnr) & PCF50633_REGULATOR_ON;
244}
245
246static struct regulator_ops pcf50633_regulator_ops = {
247 .set_voltage = pcf50633_regulator_set_voltage,
248 .get_voltage = pcf50633_regulator_get_voltage,
249 .enable = pcf50633_regulator_enable,
250 .disable = pcf50633_regulator_disable,
251 .is_enabled = pcf50633_regulator_is_enabled,
252};
253
254static struct regulator_desc regulators[] = {
255 [PCF50633_REGULATOR_AUTO] =
256 PCF50633_REGULATOR("auto", PCF50633_REGULATOR_AUTO),
257 [PCF50633_REGULATOR_DOWN1] =
258 PCF50633_REGULATOR("down1", PCF50633_REGULATOR_DOWN1),
259 [PCF50633_REGULATOR_DOWN2] =
260 PCF50633_REGULATOR("down2", PCF50633_REGULATOR_DOWN2),
261 [PCF50633_REGULATOR_LDO1] =
262 PCF50633_REGULATOR("ldo1", PCF50633_REGULATOR_LDO1),
263 [PCF50633_REGULATOR_LDO2] =
264 PCF50633_REGULATOR("ldo2", PCF50633_REGULATOR_LDO2),
265 [PCF50633_REGULATOR_LDO3] =
266 PCF50633_REGULATOR("ldo3", PCF50633_REGULATOR_LDO3),
267 [PCF50633_REGULATOR_LDO4] =
268 PCF50633_REGULATOR("ldo4", PCF50633_REGULATOR_LDO4),
269 [PCF50633_REGULATOR_LDO5] =
270 PCF50633_REGULATOR("ldo5", PCF50633_REGULATOR_LDO5),
271 [PCF50633_REGULATOR_LDO6] =
272 PCF50633_REGULATOR("ldo6", PCF50633_REGULATOR_LDO6),
273 [PCF50633_REGULATOR_HCLDO] =
274 PCF50633_REGULATOR("hcldo", PCF50633_REGULATOR_HCLDO),
275 [PCF50633_REGULATOR_MEMLDO] =
276 PCF50633_REGULATOR("memldo", PCF50633_REGULATOR_MEMLDO),
277};
278
279static int __devinit pcf50633_regulator_probe(struct platform_device *pdev)
280{
281 struct regulator_dev *rdev;
282 struct pcf50633 *pcf;
283
284 /* Already set by core driver */
285 pcf = platform_get_drvdata(pdev);
286
287 rdev = regulator_register(&regulators[pdev->id], &pdev->dev, pcf);
288 if (IS_ERR(rdev))
289 return PTR_ERR(rdev);
290
291 if (pcf->pdata->regulator_registered)
292 pcf->pdata->regulator_registered(pcf, pdev->id);
293
294 return 0;
295}
296
297static int __devexit pcf50633_regulator_remove(struct platform_device *pdev)
298{
299 struct regulator_dev *rdev = platform_get_drvdata(pdev);
300
301 regulator_unregister(rdev);
302
303 return 0;
304}
305
306static struct platform_driver pcf50633_regulator_driver = {
307 .driver = {
308 .name = "pcf50633-regltr",
309 },
310 .probe = pcf50633_regulator_probe,
311 .remove = __devexit_p(pcf50633_regulator_remove),
312};
313
314static int __init pcf50633_regulator_init(void)
315{
316 return platform_driver_register(&pcf50633_regulator_driver);
317}
318module_init(pcf50633_regulator_init);
319
320static void __exit pcf50633_regulator_exit(void)
321{
322 platform_driver_unregister(&pcf50633_regulator_driver);
323}
324module_exit(pcf50633_regulator_exit);
325
326MODULE_AUTHOR("Balaji Rao <balajirrao@openmoko.org>");
327MODULE_DESCRIPTION("PCF50633 regulator driver");
328MODULE_LICENSE("GPL");
329MODULE_ALIAS("platform:pcf50633-regulator");
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 4ad831de41a..cced4d10831 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -502,6 +502,13 @@ config RTC_DRV_WM8350
502 This driver can also be built as a module. If so, the module 502 This driver can also be built as a module. If so, the module
503 will be called "rtc-wm8350". 503 will be called "rtc-wm8350".
504 504
505config RTC_DRV_PCF50633
506 depends on MFD_PCF50633
507 tristate "NXP PCF50633 RTC"
508 help
509 If you say yes here you get support for the RTC subsystem of the
510 NXP PCF50633 used in embedded systems.
511
505comment "on-CPU RTC drivers" 512comment "on-CPU RTC drivers"
506 513
507config RTC_DRV_OMAP 514config RTC_DRV_OMAP
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 9a4340d48f2..6e28021abb9 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -74,3 +74,4 @@ obj-$(CONFIG_RTC_DRV_V3020) += rtc-v3020.o
74obj-$(CONFIG_RTC_DRV_VR41XX) += rtc-vr41xx.o 74obj-$(CONFIG_RTC_DRV_VR41XX) += rtc-vr41xx.o
75obj-$(CONFIG_RTC_DRV_WM8350) += rtc-wm8350.o 75obj-$(CONFIG_RTC_DRV_WM8350) += rtc-wm8350.o
76obj-$(CONFIG_RTC_DRV_X1205) += rtc-x1205.o 76obj-$(CONFIG_RTC_DRV_X1205) += rtc-x1205.o
77obj-$(CONFIG_RTC_DRV_PCF50633) += rtc-pcf50633.o
diff --git a/drivers/rtc/rtc-pcf50633.c b/drivers/rtc/rtc-pcf50633.c
new file mode 100644
index 00000000000..f4dd87e2907
--- /dev/null
+++ b/drivers/rtc/rtc-pcf50633.c
@@ -0,0 +1,344 @@
1/* NXP PCF50633 RTC Driver
2 *
3 * (C) 2006-2008 by Openmoko, Inc.
4 * Author: Balaji Rao <balajirrao@openmoko.org>
5 * All rights reserved.
6 *
7 * Broken down from monstrous PCF50633 driver mainly by
8 * Harald Welte, Andy Green and Werner Almesberger
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 */
16
17#include <linux/kernel.h>
18#include <linux/module.h>
19#include <linux/init.h>
20#include <linux/device.h>
21#include <linux/platform_device.h>
22#include <linux/rtc.h>
23#include <linux/bcd.h>
24#include <linux/err.h>
25
26#include <linux/mfd/pcf50633/core.h>
27
28#define PCF50633_REG_RTCSC 0x59 /* Second */
29#define PCF50633_REG_RTCMN 0x5a /* Minute */
30#define PCF50633_REG_RTCHR 0x5b /* Hour */
31#define PCF50633_REG_RTCWD 0x5c /* Weekday */
32#define PCF50633_REG_RTCDT 0x5d /* Day */
33#define PCF50633_REG_RTCMT 0x5e /* Month */
34#define PCF50633_REG_RTCYR 0x5f /* Year */
35#define PCF50633_REG_RTCSCA 0x60 /* Alarm Second */
36#define PCF50633_REG_RTCMNA 0x61 /* Alarm Minute */
37#define PCF50633_REG_RTCHRA 0x62 /* Alarm Hour */
38#define PCF50633_REG_RTCWDA 0x63 /* Alarm Weekday */
39#define PCF50633_REG_RTCDTA 0x64 /* Alarm Day */
40#define PCF50633_REG_RTCMTA 0x65 /* Alarm Month */
41#define PCF50633_REG_RTCYRA 0x66 /* Alarm Year */
42
43enum pcf50633_time_indexes {
44 PCF50633_TI_SEC,
45 PCF50633_TI_MIN,
46 PCF50633_TI_HOUR,
47 PCF50633_TI_WKDAY,
48 PCF50633_TI_DAY,
49 PCF50633_TI_MONTH,
50 PCF50633_TI_YEAR,
51 PCF50633_TI_EXTENT /* always last */
52};
53
54struct pcf50633_time {
55 u_int8_t time[PCF50633_TI_EXTENT];
56};
57
58struct pcf50633_rtc {
59 int alarm_enabled;
60 int second_enabled;
61
62 struct pcf50633 *pcf;
63 struct rtc_device *rtc_dev;
64};
65
66static void pcf2rtc_time(struct rtc_time *rtc, struct pcf50633_time *pcf)
67{
68 rtc->tm_sec = bcd2bin(pcf->time[PCF50633_TI_SEC]);
69 rtc->tm_min = bcd2bin(pcf->time[PCF50633_TI_MIN]);
70 rtc->tm_hour = bcd2bin(pcf->time[PCF50633_TI_HOUR]);
71 rtc->tm_wday = bcd2bin(pcf->time[PCF50633_TI_WKDAY]);
72 rtc->tm_mday = bcd2bin(pcf->time[PCF50633_TI_DAY]);
73 rtc->tm_mon = bcd2bin(pcf->time[PCF50633_TI_MONTH]);
74 rtc->tm_year = bcd2bin(pcf->time[PCF50633_TI_YEAR]) + 100;
75}
76
77static void rtc2pcf_time(struct pcf50633_time *pcf, struct rtc_time *rtc)
78{
79 pcf->time[PCF50633_TI_SEC] = bin2bcd(rtc->tm_sec);
80 pcf->time[PCF50633_TI_MIN] = bin2bcd(rtc->tm_min);
81 pcf->time[PCF50633_TI_HOUR] = bin2bcd(rtc->tm_hour);
82 pcf->time[PCF50633_TI_WKDAY] = bin2bcd(rtc->tm_wday);
83 pcf->time[PCF50633_TI_DAY] = bin2bcd(rtc->tm_mday);
84 pcf->time[PCF50633_TI_MONTH] = bin2bcd(rtc->tm_mon);
85 pcf->time[PCF50633_TI_YEAR] = bin2bcd(rtc->tm_year % 100);
86}
87
88static int
89pcf50633_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
90{
91 struct pcf50633_rtc *rtc = dev_get_drvdata(dev);
92 int err;
93
94 if (enabled)
95 err = pcf50633_irq_unmask(rtc->pcf, PCF50633_IRQ_ALARM);
96 else
97 err = pcf50633_irq_mask(rtc->pcf, PCF50633_IRQ_ALARM);
98
99 if (err < 0)
100 return err;
101
102 rtc->alarm_enabled = enabled;
103
104 return 0;
105}
106
107static int
108pcf50633_rtc_update_irq_enable(struct device *dev, unsigned int enabled)
109{
110 struct pcf50633_rtc *rtc = dev_get_drvdata(dev);
111 int err;
112
113 if (enabled)
114 err = pcf50633_irq_unmask(rtc->pcf, PCF50633_IRQ_SECOND);
115 else
116 err = pcf50633_irq_mask(rtc->pcf, PCF50633_IRQ_SECOND);
117
118 if (err < 0)
119 return err;
120
121 rtc->second_enabled = enabled;
122
123 return 0;
124}
125
126static int pcf50633_rtc_read_time(struct device *dev, struct rtc_time *tm)
127{
128 struct pcf50633_rtc *rtc;
129 struct pcf50633_time pcf_tm;
130 int ret;
131
132 rtc = dev_get_drvdata(dev);
133
134 ret = pcf50633_read_block(rtc->pcf, PCF50633_REG_RTCSC,
135 PCF50633_TI_EXTENT,
136 &pcf_tm.time[0]);
137 if (ret != PCF50633_TI_EXTENT) {
138 dev_err(dev, "Failed to read time\n");
139 return -EIO;
140 }
141
142 dev_dbg(dev, "PCF_TIME: %02x.%02x.%02x %02x:%02x:%02x\n",
143 pcf_tm.time[PCF50633_TI_DAY],
144 pcf_tm.time[PCF50633_TI_MONTH],
145 pcf_tm.time[PCF50633_TI_YEAR],
146 pcf_tm.time[PCF50633_TI_HOUR],
147 pcf_tm.time[PCF50633_TI_MIN],
148 pcf_tm.time[PCF50633_TI_SEC]);
149
150 pcf2rtc_time(tm, &pcf_tm);
151
152 dev_dbg(dev, "RTC_TIME: %u.%u.%u %u:%u:%u\n",
153 tm->tm_mday, tm->tm_mon, tm->tm_year,
154 tm->tm_hour, tm->tm_min, tm->tm_sec);
155
156 return rtc_valid_tm(tm);
157}
158
159static int pcf50633_rtc_set_time(struct device *dev, struct rtc_time *tm)
160{
161 struct pcf50633_rtc *rtc;
162 struct pcf50633_time pcf_tm;
163 int second_masked, alarm_masked, ret = 0;
164
165 rtc = dev_get_drvdata(dev);
166
167 dev_dbg(dev, "RTC_TIME: %u.%u.%u %u:%u:%u\n",
168 tm->tm_mday, tm->tm_mon, tm->tm_year,
169 tm->tm_hour, tm->tm_min, tm->tm_sec);
170
171 rtc2pcf_time(&pcf_tm, tm);
172
173 dev_dbg(dev, "PCF_TIME: %02x.%02x.%02x %02x:%02x:%02x\n",
174 pcf_tm.time[PCF50633_TI_DAY],
175 pcf_tm.time[PCF50633_TI_MONTH],
176 pcf_tm.time[PCF50633_TI_YEAR],
177 pcf_tm.time[PCF50633_TI_HOUR],
178 pcf_tm.time[PCF50633_TI_MIN],
179 pcf_tm.time[PCF50633_TI_SEC]);
180
181
182 second_masked = pcf50633_irq_mask_get(rtc->pcf, PCF50633_IRQ_SECOND);
183 alarm_masked = pcf50633_irq_mask_get(rtc->pcf, PCF50633_IRQ_ALARM);
184
185 if (!second_masked)
186 pcf50633_irq_mask(rtc->pcf, PCF50633_IRQ_SECOND);
187 if (!alarm_masked)
188 pcf50633_irq_mask(rtc->pcf, PCF50633_IRQ_ALARM);
189
190 /* Returns 0 on success */
191 ret = pcf50633_write_block(rtc->pcf, PCF50633_REG_RTCSC,
192 PCF50633_TI_EXTENT,
193 &pcf_tm.time[0]);
194
195 if (!second_masked)
196 pcf50633_irq_unmask(rtc->pcf, PCF50633_IRQ_SECOND);
197 if (!alarm_masked)
198 pcf50633_irq_unmask(rtc->pcf, PCF50633_IRQ_ALARM);
199
200 return ret;
201}
202
203static int pcf50633_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
204{
205 struct pcf50633_rtc *rtc;
206 struct pcf50633_time pcf_tm;
207 int ret = 0;
208
209 rtc = dev_get_drvdata(dev);
210
211 alrm->enabled = rtc->alarm_enabled;
212
213 ret = pcf50633_read_block(rtc->pcf, PCF50633_REG_RTCSCA,
214 PCF50633_TI_EXTENT, &pcf_tm.time[0]);
215 if (ret != PCF50633_TI_EXTENT) {
216 dev_err(dev, "Failed to read time\n");
217 return -EIO;
218 }
219
220 pcf2rtc_time(&alrm->time, &pcf_tm);
221
222 return rtc_valid_tm(&alrm->time);
223}
224
225static int pcf50633_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
226{
227 struct pcf50633_rtc *rtc;
228 struct pcf50633_time pcf_tm;
229 int alarm_masked, ret = 0;
230
231 rtc = dev_get_drvdata(dev);
232
233 rtc2pcf_time(&pcf_tm, &alrm->time);
234
235 /* do like mktime does and ignore tm_wday */
236 pcf_tm.time[PCF50633_TI_WKDAY] = 7;
237
238 alarm_masked = pcf50633_irq_mask_get(rtc->pcf, PCF50633_IRQ_ALARM);
239
240 /* disable alarm interrupt */
241 if (!alarm_masked)
242 pcf50633_irq_mask(rtc->pcf, PCF50633_IRQ_ALARM);
243
244 /* Returns 0 on success */
245 ret = pcf50633_write_block(rtc->pcf, PCF50633_REG_RTCSCA,
246 PCF50633_TI_EXTENT, &pcf_tm.time[0]);
247
248 if (!alarm_masked)
249 pcf50633_irq_unmask(rtc->pcf, PCF50633_IRQ_ALARM);
250
251 return ret;
252}
253
254static struct rtc_class_ops pcf50633_rtc_ops = {
255 .read_time = pcf50633_rtc_read_time,
256 .set_time = pcf50633_rtc_set_time,
257 .read_alarm = pcf50633_rtc_read_alarm,
258 .set_alarm = pcf50633_rtc_set_alarm,
259 .alarm_irq_enable = pcf50633_rtc_alarm_irq_enable,
260 .update_irq_enable = pcf50633_rtc_update_irq_enable,
261};
262
263static void pcf50633_rtc_irq(int irq, void *data)
264{
265 struct pcf50633_rtc *rtc = data;
266
267 switch (irq) {
268 case PCF50633_IRQ_ALARM:
269 rtc_update_irq(rtc->rtc_dev, 1, RTC_AF | RTC_IRQF);
270 break;
271 case PCF50633_IRQ_SECOND:
272 rtc_update_irq(rtc->rtc_dev, 1, RTC_UF | RTC_IRQF);
273 break;
274 }
275}
276
277static int __devinit pcf50633_rtc_probe(struct platform_device *pdev)
278{
279 struct pcf50633_subdev_pdata *pdata;
280 struct pcf50633_rtc *rtc;
281
282
283 rtc = kzalloc(sizeof(*rtc), GFP_KERNEL);
284 if (!rtc)
285 return -ENOMEM;
286
287 pdata = pdev->dev.platform_data;
288 rtc->pcf = pdata->pcf;
289 platform_set_drvdata(pdev, rtc);
290 rtc->rtc_dev = rtc_device_register("pcf50633-rtc", &pdev->dev,
291 &pcf50633_rtc_ops, THIS_MODULE);
292
293 if (IS_ERR(rtc->rtc_dev)) {
294 kfree(rtc);
295 return PTR_ERR(rtc->rtc_dev);
296 }
297
298 pcf50633_register_irq(rtc->pcf, PCF50633_IRQ_ALARM,
299 pcf50633_rtc_irq, rtc);
300 pcf50633_register_irq(rtc->pcf, PCF50633_IRQ_SECOND,
301 pcf50633_rtc_irq, rtc);
302
303 return 0;
304}
305
306static int __devexit pcf50633_rtc_remove(struct platform_device *pdev)
307{
308 struct pcf50633_rtc *rtc;
309
310 rtc = platform_get_drvdata(pdev);
311
312 pcf50633_free_irq(rtc->pcf, PCF50633_IRQ_ALARM);
313 pcf50633_free_irq(rtc->pcf, PCF50633_IRQ_SECOND);
314
315 rtc_device_unregister(rtc->rtc_dev);
316 kfree(rtc);
317
318 return 0;
319}
320
321static struct platform_driver pcf50633_rtc_driver = {
322 .driver = {
323 .name = "pcf50633-rtc",
324 },
325 .probe = pcf50633_rtc_probe,
326 .remove = __devexit_p(pcf50633_rtc_remove),
327};
328
329static int __init pcf50633_rtc_init(void)
330{
331 return platform_driver_register(&pcf50633_rtc_driver);
332}
333module_init(pcf50633_rtc_init);
334
335static void __exit pcf50633_rtc_exit(void)
336{
337 platform_driver_unregister(&pcf50633_rtc_driver);
338}
339module_exit(pcf50633_rtc_exit);
340
341MODULE_DESCRIPTION("PCF50633 RTC driver");
342MODULE_AUTHOR("Balaji Rao <balajirrao@openmoko.org>");
343MODULE_LICENSE("GPL");
344
diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c
index c4f1b046c3b..07ab8a5c1c4 100644
--- a/drivers/s390/net/qeth_l2_main.c
+++ b/drivers/s390/net/qeth_l2_main.c
@@ -916,7 +916,7 @@ static struct ethtool_ops qeth_l2_osn_ops = {
916 .get_drvinfo = qeth_core_get_drvinfo, 916 .get_drvinfo = qeth_core_get_drvinfo,
917}; 917};
918 918
919static struct net_device_ops qeth_l2_netdev_ops = { 919static const struct net_device_ops qeth_l2_netdev_ops = {
920 .ndo_open = qeth_l2_open, 920 .ndo_open = qeth_l2_open,
921 .ndo_stop = qeth_l2_stop, 921 .ndo_stop = qeth_l2_stop,
922 .ndo_get_stats = qeth_get_stats, 922 .ndo_get_stats = qeth_get_stats,
diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c
index 68d623ab7e6..3d04920b9bb 100644
--- a/drivers/s390/net/qeth_l3_main.c
+++ b/drivers/s390/net/qeth_l3_main.c
@@ -2894,7 +2894,7 @@ qeth_l3_neigh_setup(struct net_device *dev, struct neigh_parms *np)
2894 return 0; 2894 return 0;
2895} 2895}
2896 2896
2897static struct net_device_ops qeth_l3_netdev_ops = { 2897static const struct net_device_ops qeth_l3_netdev_ops = {
2898 .ndo_open = qeth_l3_open, 2898 .ndo_open = qeth_l3_open,
2899 .ndo_stop = qeth_l3_stop, 2899 .ndo_stop = qeth_l3_stop,
2900 .ndo_get_stats = qeth_get_stats, 2900 .ndo_get_stats = qeth_get_stats,
@@ -2909,6 +2909,22 @@ static struct net_device_ops qeth_l3_netdev_ops = {
2909 .ndo_tx_timeout = qeth_tx_timeout, 2909 .ndo_tx_timeout = qeth_tx_timeout,
2910}; 2910};
2911 2911
2912static const struct net_device_ops qeth_l3_osa_netdev_ops = {
2913 .ndo_open = qeth_l3_open,
2914 .ndo_stop = qeth_l3_stop,
2915 .ndo_get_stats = qeth_get_stats,
2916 .ndo_start_xmit = qeth_l3_hard_start_xmit,
2917 .ndo_validate_addr = eth_validate_addr,
2918 .ndo_set_multicast_list = qeth_l3_set_multicast_list,
2919 .ndo_do_ioctl = qeth_l3_do_ioctl,
2920 .ndo_change_mtu = qeth_change_mtu,
2921 .ndo_vlan_rx_register = qeth_l3_vlan_rx_register,
2922 .ndo_vlan_rx_add_vid = qeth_l3_vlan_rx_add_vid,
2923 .ndo_vlan_rx_kill_vid = qeth_l3_vlan_rx_kill_vid,
2924 .ndo_tx_timeout = qeth_tx_timeout,
2925 .ndo_neigh_setup = qeth_l3_neigh_setup,
2926};
2927
2912static int qeth_l3_setup_netdev(struct qeth_card *card) 2928static int qeth_l3_setup_netdev(struct qeth_card *card)
2913{ 2929{
2914 if (card->info.type == QETH_CARD_TYPE_OSAE) { 2930 if (card->info.type == QETH_CARD_TYPE_OSAE) {
@@ -2919,12 +2935,12 @@ static int qeth_l3_setup_netdev(struct qeth_card *card)
2919#endif 2935#endif
2920 if (!card->dev) 2936 if (!card->dev)
2921 return -ENODEV; 2937 return -ENODEV;
2938 card->dev->netdev_ops = &qeth_l3_netdev_ops;
2922 } else { 2939 } else {
2923 card->dev = alloc_etherdev(0); 2940 card->dev = alloc_etherdev(0);
2924 if (!card->dev) 2941 if (!card->dev)
2925 return -ENODEV; 2942 return -ENODEV;
2926 qeth_l3_netdev_ops.ndo_neigh_setup = 2943 card->dev->netdev_ops = &qeth_l3_osa_netdev_ops;
2927 qeth_l3_neigh_setup;
2928 2944
2929 /*IPv6 address autoconfiguration stuff*/ 2945 /*IPv6 address autoconfiguration stuff*/
2930 qeth_l3_get_unique_id(card); 2946 qeth_l3_get_unique_id(card);
@@ -2937,6 +2953,7 @@ static int qeth_l3_setup_netdev(struct qeth_card *card)
2937 if (!card->dev) 2953 if (!card->dev)
2938 return -ENODEV; 2954 return -ENODEV;
2939 card->dev->flags |= IFF_NOARP; 2955 card->dev->flags |= IFF_NOARP;
2956 card->dev->netdev_ops = &qeth_l3_netdev_ops;
2940 qeth_l3_iqd_read_initial_mac(card); 2957 qeth_l3_iqd_read_initial_mac(card);
2941 } else 2958 } else
2942 return -ENODEV; 2959 return -ENODEV;
@@ -2944,7 +2961,6 @@ static int qeth_l3_setup_netdev(struct qeth_card *card)
2944 card->dev->ml_priv = card; 2961 card->dev->ml_priv = card;
2945 card->dev->watchdog_timeo = QETH_TX_TIMEOUT; 2962 card->dev->watchdog_timeo = QETH_TX_TIMEOUT;
2946 card->dev->mtu = card->info.initial_mtu; 2963 card->dev->mtu = card->info.initial_mtu;
2947 card->dev->netdev_ops = &qeth_l3_netdev_ops;
2948 SET_ETHTOOL_OPS(card->dev, &qeth_l3_ethtool_ops); 2964 SET_ETHTOOL_OPS(card->dev, &qeth_l3_ethtool_ops);
2949 card->dev->features |= NETIF_F_HW_VLAN_TX | 2965 card->dev->features |= NETIF_F_HW_VLAN_TX |
2950 NETIF_F_HW_VLAN_RX | 2966 NETIF_F_HW_VLAN_RX |
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index 1889a63ebc2..0d934bfbdd9 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -2839,6 +2839,8 @@ int __init early_serial_setup(struct uart_port *port)
2839 p->flags = port->flags; 2839 p->flags = port->flags;
2840 p->mapbase = port->mapbase; 2840 p->mapbase = port->mapbase;
2841 p->private_data = port->private_data; 2841 p->private_data = port->private_data;
2842 p->type = port->type;
2843 p->line = port->line;
2842 2844
2843 set_io_from_upio(p); 2845 set_io_from_upio(p);
2844 if (port->serial_in) 2846 if (port->serial_in)
diff --git a/drivers/serial/jsm/jsm_neo.c b/drivers/serial/jsm/jsm_neo.c
index b7584ca55ad..e6390d02363 100644
--- a/drivers/serial/jsm/jsm_neo.c
+++ b/drivers/serial/jsm/jsm_neo.c
@@ -577,9 +577,6 @@ static void neo_parse_modem(struct jsm_channel *ch, u8 signals)
577 jsm_printk(MSIGS, INFO, &ch->ch_bd->pci_dev, 577 jsm_printk(MSIGS, INFO, &ch->ch_bd->pci_dev,
578 "neo_parse_modem: port: %d msignals: %x\n", ch->ch_portnum, msignals); 578 "neo_parse_modem: port: %d msignals: %x\n", ch->ch_portnum, msignals);
579 579
580 if (!ch)
581 return;
582
583 /* Scrub off lower bits. They signify delta's, which I don't care about */ 580 /* Scrub off lower bits. They signify delta's, which I don't care about */
584 /* Keep DDCD and DDSR though */ 581 /* Keep DDCD and DDSR though */
585 msignals &= 0xf8; 582 msignals &= 0xf8;
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index 01d0c70d60e..3cf41df302d 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -145,7 +145,7 @@ static int ti_command_in_sync(struct ti_device *tdev, __u8 command,
145static int ti_write_byte(struct ti_device *tdev, unsigned long addr, 145static int ti_write_byte(struct ti_device *tdev, unsigned long addr,
146 __u8 mask, __u8 byte); 146 __u8 mask, __u8 byte);
147 147
148static int ti_download_firmware(struct ti_device *tdev, int type); 148static int ti_download_firmware(struct ti_device *tdev);
149 149
150/* circular buffer */ 150/* circular buffer */
151static struct circ_buf *ti_buf_alloc(void); 151static struct circ_buf *ti_buf_alloc(void);
@@ -176,9 +176,14 @@ static unsigned int product_5052_count;
176/* the array dimension is the number of default entries plus */ 176/* the array dimension is the number of default entries plus */
177/* TI_EXTRA_VID_PID_COUNT user defined entries plus 1 terminating */ 177/* TI_EXTRA_VID_PID_COUNT user defined entries plus 1 terminating */
178/* null entry */ 178/* null entry */
179static struct usb_device_id ti_id_table_3410[1+TI_EXTRA_VID_PID_COUNT+1] = { 179static struct usb_device_id ti_id_table_3410[7+TI_EXTRA_VID_PID_COUNT+1] = {
180 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) }, 180 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) },
181 { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) }, 181 { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) },
182 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_NO_FW_PRODUCT_ID) },
183 { USB_DEVICE(MTS_VENDOR_ID, MTS_CDMA_NO_FW_PRODUCT_ID) },
184 { USB_DEVICE(MTS_VENDOR_ID, MTS_CDMA_PRODUCT_ID) },
185 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_PRODUCT_ID) },
186 { USB_DEVICE(MTS_VENDOR_ID, MTS_EDGE_PRODUCT_ID) },
182}; 187};
183 188
184static struct usb_device_id ti_id_table_5052[4+TI_EXTRA_VID_PID_COUNT+1] = { 189static struct usb_device_id ti_id_table_5052[4+TI_EXTRA_VID_PID_COUNT+1] = {
@@ -188,9 +193,14 @@ static struct usb_device_id ti_id_table_5052[4+TI_EXTRA_VID_PID_COUNT+1] = {
188 { USB_DEVICE(TI_VENDOR_ID, TI_5052_FIRMWARE_PRODUCT_ID) }, 193 { USB_DEVICE(TI_VENDOR_ID, TI_5052_FIRMWARE_PRODUCT_ID) },
189}; 194};
190 195
191static struct usb_device_id ti_id_table_combined[] = { 196static struct usb_device_id ti_id_table_combined[6+2*TI_EXTRA_VID_PID_COUNT+1] = {
192 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) }, 197 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) },
193 { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) }, 198 { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) },
199 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_NO_FW_PRODUCT_ID) },
200 { USB_DEVICE(MTS_VENDOR_ID, MTS_CDMA_NO_FW_PRODUCT_ID) },
201 { USB_DEVICE(MTS_VENDOR_ID, MTS_CDMA_PRODUCT_ID) },
202 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_PRODUCT_ID) },
203 { USB_DEVICE(MTS_VENDOR_ID, MTS_EDGE_PRODUCT_ID) },
194 { USB_DEVICE(TI_VENDOR_ID, TI_5052_BOOT_PRODUCT_ID) }, 204 { USB_DEVICE(TI_VENDOR_ID, TI_5052_BOOT_PRODUCT_ID) },
195 { USB_DEVICE(TI_VENDOR_ID, TI_5152_BOOT_PRODUCT_ID) }, 205 { USB_DEVICE(TI_VENDOR_ID, TI_5152_BOOT_PRODUCT_ID) },
196 { USB_DEVICE(TI_VENDOR_ID, TI_5052_EEPROM_PRODUCT_ID) }, 206 { USB_DEVICE(TI_VENDOR_ID, TI_5052_EEPROM_PRODUCT_ID) },
@@ -272,6 +282,9 @@ MODULE_LICENSE("GPL");
272 282
273MODULE_FIRMWARE("ti_3410.fw"); 283MODULE_FIRMWARE("ti_3410.fw");
274MODULE_FIRMWARE("ti_5052.fw"); 284MODULE_FIRMWARE("ti_5052.fw");
285MODULE_FIRMWARE("mts_cdma.fw");
286MODULE_FIRMWARE("mts_gsm.fw");
287MODULE_FIRMWARE("mts_edge.fw");
275 288
276module_param(debug, bool, S_IRUGO | S_IWUSR); 289module_param(debug, bool, S_IRUGO | S_IWUSR);
277MODULE_PARM_DESC(debug, "Enable debugging, 0=no, 1=yes"); 290MODULE_PARM_DESC(debug, "Enable debugging, 0=no, 1=yes");
@@ -304,21 +317,28 @@ MODULE_DEVICE_TABLE(usb, ti_id_table_combined);
304 317
305static int __init ti_init(void) 318static int __init ti_init(void)
306{ 319{
307 int i, j; 320 int i, j, c;
308 int ret; 321 int ret;
309 322
310 /* insert extra vendor and product ids */ 323 /* insert extra vendor and product ids */
324 c = ARRAY_SIZE(ti_id_table_combined) - 2 * TI_EXTRA_VID_PID_COUNT - 1;
311 j = ARRAY_SIZE(ti_id_table_3410) - TI_EXTRA_VID_PID_COUNT - 1; 325 j = ARRAY_SIZE(ti_id_table_3410) - TI_EXTRA_VID_PID_COUNT - 1;
312 for (i = 0; i < min(vendor_3410_count, product_3410_count); i++, j++) { 326 for (i = 0; i < min(vendor_3410_count, product_3410_count); i++, j++, c++) {
313 ti_id_table_3410[j].idVendor = vendor_3410[i]; 327 ti_id_table_3410[j].idVendor = vendor_3410[i];
314 ti_id_table_3410[j].idProduct = product_3410[i]; 328 ti_id_table_3410[j].idProduct = product_3410[i];
315 ti_id_table_3410[j].match_flags = USB_DEVICE_ID_MATCH_DEVICE; 329 ti_id_table_3410[j].match_flags = USB_DEVICE_ID_MATCH_DEVICE;
330 ti_id_table_combined[c].idVendor = vendor_3410[i];
331 ti_id_table_combined[c].idProduct = product_3410[i];
332 ti_id_table_combined[c].match_flags = USB_DEVICE_ID_MATCH_DEVICE;
316 } 333 }
317 j = ARRAY_SIZE(ti_id_table_5052) - TI_EXTRA_VID_PID_COUNT - 1; 334 j = ARRAY_SIZE(ti_id_table_5052) - TI_EXTRA_VID_PID_COUNT - 1;
318 for (i = 0; i < min(vendor_5052_count, product_5052_count); i++, j++) { 335 for (i = 0; i < min(vendor_5052_count, product_5052_count); i++, j++, c++) {
319 ti_id_table_5052[j].idVendor = vendor_5052[i]; 336 ti_id_table_5052[j].idVendor = vendor_5052[i];
320 ti_id_table_5052[j].idProduct = product_5052[i]; 337 ti_id_table_5052[j].idProduct = product_5052[i];
321 ti_id_table_5052[j].match_flags = USB_DEVICE_ID_MATCH_DEVICE; 338 ti_id_table_5052[j].match_flags = USB_DEVICE_ID_MATCH_DEVICE;
339 ti_id_table_combined[c].idVendor = vendor_5052[i];
340 ti_id_table_combined[c].idProduct = product_5052[i];
341 ti_id_table_combined[c].match_flags = USB_DEVICE_ID_MATCH_DEVICE;
322 } 342 }
323 343
324 ret = usb_serial_register(&ti_1port_device); 344 ret = usb_serial_register(&ti_1port_device);
@@ -390,11 +410,7 @@ static int ti_startup(struct usb_serial *serial)
390 410
391 /* if we have only 1 configuration, download firmware */ 411 /* if we have only 1 configuration, download firmware */
392 if (dev->descriptor.bNumConfigurations == 1) { 412 if (dev->descriptor.bNumConfigurations == 1) {
393 if (tdev->td_is_3410) 413 if ((status = ti_download_firmware(tdev)) != 0)
394 status = ti_download_firmware(tdev, 3410);
395 else
396 status = ti_download_firmware(tdev, 5052);
397 if (status)
398 goto free_tdev; 414 goto free_tdev;
399 415
400 /* 3410 must be reset, 5052 resets itself */ 416 /* 3410 must be reset, 5052 resets itself */
@@ -1671,9 +1687,9 @@ static int ti_do_download(struct usb_device *dev, int pipe,
1671 return status; 1687 return status;
1672} 1688}
1673 1689
1674static int ti_download_firmware(struct ti_device *tdev, int type) 1690static int ti_download_firmware(struct ti_device *tdev)
1675{ 1691{
1676 int status = -ENOMEM; 1692 int status;
1677 int buffer_size; 1693 int buffer_size;
1678 __u8 *buffer; 1694 __u8 *buffer;
1679 struct usb_device *dev = tdev->td_serial->dev; 1695 struct usb_device *dev = tdev->td_serial->dev;
@@ -1681,9 +1697,34 @@ static int ti_download_firmware(struct ti_device *tdev, int type)
1681 tdev->td_serial->port[0]->bulk_out_endpointAddress); 1697 tdev->td_serial->port[0]->bulk_out_endpointAddress);
1682 const struct firmware *fw_p; 1698 const struct firmware *fw_p;
1683 char buf[32]; 1699 char buf[32];
1684 sprintf(buf, "ti_usb-%d.bin", type);
1685 1700
1686 if (request_firmware(&fw_p, buf, &dev->dev)) { 1701 /* try ID specific firmware first, then try generic firmware */
1702 sprintf(buf, "ti_usb-v%04x-p%04x.fw", dev->descriptor.idVendor,
1703 dev->descriptor.idProduct);
1704 if ((status = request_firmware(&fw_p, buf, &dev->dev)) != 0) {
1705 buf[0] = '\0';
1706 if (dev->descriptor.idVendor == MTS_VENDOR_ID) {
1707 switch (dev->descriptor.idProduct) {
1708 case MTS_CDMA_PRODUCT_ID:
1709 strcpy(buf, "mts_cdma.fw");
1710 break;
1711 case MTS_GSM_PRODUCT_ID:
1712 strcpy(buf, "mts_gsm.fw");
1713 break;
1714 case MTS_EDGE_PRODUCT_ID:
1715 strcpy(buf, "mts_edge.fw");
1716 break;
1717 }
1718 }
1719 if (buf[0] == '\0') {
1720 if (tdev->td_is_3410)
1721 strcpy(buf, "ti_3410.fw");
1722 else
1723 strcpy(buf, "ti_5052.fw");
1724 }
1725 status = request_firmware(&fw_p, buf, &dev->dev);
1726 }
1727 if (status) {
1687 dev_err(&dev->dev, "%s - firmware not found\n", __func__); 1728 dev_err(&dev->dev, "%s - firmware not found\n", __func__);
1688 return -ENOENT; 1729 return -ENOENT;
1689 } 1730 }
@@ -1699,6 +1740,8 @@ static int ti_download_firmware(struct ti_device *tdev, int type)
1699 memset(buffer + fw_p->size, 0xff, buffer_size - fw_p->size); 1740 memset(buffer + fw_p->size, 0xff, buffer_size - fw_p->size);
1700 status = ti_do_download(dev, pipe, buffer, fw_p->size); 1741 status = ti_do_download(dev, pipe, buffer, fw_p->size);
1701 kfree(buffer); 1742 kfree(buffer);
1743 } else {
1744 status = -ENOMEM;
1702 } 1745 }
1703 release_firmware(fw_p); 1746 release_firmware(fw_p);
1704 if (status) { 1747 if (status) {
diff --git a/drivers/usb/serial/ti_usb_3410_5052.h b/drivers/usb/serial/ti_usb_3410_5052.h
index b5541bf991b..7e4752fbf23 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.h
+++ b/drivers/usb/serial/ti_usb_3410_5052.h
@@ -34,6 +34,14 @@
34#define TI_5052_EEPROM_PRODUCT_ID 0x505A /* EEPROM, no firmware */ 34#define TI_5052_EEPROM_PRODUCT_ID 0x505A /* EEPROM, no firmware */
35#define TI_5052_FIRMWARE_PRODUCT_ID 0x505F /* firmware is running */ 35#define TI_5052_FIRMWARE_PRODUCT_ID 0x505F /* firmware is running */
36 36
37/* Multi-Tech vendor and product ids */
38#define MTS_VENDOR_ID 0x06E0
39#define MTS_GSM_NO_FW_PRODUCT_ID 0xF108
40#define MTS_CDMA_NO_FW_PRODUCT_ID 0xF109
41#define MTS_CDMA_PRODUCT_ID 0xF110
42#define MTS_GSM_PRODUCT_ID 0xF111
43#define MTS_EDGE_PRODUCT_ID 0xF112
44
37/* Commands */ 45/* Commands */
38#define TI_GET_VERSION 0x01 46#define TI_GET_VERSION 0x01
39#define TI_GET_PORT_STATUS 0x02 47#define TI_GET_PORT_STATUS 0x02
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 080ade223d5..cfcfd5ab06c 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -511,9 +511,6 @@ static void usb_serial_port_work(struct work_struct *work)
511 511
512 dbg("%s - port %d", __func__, port->number); 512 dbg("%s - port %d", __func__, port->number);
513 513
514 if (!port)
515 return;
516
517 tty = tty_port_tty_get(&port->port); 514 tty = tty_port_tty_get(&port->port);
518 if (!tty) 515 if (!tty)
519 return; 516 return;
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index e39e33e797d..be2b657546e 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -28,7 +28,7 @@ obj-$(CONFIG_FB_DDC) += fb_ddc.o
28obj-$(CONFIG_FB_DEFERRED_IO) += fb_defio.o 28obj-$(CONFIG_FB_DEFERRED_IO) += fb_defio.o
29 29
30# Hardware specific drivers go first 30# Hardware specific drivers go first
31obj-$(CONFIG_FB_AMIGA) += amifb.o c2p.o 31obj-$(CONFIG_FB_AMIGA) += amifb.o c2p_planar.o
32obj-$(CONFIG_FB_ARC) += arcfb.o 32obj-$(CONFIG_FB_ARC) += arcfb.o
33obj-$(CONFIG_FB_CLPS711X) += clps711xfb.o 33obj-$(CONFIG_FB_CLPS711X) += clps711xfb.o
34obj-$(CONFIG_FB_CYBER2000) += cyber2000fb.o 34obj-$(CONFIG_FB_CYBER2000) += cyber2000fb.o
@@ -72,7 +72,7 @@ obj-$(CONFIG_FB_TCX) += tcx.o sbuslib.o
72obj-$(CONFIG_FB_LEO) += leo.o sbuslib.o 72obj-$(CONFIG_FB_LEO) += leo.o sbuslib.o
73obj-$(CONFIG_FB_SGIVW) += sgivwfb.o 73obj-$(CONFIG_FB_SGIVW) += sgivwfb.o
74obj-$(CONFIG_FB_ACORN) += acornfb.o 74obj-$(CONFIG_FB_ACORN) += acornfb.o
75obj-$(CONFIG_FB_ATARI) += atafb.o c2p.o atafb_mfb.o \ 75obj-$(CONFIG_FB_ATARI) += atafb.o c2p_iplan2.o atafb_mfb.o \
76 atafb_iplan2p2.o atafb_iplan2p4.o atafb_iplan2p8.o 76 atafb_iplan2p2.o atafb_iplan2p4.o atafb_iplan2p8.o
77obj-$(CONFIG_FB_MAC) += macfb.o 77obj-$(CONFIG_FB_MAC) += macfb.o
78obj-$(CONFIG_FB_HECUBA) += hecubafb.o 78obj-$(CONFIG_FB_HECUBA) += hecubafb.o
diff --git a/drivers/video/amifb.c b/drivers/video/amifb.c
index b8e9a8682f2..100f2366146 100644
--- a/drivers/video/amifb.c
+++ b/drivers/video/amifb.c
@@ -2159,9 +2159,9 @@ static void amifb_imageblit(struct fb_info *info, const struct fb_image *image)
2159 src += pitch; 2159 src += pitch;
2160 } 2160 }
2161 } else { 2161 } else {
2162 c2p(info->screen_base, image->data, dx, dy, width, height, 2162 c2p_planar(info->screen_base, image->data, dx, dy, width,
2163 par->next_line, par->next_plane, image->width, 2163 height, par->next_line, par->next_plane,
2164 info->var.bits_per_pixel); 2164 image->width, info->var.bits_per_pixel);
2165 } 2165 }
2166} 2166}
2167 2167
diff --git a/drivers/video/atafb.c b/drivers/video/atafb.c
index 77eb8b34fbf..8058572a742 100644
--- a/drivers/video/atafb.c
+++ b/drivers/video/atafb.c
@@ -122,7 +122,6 @@ static struct atafb_par {
122 void *screen_base; 122 void *screen_base;
123 int yres_virtual; 123 int yres_virtual;
124 u_long next_line; 124 u_long next_line;
125 u_long next_plane;
126#if defined ATAFB_TT || defined ATAFB_STE 125#if defined ATAFB_TT || defined ATAFB_STE
127 union { 126 union {
128 struct { 127 struct {
@@ -149,6 +148,7 @@ static struct atafb_par {
149 short mono; 148 short mono;
150 short ste_mode; 149 short ste_mode;
151 short bpp; 150 short bpp;
151 u32 pseudo_palette[16];
152 } falcon; 152 } falcon;
153#endif 153#endif
154 /* Nothing needed for external mode */ 154 /* Nothing needed for external mode */
@@ -614,7 +614,7 @@ static int tt_encode_fix(struct fb_fix_screeninfo *fix, struct atafb_par *par)
614 fix->xpanstep = 0; 614 fix->xpanstep = 0;
615 fix->ypanstep = 1; 615 fix->ypanstep = 1;
616 fix->ywrapstep = 0; 616 fix->ywrapstep = 0;
617 fix->line_length = 0; 617 fix->line_length = par->next_line;
618 fix->accel = FB_ACCEL_ATARIBLITT; 618 fix->accel = FB_ACCEL_ATARIBLITT;
619 return 0; 619 return 0;
620} 620}
@@ -691,6 +691,7 @@ static int tt_decode_var(struct fb_var_screeninfo *var, struct atafb_par *par)
691 return -EINVAL; 691 return -EINVAL;
692 par->yres_virtual = yres_virtual; 692 par->yres_virtual = yres_virtual;
693 par->screen_base = screen_base + var->yoffset * linelen; 693 par->screen_base = screen_base + var->yoffset * linelen;
694 par->next_line = linelen;
694 return 0; 695 return 0;
695} 696}
696 697
@@ -884,10 +885,6 @@ static int vdl_prescale[4][3] = {
884/* Default hsync timing [mon_type] in picoseconds */ 885/* Default hsync timing [mon_type] in picoseconds */
885static long h_syncs[4] = { 3000000, 4875000, 4000000, 4875000 }; 886static long h_syncs[4] = { 3000000, 4875000, 4000000, 4875000 };
886 887
887#ifdef FBCON_HAS_CFB16
888static u16 fbcon_cfb16_cmap[16];
889#endif
890
891static inline int hxx_prescale(struct falcon_hw *hw) 888static inline int hxx_prescale(struct falcon_hw *hw)
892{ 889{
893 return hw->ste_mode ? 16 890 return hw->ste_mode ? 16
@@ -918,7 +915,7 @@ static int falcon_encode_fix(struct fb_fix_screeninfo *fix,
918 fix->visual = FB_VISUAL_TRUECOLOR; 915 fix->visual = FB_VISUAL_TRUECOLOR;
919 fix->xpanstep = 2; 916 fix->xpanstep = 2;
920 } 917 }
921 fix->line_length = 0; 918 fix->line_length = par->next_line;
922 fix->accel = FB_ACCEL_ATARIBLITT; 919 fix->accel = FB_ACCEL_ATARIBLITT;
923 return 0; 920 return 0;
924} 921}
@@ -1394,14 +1391,7 @@ set_screen_base:
1394 par->screen_base = screen_base + var->yoffset * linelen; 1391 par->screen_base = screen_base + var->yoffset * linelen;
1395 par->hw.falcon.xoffset = 0; 1392 par->hw.falcon.xoffset = 0;
1396 1393
1397 // FIXME!!! sort of works, no crash
1398 //par->next_line = linelen;
1399 //par->next_plane = yres_virtual * linelen;
1400 par->next_line = linelen; 1394 par->next_line = linelen;
1401 par->next_plane = 2;
1402 // crashes
1403 //par->next_plane = linelen;
1404 //par->next_line = yres_virtual * linelen;
1405 1395
1406 return 0; 1396 return 0;
1407} 1397}
@@ -1735,10 +1725,10 @@ static int falcon_setcolreg(unsigned int regno, unsigned int red,
1735 (((red & 0xe000) >> 13) | ((red & 0x1000) >> 12) << 8) | 1725 (((red & 0xe000) >> 13) | ((red & 0x1000) >> 12) << 8) |
1736 (((green & 0xe000) >> 13) | ((green & 0x1000) >> 12) << 4) | 1726 (((green & 0xe000) >> 13) | ((green & 0x1000) >> 12) << 4) |
1737 ((blue & 0xe000) >> 13) | ((blue & 0x1000) >> 12); 1727 ((blue & 0xe000) >> 13) | ((blue & 0x1000) >> 12);
1738#ifdef FBCON_HAS_CFB16 1728#ifdef ATAFB_FALCON
1739 fbcon_cfb16_cmap[regno] = ((red & 0xf800) | 1729 ((u32 *)info->pseudo_palette)[regno] = ((red & 0xf800) |
1740 ((green & 0xfc00) >> 5) | 1730 ((green & 0xfc00) >> 5) |
1741 ((blue & 0xf800) >> 11)); 1731 ((blue & 0xf800) >> 11));
1742#endif 1732#endif
1743 } 1733 }
1744 return 0; 1734 return 0;
@@ -1852,7 +1842,7 @@ static int stste_encode_fix(struct fb_fix_screeninfo *fix,
1852 fix->ypanstep = 0; 1842 fix->ypanstep = 0;
1853 } 1843 }
1854 fix->ywrapstep = 0; 1844 fix->ywrapstep = 0;
1855 fix->line_length = 0; 1845 fix->line_length = par->next_line;
1856 fix->accel = FB_ACCEL_ATARIBLITT; 1846 fix->accel = FB_ACCEL_ATARIBLITT;
1857 return 0; 1847 return 0;
1858} 1848}
@@ -1910,6 +1900,7 @@ static int stste_decode_var(struct fb_var_screeninfo *var,
1910 return -EINVAL; 1900 return -EINVAL;
1911 par->yres_virtual = yres_virtual; 1901 par->yres_virtual = yres_virtual;
1912 par->screen_base = screen_base + var->yoffset * linelen; 1902 par->screen_base = screen_base + var->yoffset * linelen;
1903 par->next_line = linelen;
1913 return 0; 1904 return 0;
1914} 1905}
1915 1906
@@ -2169,7 +2160,7 @@ static int ext_encode_fix(struct fb_fix_screeninfo *fix, struct atafb_par *par)
2169 fix->xpanstep = 0; 2160 fix->xpanstep = 0;
2170 fix->ypanstep = 0; 2161 fix->ypanstep = 0;
2171 fix->ywrapstep = 0; 2162 fix->ywrapstep = 0;
2172 fix->line_length = 0; 2163 fix->line_length = par->next_line;
2173 return 0; 2164 return 0;
2174} 2165}
2175 2166
@@ -2184,6 +2175,8 @@ static int ext_decode_var(struct fb_var_screeninfo *var, struct atafb_par *par)
2184 var->xoffset > 0 || 2175 var->xoffset > 0 ||
2185 var->yoffset > 0) 2176 var->yoffset > 0)
2186 return -EINVAL; 2177 return -EINVAL;
2178
2179 par->next_line = external_xres_virtual * external_depth / 8;
2187 return 0; 2180 return 0;
2188} 2181}
2189 2182
@@ -2443,42 +2436,6 @@ static void atafb_set_disp(struct fb_info *info)
2443 atafb_get_fix(&info->fix, info); 2436 atafb_get_fix(&info->fix, info);
2444 2437
2445 info->screen_base = (void *)info->fix.smem_start; 2438 info->screen_base = (void *)info->fix.smem_start;
2446
2447 switch (info->fix.type) {
2448 case FB_TYPE_INTERLEAVED_PLANES:
2449 switch (info->var.bits_per_pixel) {
2450 case 2:
2451 // display->dispsw = &fbcon_iplan2p2;
2452 break;
2453 case 4:
2454 // display->dispsw = &fbcon_iplan2p4;
2455 break;
2456 case 8:
2457 // display->dispsw = &fbcon_iplan2p8;
2458 break;
2459 }
2460 break;
2461 case FB_TYPE_PACKED_PIXELS:
2462 switch (info->var.bits_per_pixel) {
2463#ifdef FBCON_HAS_MFB
2464 case 1:
2465 // display->dispsw = &fbcon_mfb;
2466 break;
2467#endif
2468#ifdef FBCON_HAS_CFB8
2469 case 8:
2470 // display->dispsw = &fbcon_cfb8;
2471 break;
2472#endif
2473#ifdef FBCON_HAS_CFB16
2474 case 16:
2475 // display->dispsw = &fbcon_cfb16;
2476 // display->dispsw_data = fbcon_cfb16_cmap;
2477 break;
2478#endif
2479 }
2480 break;
2481 }
2482} 2439}
2483 2440
2484static int atafb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, 2441static int atafb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
@@ -2549,6 +2506,13 @@ static void atafb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
2549 if (!rect->width || !rect->height) 2506 if (!rect->width || !rect->height)
2550 return; 2507 return;
2551 2508
2509#ifdef ATAFB_FALCON
2510 if (info->var.bits_per_pixel == 16) {
2511 cfb_fillrect(info, rect);
2512 return;
2513 }
2514#endif
2515
2552 /* 2516 /*
2553 * We could use hardware clipping but on many cards you get around 2517 * We could use hardware clipping but on many cards you get around
2554 * hardware clipping by writing to framebuffer directly. 2518 * hardware clipping by writing to framebuffer directly.
@@ -2583,6 +2547,13 @@ static void atafb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
2583 u32 dx, dy, sx, sy, width, height; 2547 u32 dx, dy, sx, sy, width, height;
2584 int rev_copy = 0; 2548 int rev_copy = 0;
2585 2549
2550#ifdef ATAFB_FALCON
2551 if (info->var.bits_per_pixel == 16) {
2552 cfb_copyarea(info, area);
2553 return;
2554 }
2555#endif
2556
2586 /* clip the destination */ 2557 /* clip the destination */
2587 x2 = area->dx + area->width; 2558 x2 = area->dx + area->width;
2588 y2 = area->dy + area->height; 2559 y2 = area->dy + area->height;
@@ -2632,6 +2603,13 @@ static void atafb_imageblit(struct fb_info *info, const struct fb_image *image)
2632 const char *src; 2603 const char *src;
2633 u32 dx, dy, width, height, pitch; 2604 u32 dx, dy, width, height, pitch;
2634 2605
2606#ifdef ATAFB_FALCON
2607 if (info->var.bits_per_pixel == 16) {
2608 cfb_imageblit(info, image);
2609 return;
2610 }
2611#endif
2612
2635 /* 2613 /*
2636 * We could use hardware clipping but on many cards you get around 2614 * We could use hardware clipping but on many cards you get around
2637 * hardware clipping by writing to framebuffer directly like we are 2615 * hardware clipping by writing to framebuffer directly like we are
@@ -2676,10 +2654,9 @@ static void atafb_imageblit(struct fb_info *info, const struct fb_image *image)
2676 src += pitch; 2654 src += pitch;
2677 } 2655 }
2678 } else { 2656 } else {
2679 // only used for logo; broken 2657 c2p_iplan2(info->screen_base, image->data, dx, dy, width,
2680 c2p(info->screen_base, image->data, dx, dy, width, height, 2658 height, par->next_line, image->width,
2681 par->next_line, par->next_plane, image->width, 2659 info->var.bits_per_pixel);
2682 info->var.bits_per_pixel);
2683 } 2660 }
2684} 2661}
2685 2662
@@ -3098,8 +3075,7 @@ int __init atafb_setup(char *options)
3098 3075
3099int __init atafb_init(void) 3076int __init atafb_init(void)
3100{ 3077{
3101 int pad; 3078 int pad, detected_mode, error;
3102 int detected_mode;
3103 unsigned int defmode = 0; 3079 unsigned int defmode = 0;
3104 unsigned long mem_req; 3080 unsigned long mem_req;
3105 3081
@@ -3139,8 +3115,12 @@ int __init atafb_init(void)
3139 printk("atafb_init: initializing Falcon hw\n"); 3115 printk("atafb_init: initializing Falcon hw\n");
3140 fbhw = &falcon_switch; 3116 fbhw = &falcon_switch;
3141 atafb_ops.fb_setcolreg = &falcon_setcolreg; 3117 atafb_ops.fb_setcolreg = &falcon_setcolreg;
3142 request_irq(IRQ_AUTO_4, falcon_vbl_switcher, IRQ_TYPE_PRIO, 3118 error = request_irq(IRQ_AUTO_4, falcon_vbl_switcher,
3143 "framebuffer/modeswitch", falcon_vbl_switcher); 3119 IRQ_TYPE_PRIO,
3120 "framebuffer/modeswitch",
3121 falcon_vbl_switcher);
3122 if (error)
3123 return error;
3144 defmode = DEFMODE_F30; 3124 defmode = DEFMODE_F30;
3145 break; 3125 break;
3146 } 3126 }
@@ -3225,6 +3205,10 @@ int __init atafb_init(void)
3225 // tries to read from HW which may not be initialized yet 3205 // tries to read from HW which may not be initialized yet
3226 // so set sane var first, then call atafb_set_par 3206 // so set sane var first, then call atafb_set_par
3227 atafb_get_var(&fb_info.var, &fb_info); 3207 atafb_get_var(&fb_info.var, &fb_info);
3208
3209#ifdef ATAFB_FALCON
3210 fb_info.pseudo_palette = current_par.hw.falcon.pseudo_palette;
3211#endif
3228 fb_info.flags = FBINFO_FLAG_DEFAULT; 3212 fb_info.flags = FBINFO_FLAG_DEFAULT;
3229 3213
3230 if (!fb_find_mode(&fb_info.var, &fb_info, mode_option, atafb_modedb, 3214 if (!fb_find_mode(&fb_info.var, &fb_info, mode_option, atafb_modedb,
diff --git a/drivers/video/c2p.c b/drivers/video/c2p.c
deleted file mode 100644
index 376bc07ff95..00000000000
--- a/drivers/video/c2p.c
+++ /dev/null
@@ -1,232 +0,0 @@
1/*
2 * Fast C2P (Chunky-to-Planar) Conversion
3 *
4 * Copyright (C) 2003 Geert Uytterhoeven
5 *
6 * NOTES:
7 * - This code was inspired by Scout's C2P tutorial
8 * - It assumes to run on a big endian system
9 *
10 * This file is subject to the terms and conditions of the GNU General Public
11 * License. See the file COPYING in the main directory of this archive
12 * for more details.
13 */
14
15#include <linux/module.h>
16#include <linux/string.h>
17#include "c2p.h"
18
19
20 /*
21 * Basic transpose step
22 */
23
24#define _transp(d, i1, i2, shift, mask) \
25 do { \
26 u32 t = (d[i1] ^ (d[i2] >> shift)) & mask; \
27 d[i1] ^= t; \
28 d[i2] ^= t << shift; \
29 } while (0)
30
31static inline u32 get_mask(int n)
32{
33 switch (n) {
34 case 1:
35 return 0x55555555;
36 break;
37
38 case 2:
39 return 0x33333333;
40 break;
41
42 case 4:
43 return 0x0f0f0f0f;
44 break;
45
46 case 8:
47 return 0x00ff00ff;
48 break;
49
50 case 16:
51 return 0x0000ffff;
52 break;
53 }
54 return 0;
55}
56
57#define transp_nx1(d, n) \
58 do { \
59 u32 mask = get_mask(n); \
60 /* First block */ \
61 _transp(d, 0, 1, n, mask); \
62 /* Second block */ \
63 _transp(d, 2, 3, n, mask); \
64 /* Third block */ \
65 _transp(d, 4, 5, n, mask); \
66 /* Fourth block */ \
67 _transp(d, 6, 7, n, mask); \
68 } while (0)
69
70#define transp_nx2(d, n) \
71 do { \
72 u32 mask = get_mask(n); \
73 /* First block */ \
74 _transp(d, 0, 2, n, mask); \
75 _transp(d, 1, 3, n, mask); \
76 /* Second block */ \
77 _transp(d, 4, 6, n, mask); \
78 _transp(d, 5, 7, n, mask); \
79 } while (0)
80
81#define transp_nx4(d, n) \
82 do { \
83 u32 mask = get_mask(n); \
84 _transp(d, 0, 4, n, mask); \
85 _transp(d, 1, 5, n, mask); \
86 _transp(d, 2, 6, n, mask); \
87 _transp(d, 3, 7, n, mask); \
88 } while (0)
89
90#define transp(d, n, m) transp_nx ## m(d, n)
91
92
93 /*
94 * Perform a full C2P step on 32 8-bit pixels, stored in 8 32-bit words
95 * containing
96 * - 32 8-bit chunky pixels on input
97 * - permuted planar data on output
98 */
99
100static void c2p_8bpp(u32 d[8])
101{
102 transp(d, 16, 4);
103 transp(d, 8, 2);
104 transp(d, 4, 1);
105 transp(d, 2, 4);
106 transp(d, 1, 2);
107}
108
109
110 /*
111 * Array containing the permution indices of the planar data after c2p
112 */
113
114static const int perm_c2p_8bpp[8] = { 7, 5, 3, 1, 6, 4, 2, 0 };
115
116
117 /*
118 * Compose two values, using a bitmask as decision value
119 * This is equivalent to (a & mask) | (b & ~mask)
120 */
121
122static inline unsigned long comp(unsigned long a, unsigned long b,
123 unsigned long mask)
124{
125 return ((a ^ b) & mask) ^ b;
126}
127
128
129 /*
130 * Store a full block of planar data after c2p conversion
131 */
132
133static inline void store_planar(char *dst, u32 dst_inc, u32 bpp, u32 d[8])
134{
135 int i;
136
137 for (i = 0; i < bpp; i++, dst += dst_inc)
138 *(u32 *)dst = d[perm_c2p_8bpp[i]];
139}
140
141
142 /*
143 * Store a partial block of planar data after c2p conversion
144 */
145
146static inline void store_planar_masked(char *dst, u32 dst_inc, u32 bpp,
147 u32 d[8], u32 mask)
148{
149 int i;
150
151 for (i = 0; i < bpp; i++, dst += dst_inc)
152 *(u32 *)dst = comp(d[perm_c2p_8bpp[i]], *(u32 *)dst, mask);
153}
154
155
156 /*
157 * c2p - Copy 8-bit chunky image data to a planar frame buffer
158 * @dst: Starting address of the planar frame buffer
159 * @dx: Horizontal destination offset (in pixels)
160 * @dy: Vertical destination offset (in pixels)
161 * @width: Image width (in pixels)
162 * @height: Image height (in pixels)
163 * @dst_nextline: Frame buffer offset to the next line (in bytes)
164 * @dst_nextplane: Frame buffer offset to the next plane (in bytes)
165 * @src_nextline: Image offset to the next line (in bytes)
166 * @bpp: Bits per pixel of the planar frame buffer (1-8)
167 */
168
169void c2p(u8 *dst, const u8 *src, u32 dx, u32 dy, u32 width, u32 height,
170 u32 dst_nextline, u32 dst_nextplane, u32 src_nextline, u32 bpp)
171{
172 int dst_idx;
173 u32 d[8], first, last, w;
174 const u8 *c;
175 u8 *p;
176
177 dst += dy*dst_nextline+(dx & ~31);
178 dst_idx = dx % 32;
179 first = ~0UL >> dst_idx;
180 last = ~(~0UL >> ((dst_idx+width) % 32));
181 while (height--) {
182 c = src;
183 p = dst;
184 w = width;
185 if (dst_idx+width <= 32) {
186 /* Single destination word */
187 first &= last;
188 memset(d, 0, sizeof(d));
189 memcpy((u8 *)d+dst_idx, c, width);
190 c += width;
191 c2p_8bpp(d);
192 store_planar_masked(p, dst_nextplane, bpp, d, first);
193 p += 4;
194 } else {
195 /* Multiple destination words */
196 w = width;
197 /* Leading bits */
198 if (dst_idx) {
199 w = 32 - dst_idx;
200 memset(d, 0, dst_idx);
201 memcpy((u8 *)d+dst_idx, c, w);
202 c += w;
203 c2p_8bpp(d);
204 store_planar_masked(p, dst_nextplane, bpp, d, first);
205 p += 4;
206 w = width-w;
207 }
208 /* Main chunk */
209 while (w >= 32) {
210 memcpy(d, c, 32);
211 c += 32;
212 c2p_8bpp(d);
213 store_planar(p, dst_nextplane, bpp, d);
214 p += 4;
215 w -= 32;
216 }
217 /* Trailing bits */
218 w %= 32;
219 if (w > 0) {
220 memcpy(d, c, w);
221 memset((u8 *)d+w, 0, 32-w);
222 c2p_8bpp(d);
223 store_planar_masked(p, dst_nextplane, bpp, d, last);
224 }
225 }
226 src += src_nextline;
227 dst += dst_nextline;
228 }
229}
230EXPORT_SYMBOL_GPL(c2p);
231
232MODULE_LICENSE("GPL");
diff --git a/drivers/video/c2p.h b/drivers/video/c2p.h
index c77cbf17e04..6c38d40427d 100644
--- a/drivers/video/c2p.h
+++ b/drivers/video/c2p.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Fast C2P (Chunky-to-Planar) Conversion 2 * Fast C2P (Chunky-to-Planar) Conversion
3 * 3 *
4 * Copyright (C) 2003 Geert Uytterhoeven 4 * Copyright (C) 2003-2008 Geert Uytterhoeven
5 * 5 *
6 * This file is subject to the terms and conditions of the GNU General Public 6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file COPYING in the main directory of this archive 7 * License. See the file COPYING in the main directory of this archive
@@ -10,7 +10,10 @@
10 10
11#include <linux/types.h> 11#include <linux/types.h>
12 12
13extern void c2p(u8 *dst, const u8 *src, u32 dx, u32 dy, u32 width, u32 height, 13extern void c2p_planar(void *dst, const void *src, u32 dx, u32 dy, u32 width,
14 u32 dst_nextline, u32 dst_nextplane, u32 src_nextline, 14 u32 height, u32 dst_nextline, u32 dst_nextplane,
15 u32 bpp); 15 u32 src_nextline, u32 bpp);
16 16
17extern void c2p_iplan2(void *dst, const void *src, u32 dx, u32 dy, u32 width,
18 u32 height, u32 dst_nextline, u32 src_nextline,
19 u32 bpp);
diff --git a/drivers/video/c2p_core.h b/drivers/video/c2p_core.h
new file mode 100644
index 00000000000..e1035a865fb
--- /dev/null
+++ b/drivers/video/c2p_core.h
@@ -0,0 +1,153 @@
1/*
2 * Fast C2P (Chunky-to-Planar) Conversion
3 *
4 * Copyright (C) 2003-2008 Geert Uytterhoeven
5 *
6 * NOTES:
7 * - This code was inspired by Scout's C2P tutorial
8 * - It assumes to run on a big endian system
9 *
10 * This file is subject to the terms and conditions of the GNU General Public
11 * License. See the file COPYING in the main directory of this archive
12 * for more details.
13 */
14
15
16 /*
17 * Basic transpose step
18 */
19
20static inline void _transp(u32 d[], unsigned int i1, unsigned int i2,
21 unsigned int shift, u32 mask)
22{
23 u32 t = (d[i1] ^ (d[i2] >> shift)) & mask;
24
25 d[i1] ^= t;
26 d[i2] ^= t << shift;
27}
28
29
30extern void c2p_unsupported(void);
31
32static inline u32 get_mask(unsigned int n)
33{
34 switch (n) {
35 case 1:
36 return 0x55555555;
37
38 case 2:
39 return 0x33333333;
40
41 case 4:
42 return 0x0f0f0f0f;
43
44 case 8:
45 return 0x00ff00ff;
46
47 case 16:
48 return 0x0000ffff;
49 }
50
51 c2p_unsupported();
52 return 0;
53}
54
55
56 /*
57 * Transpose operations on 8 32-bit words
58 */
59
60static inline void transp8(u32 d[], unsigned int n, unsigned int m)
61{
62 u32 mask = get_mask(n);
63
64 switch (m) {
65 case 1:
66 /* First n x 1 block */
67 _transp(d, 0, 1, n, mask);
68 /* Second n x 1 block */
69 _transp(d, 2, 3, n, mask);
70 /* Third n x 1 block */
71 _transp(d, 4, 5, n, mask);
72 /* Fourth n x 1 block */
73 _transp(d, 6, 7, n, mask);
74 return;
75
76 case 2:
77 /* First n x 2 block */
78 _transp(d, 0, 2, n, mask);
79 _transp(d, 1, 3, n, mask);
80 /* Second n x 2 block */
81 _transp(d, 4, 6, n, mask);
82 _transp(d, 5, 7, n, mask);
83 return;
84
85 case 4:
86 /* Single n x 4 block */
87 _transp(d, 0, 4, n, mask);
88 _transp(d, 1, 5, n, mask);
89 _transp(d, 2, 6, n, mask);
90 _transp(d, 3, 7, n, mask);
91 return;
92 }
93
94 c2p_unsupported();
95}
96
97
98 /*
99 * Transpose operations on 4 32-bit words
100 */
101
102static inline void transp4(u32 d[], unsigned int n, unsigned int m)
103{
104 u32 mask = get_mask(n);
105
106 switch (m) {
107 case 1:
108 /* First n x 1 block */
109 _transp(d, 0, 1, n, mask);
110 /* Second n x 1 block */
111 _transp(d, 2, 3, n, mask);
112 return;
113
114 case 2:
115 /* Single n x 2 block */
116 _transp(d, 0, 2, n, mask);
117 _transp(d, 1, 3, n, mask);
118 return;
119 }
120
121 c2p_unsupported();
122}
123
124
125 /*
126 * Transpose operations on 4 32-bit words (reverse order)
127 */
128
129static inline void transp4x(u32 d[], unsigned int n, unsigned int m)
130{
131 u32 mask = get_mask(n);
132
133 switch (m) {
134 case 2:
135 /* Single n x 2 block */
136 _transp(d, 2, 0, n, mask);
137 _transp(d, 3, 1, n, mask);
138 return;
139 }
140
141 c2p_unsupported();
142}
143
144
145 /*
146 * Compose two values, using a bitmask as decision value
147 * This is equivalent to (a & mask) | (b & ~mask)
148 */
149
150static inline u32 comp(u32 a, u32 b, u32 mask)
151{
152 return ((a ^ b) & mask) ^ b;
153}
diff --git a/drivers/video/c2p_iplan2.c b/drivers/video/c2p_iplan2.c
new file mode 100644
index 00000000000..19156dc6158
--- /dev/null
+++ b/drivers/video/c2p_iplan2.c
@@ -0,0 +1,153 @@
1/*
2 * Fast C2P (Chunky-to-Planar) Conversion
3 *
4 * Copyright (C) 2003-2008 Geert Uytterhoeven
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file COPYING in the main directory of this archive
8 * for more details.
9 */
10
11#include <linux/module.h>
12#include <linux/string.h>
13
14#include <asm/unaligned.h>
15
16#include "c2p.h"
17#include "c2p_core.h"
18
19
20 /*
21 * Perform a full C2P step on 16 8-bit pixels, stored in 4 32-bit words
22 * containing
23 * - 16 8-bit chunky pixels on input
24 * - permutated planar data (2 planes per 32-bit word) on output
25 */
26
27static void c2p_16x8(u32 d[4])
28{
29 transp4(d, 8, 2);
30 transp4(d, 1, 2);
31 transp4x(d, 16, 2);
32 transp4x(d, 2, 2);
33 transp4(d, 4, 1);
34}
35
36
37 /*
38 * Array containing the permutation indices of the planar data after c2p
39 */
40
41static const int perm_c2p_16x8[4] = { 1, 3, 0, 2 };
42
43
44 /*
45 * Store a full block of iplan2 data after c2p conversion
46 */
47
48static inline void store_iplan2(void *dst, u32 bpp, u32 d[4])
49{
50 int i;
51
52 for (i = 0; i < bpp/2; i++, dst += 4)
53 put_unaligned_be32(d[perm_c2p_16x8[i]], dst);
54}
55
56
57 /*
58 * Store a partial block of iplan2 data after c2p conversion
59 */
60
61static inline void store_iplan2_masked(void *dst, u32 bpp, u32 d[4], u32 mask)
62{
63 int i;
64
65 for (i = 0; i < bpp/2; i++, dst += 4)
66 put_unaligned_be32(comp(d[perm_c2p_16x8[i]],
67 get_unaligned_be32(dst), mask),
68 dst);
69}
70
71
72 /*
73 * c2p_iplan2 - Copy 8-bit chunky image data to an interleaved planar
74 * frame buffer with 2 bytes of interleave
75 * @dst: Starting address of the planar frame buffer
76 * @dx: Horizontal destination offset (in pixels)
77 * @dy: Vertical destination offset (in pixels)
78 * @width: Image width (in pixels)
79 * @height: Image height (in pixels)
80 * @dst_nextline: Frame buffer offset to the next line (in bytes)
81 * @src_nextline: Image offset to the next line (in bytes)
82 * @bpp: Bits per pixel of the planar frame buffer (2, 4, or 8)
83 */
84
85void c2p_iplan2(void *dst, const void *src, u32 dx, u32 dy, u32 width,
86 u32 height, u32 dst_nextline, u32 src_nextline, u32 bpp)
87{
88 union {
89 u8 pixels[16];
90 u32 words[4];
91 } d;
92 u32 dst_idx, first, last, w;
93 const u8 *c;
94 void *p;
95
96 dst += dy*dst_nextline+(dx & ~15)*bpp;
97 dst_idx = dx % 16;
98 first = 0xffffU >> dst_idx;
99 first |= first << 16;
100 last = 0xffffU ^ (0xffffU >> ((dst_idx+width) % 16));
101 last |= last << 16;
102 while (height--) {
103 c = src;
104 p = dst;
105 w = width;
106 if (dst_idx+width <= 16) {
107 /* Single destination word */
108 first &= last;
109 memset(d.pixels, 0, sizeof(d));
110 memcpy(d.pixels+dst_idx, c, width);
111 c += width;
112 c2p_16x8(d.words);
113 store_iplan2_masked(p, bpp, d.words, first);
114 p += bpp*2;
115 } else {
116 /* Multiple destination words */
117 w = width;
118 /* Leading bits */
119 if (dst_idx) {
120 w = 16 - dst_idx;
121 memset(d.pixels, 0, dst_idx);
122 memcpy(d.pixels+dst_idx, c, w);
123 c += w;
124 c2p_16x8(d.words);
125 store_iplan2_masked(p, bpp, d.words, first);
126 p += bpp*2;
127 w = width-w;
128 }
129 /* Main chunk */
130 while (w >= 16) {
131 memcpy(d.pixels, c, 16);
132 c += 16;
133 c2p_16x8(d.words);
134 store_iplan2(p, bpp, d.words);
135 p += bpp*2;
136 w -= 16;
137 }
138 /* Trailing bits */
139 w %= 16;
140 if (w > 0) {
141 memcpy(d.pixels, c, w);
142 memset(d.pixels+w, 0, 16-w);
143 c2p_16x8(d.words);
144 store_iplan2_masked(p, bpp, d.words, last);
145 }
146 }
147 src += src_nextline;
148 dst += dst_nextline;
149 }
150}
151EXPORT_SYMBOL_GPL(c2p_iplan2);
152
153MODULE_LICENSE("GPL");
diff --git a/drivers/video/c2p_planar.c b/drivers/video/c2p_planar.c
new file mode 100644
index 00000000000..ec7ac8526f0
--- /dev/null
+++ b/drivers/video/c2p_planar.c
@@ -0,0 +1,156 @@
1/*
2 * Fast C2P (Chunky-to-Planar) Conversion
3 *
4 * Copyright (C) 2003-2008 Geert Uytterhoeven
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file COPYING in the main directory of this archive
8 * for more details.
9 */
10
11#include <linux/module.h>
12#include <linux/string.h>
13
14#include <asm/unaligned.h>
15
16#include "c2p.h"
17#include "c2p_core.h"
18
19
20 /*
21 * Perform a full C2P step on 32 8-bit pixels, stored in 8 32-bit words
22 * containing
23 * - 32 8-bit chunky pixels on input
24 * - permutated planar data (1 plane per 32-bit word) on output
25 */
26
27static void c2p_32x8(u32 d[8])
28{
29 transp8(d, 16, 4);
30 transp8(d, 8, 2);
31 transp8(d, 4, 1);
32 transp8(d, 2, 4);
33 transp8(d, 1, 2);
34}
35
36
37 /*
38 * Array containing the permutation indices of the planar data after c2p
39 */
40
41static const int perm_c2p_32x8[8] = { 7, 5, 3, 1, 6, 4, 2, 0 };
42
43
44 /*
45 * Store a full block of planar data after c2p conversion
46 */
47
48static inline void store_planar(void *dst, u32 dst_inc, u32 bpp, u32 d[8])
49{
50 int i;
51
52 for (i = 0; i < bpp; i++, dst += dst_inc)
53 put_unaligned_be32(d[perm_c2p_32x8[i]], dst);
54}
55
56
57 /*
58 * Store a partial block of planar data after c2p conversion
59 */
60
61static inline void store_planar_masked(void *dst, u32 dst_inc, u32 bpp,
62 u32 d[8], u32 mask)
63{
64 int i;
65
66 for (i = 0; i < bpp; i++, dst += dst_inc)
67 put_unaligned_be32(comp(d[perm_c2p_32x8[i]],
68 get_unaligned_be32(dst), mask),
69 dst);
70}
71
72
73 /*
74 * c2p_planar - Copy 8-bit chunky image data to a planar frame buffer
75 * @dst: Starting address of the planar frame buffer
76 * @dx: Horizontal destination offset (in pixels)
77 * @dy: Vertical destination offset (in pixels)
78 * @width: Image width (in pixels)
79 * @height: Image height (in pixels)
80 * @dst_nextline: Frame buffer offset to the next line (in bytes)
81 * @dst_nextplane: Frame buffer offset to the next plane (in bytes)
82 * @src_nextline: Image offset to the next line (in bytes)
83 * @bpp: Bits per pixel of the planar frame buffer (1-8)
84 */
85
86void c2p_planar(void *dst, const void *src, u32 dx, u32 dy, u32 width,
87 u32 height, u32 dst_nextline, u32 dst_nextplane,
88 u32 src_nextline, u32 bpp)
89{
90 union {
91 u8 pixels[32];
92 u32 words[8];
93 } d;
94 u32 dst_idx, first, last, w;
95 const u8 *c;
96 void *p;
97
98 dst += dy*dst_nextline+(dx & ~31);
99 dst_idx = dx % 32;
100 first = 0xffffffffU >> dst_idx;
101 last = ~(0xffffffffU >> ((dst_idx+width) % 32));
102 while (height--) {
103 c = src;
104 p = dst;
105 w = width;
106 if (dst_idx+width <= 32) {
107 /* Single destination word */
108 first &= last;
109 memset(d.pixels, 0, sizeof(d));
110 memcpy(d.pixels+dst_idx, c, width);
111 c += width;
112 c2p_32x8(d.words);
113 store_planar_masked(p, dst_nextplane, bpp, d.words,
114 first);
115 p += 4;
116 } else {
117 /* Multiple destination words */
118 w = width;
119 /* Leading bits */
120 if (dst_idx) {
121 w = 32 - dst_idx;
122 memset(d.pixels, 0, dst_idx);
123 memcpy(d.pixels+dst_idx, c, w);
124 c += w;
125 c2p_32x8(d.words);
126 store_planar_masked(p, dst_nextplane, bpp,
127 d.words, first);
128 p += 4;
129 w = width-w;
130 }
131 /* Main chunk */
132 while (w >= 32) {
133 memcpy(d.pixels, c, 32);
134 c += 32;
135 c2p_32x8(d.words);
136 store_planar(p, dst_nextplane, bpp, d.words);
137 p += 4;
138 w -= 32;
139 }
140 /* Trailing bits */
141 w %= 32;
142 if (w > 0) {
143 memcpy(d.pixels, c, w);
144 memset(d.pixels+w, 0, 32-w);
145 c2p_32x8(d.words);
146 store_planar_masked(p, dst_nextplane, bpp,
147 d.words, last);
148 }
149 }
150 src += src_nextline;
151 dst += dst_nextline;
152 }
153}
154EXPORT_SYMBOL_GPL(c2p_planar);
155
156MODULE_LICENSE("GPL");
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index 4bcff81b50e..1657b9608b0 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -78,13 +78,6 @@
78#include <asm/fb.h> 78#include <asm/fb.h>
79#include <asm/irq.h> 79#include <asm/irq.h>
80#include <asm/system.h> 80#include <asm/system.h>
81#ifdef CONFIG_ATARI
82#include <asm/atariints.h>
83#endif
84#if defined(__mc68000__)
85#include <asm/machdep.h>
86#include <asm/setup.h>
87#endif
88 81
89#include "fbcon.h" 82#include "fbcon.h"
90 83
@@ -155,9 +148,6 @@ static int fbcon_set_origin(struct vc_data *);
155 148
156#define CURSOR_DRAW_DELAY (1) 149#define CURSOR_DRAW_DELAY (1)
157 150
158/* # VBL ints between cursor state changes */
159#define ATARI_CURSOR_BLINK_RATE (42)
160
161static int vbl_cursor_cnt; 151static int vbl_cursor_cnt;
162static int fbcon_cursor_noblink; 152static int fbcon_cursor_noblink;
163 153
@@ -403,20 +393,6 @@ static void fb_flashcursor(struct work_struct *work)
403 release_console_sem(); 393 release_console_sem();
404} 394}
405 395
406#ifdef CONFIG_ATARI
407static int cursor_blink_rate;
408static irqreturn_t fb_vbl_handler(int irq, void *dev_id)
409{
410 struct fb_info *info = dev_id;
411
412 if (vbl_cursor_cnt && --vbl_cursor_cnt == 0) {
413 schedule_work(&info->queue);
414 vbl_cursor_cnt = cursor_blink_rate;
415 }
416 return IRQ_HANDLED;
417}
418#endif
419
420static void cursor_timer_handler(unsigned long dev_addr) 396static void cursor_timer_handler(unsigned long dev_addr)
421{ 397{
422 struct fb_info *info = (struct fb_info *) dev_addr; 398 struct fb_info *info = (struct fb_info *) dev_addr;
@@ -1017,15 +993,6 @@ static const char *fbcon_startup(void)
1017 info->var.yres, 993 info->var.yres,
1018 info->var.bits_per_pixel); 994 info->var.bits_per_pixel);
1019 995
1020#ifdef CONFIG_ATARI
1021 if (MACH_IS_ATARI) {
1022 cursor_blink_rate = ATARI_CURSOR_BLINK_RATE;
1023 (void)request_irq(IRQ_AUTO_4, fb_vbl_handler,
1024 IRQ_TYPE_PRIO, "framebuffer vbl",
1025 info);
1026 }
1027#endif /* CONFIG_ATARI */
1028
1029 fbcon_add_cursor_timer(info); 996 fbcon_add_cursor_timer(info);
1030 fbcon_has_exited = 0; 997 fbcon_has_exited = 0;
1031 return display_desc; 998 return display_desc;
@@ -3454,11 +3421,6 @@ static void fbcon_exit(void)
3454 if (fbcon_has_exited) 3421 if (fbcon_has_exited)
3455 return; 3422 return;
3456 3423
3457#ifdef CONFIG_ATARI
3458 if (MACH_IS_ATARI)
3459 free_irq(IRQ_AUTO_4, fb_vbl_handler);
3460#endif
3461
3462 kfree((void *)softback_buf); 3424 kfree((void *)softback_buf);
3463 softback_buf = 0UL; 3425 softback_buf = 0UL;
3464 3426
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index ec68c741b56..3efa12f9ee5 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -770,6 +770,12 @@ config TXX9_WDT
770 770
771# POWERPC Architecture 771# POWERPC Architecture
772 772
773config GEF_WDT
774 tristate "GE Fanuc Watchdog Timer"
775 depends on GEF_SBC610
776 ---help---
777 Watchdog timer found in a number of GE Fanuc single board computers.
778
773config MPC5200_WDT 779config MPC5200_WDT
774 tristate "MPC5200 Watchdog Timer" 780 tristate "MPC5200 Watchdog Timer"
775 depends on PPC_MPC52xx 781 depends on PPC_MPC52xx
@@ -790,6 +796,14 @@ config MV64X60_WDT
790 tristate "MV64X60 (Marvell Discovery) Watchdog Timer" 796 tristate "MV64X60 (Marvell Discovery) Watchdog Timer"
791 depends on MV64X60 797 depends on MV64X60
792 798
799config PIKA_WDT
800 tristate "PIKA FPGA Watchdog"
801 depends on WARP
802 default y
803 help
804 This enables the watchdog in the PIKA FPGA. Currently used on
805 the Warp platform.
806
793config BOOKE_WDT 807config BOOKE_WDT
794 bool "PowerPC Book-E Watchdog Timer" 808 bool "PowerPC Book-E Watchdog Timer"
795 depends on BOOKE || 4xx 809 depends on BOOKE || 4xx
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index c19b866f5ed..806b3eb0853 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -111,9 +111,11 @@ obj-$(CONFIG_TXX9_WDT) += txx9wdt.o
111# PARISC Architecture 111# PARISC Architecture
112 112
113# POWERPC Architecture 113# POWERPC Architecture
114obj-$(CONFIG_GEF_WDT) += gef_wdt.o
114obj-$(CONFIG_MPC5200_WDT) += mpc5200_wdt.o 115obj-$(CONFIG_MPC5200_WDT) += mpc5200_wdt.o
115obj-$(CONFIG_8xxx_WDT) += mpc8xxx_wdt.o 116obj-$(CONFIG_8xxx_WDT) += mpc8xxx_wdt.o
116obj-$(CONFIG_MV64X60_WDT) += mv64x60_wdt.o 117obj-$(CONFIG_MV64X60_WDT) += mv64x60_wdt.o
118obj-$(CONFIG_PIKA_WDT) += pika_wdt.o
117obj-$(CONFIG_BOOKE_WDT) += booke_wdt.o 119obj-$(CONFIG_BOOKE_WDT) += booke_wdt.o
118 120
119# PPC64 Architecture 121# PPC64 Architecture
diff --git a/drivers/watchdog/gef_wdt.c b/drivers/watchdog/gef_wdt.c
new file mode 100644
index 00000000000..f0c2b7a1a17
--- /dev/null
+++ b/drivers/watchdog/gef_wdt.c
@@ -0,0 +1,330 @@
1/*
2 * GE Fanuc watchdog userspace interface
3 *
4 * Author: Martyn Welch <martyn.welch@gefanuc.com>
5 *
6 * Copyright 2008 GE Fanuc Intelligent Platforms Embedded Systems, Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 * Based on: mv64x60_wdt.c (MV64X60 watchdog userspace interface)
14 * Author: James Chapman <jchapman@katalix.com>
15 */
16
17/* TODO:
18 * This driver does not provide support for the hardwares capability of sending
19 * an interrupt at a programmable threshold.
20 *
21 * This driver currently can only support 1 watchdog - there are 2 in the
22 * hardware that this driver supports. Thus one could be configured as a
23 * process-based watchdog (via /dev/watchdog), the second (using the interrupt
24 * capabilities) a kernel-based watchdog.
25 */
26
27#include <linux/kernel.h>
28#include <linux/compiler.h>
29#include <linux/init.h>
30#include <linux/module.h>
31#include <linux/miscdevice.h>
32#include <linux/watchdog.h>
33#include <linux/of.h>
34#include <linux/of_platform.h>
35#include <linux/io.h>
36#include <linux/uaccess.h>
37
38#include <sysdev/fsl_soc.h>
39
40/*
41 * The watchdog configuration register contains a pair of 2-bit fields,
42 * 1. a reload field, bits 27-26, which triggers a reload of
43 * the countdown register, and
44 * 2. an enable field, bits 25-24, which toggles between
45 * enabling and disabling the watchdog timer.
46 * Bit 31 is a read-only field which indicates whether the
47 * watchdog timer is currently enabled.
48 *
49 * The low 24 bits contain the timer reload value.
50 */
51#define GEF_WDC_ENABLE_SHIFT 24
52#define GEF_WDC_SERVICE_SHIFT 26
53#define GEF_WDC_ENABLED_SHIFT 31
54
55#define GEF_WDC_ENABLED_TRUE 1
56#define GEF_WDC_ENABLED_FALSE 0
57
58/* Flags bits */
59#define GEF_WDOG_FLAG_OPENED 0
60
61static unsigned long wdt_flags;
62static int wdt_status;
63static void __iomem *gef_wdt_regs;
64static int gef_wdt_timeout;
65static int gef_wdt_count;
66static unsigned int bus_clk;
67static char expect_close;
68static DEFINE_SPINLOCK(gef_wdt_spinlock);
69
70static int nowayout = WATCHDOG_NOWAYOUT;
71module_param(nowayout, int, 0);
72MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
73 __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
74
75
76static int gef_wdt_toggle_wdc(int enabled_predicate, int field_shift)
77{
78 u32 data;
79 u32 enabled;
80 int ret = 0;
81
82 spin_lock(&gef_wdt_spinlock);
83 data = ioread32be(gef_wdt_regs);
84 enabled = (data >> GEF_WDC_ENABLED_SHIFT) & 1;
85
86 /* only toggle the requested field if enabled state matches predicate */
87 if ((enabled ^ enabled_predicate) == 0) {
88 /* We write a 1, then a 2 -- to the appropriate field */
89 data = (1 << field_shift) | gef_wdt_count;
90 iowrite32be(data, gef_wdt_regs);
91
92 data = (2 << field_shift) | gef_wdt_count;
93 iowrite32be(data, gef_wdt_regs);
94 ret = 1;
95 }
96 spin_unlock(&gef_wdt_spinlock);
97
98 return ret;
99}
100
101static void gef_wdt_service(void)
102{
103 gef_wdt_toggle_wdc(GEF_WDC_ENABLED_TRUE,
104 GEF_WDC_SERVICE_SHIFT);
105}
106
107static void gef_wdt_handler_enable(void)
108{
109 if (gef_wdt_toggle_wdc(GEF_WDC_ENABLED_FALSE,
110 GEF_WDC_ENABLE_SHIFT)) {
111 gef_wdt_service();
112 printk(KERN_NOTICE "gef_wdt: watchdog activated\n");
113 }
114}
115
116static void gef_wdt_handler_disable(void)
117{
118 if (gef_wdt_toggle_wdc(GEF_WDC_ENABLED_TRUE,
119 GEF_WDC_ENABLE_SHIFT))
120 printk(KERN_NOTICE "gef_wdt: watchdog deactivated\n");
121}
122
123static void gef_wdt_set_timeout(unsigned int timeout)
124{
125 /* maximum bus cycle count is 0xFFFFFFFF */
126 if (timeout > 0xFFFFFFFF / bus_clk)
127 timeout = 0xFFFFFFFF / bus_clk;
128
129 /* Register only holds upper 24 bits, bit shifted into lower 24 */
130 gef_wdt_count = (timeout * bus_clk) >> 8;
131 gef_wdt_timeout = timeout;
132}
133
134
135static ssize_t gef_wdt_write(struct file *file, const char __user *data,
136 size_t len, loff_t *ppos)
137{
138 if (len) {
139 if (!nowayout) {
140 size_t i;
141
142 expect_close = 0;
143
144 for (i = 0; i != len; i++) {
145 char c;
146 if (get_user(c, data + i))
147 return -EFAULT;
148 if (c == 'V')
149 expect_close = 42;
150 }
151 }
152 gef_wdt_service();
153 }
154
155 return len;
156}
157
158static long gef_wdt_ioctl(struct file *file, unsigned int cmd,
159 unsigned long arg)
160{
161 int timeout;
162 int options;
163 void __user *argp = (void __user *)arg;
164 static struct watchdog_info info = {
165 .options = WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE |
166 WDIOF_KEEPALIVEPING,
167 .firmware_version = 0,
168 .identity = "GE Fanuc watchdog",
169 };
170
171 switch (cmd) {
172 case WDIOC_GETSUPPORT:
173 if (copy_to_user(argp, &info, sizeof(info)))
174 return -EFAULT;
175 break;
176
177 case WDIOC_GETSTATUS:
178 case WDIOC_GETBOOTSTATUS:
179 if (put_user(wdt_status, (int __user *)argp))
180 return -EFAULT;
181 wdt_status &= ~WDIOF_KEEPALIVEPING;
182 break;
183
184 case WDIOC_SETOPTIONS:
185 if (get_user(options, (int __user *)argp))
186 return -EFAULT;
187
188 if (options & WDIOS_DISABLECARD)
189 gef_wdt_handler_disable();
190
191 if (options & WDIOS_ENABLECARD)
192 gef_wdt_handler_enable();
193 break;
194
195 case WDIOC_KEEPALIVE:
196 gef_wdt_service();
197 wdt_status |= WDIOF_KEEPALIVEPING;
198 break;
199
200 case WDIOC_SETTIMEOUT:
201 if (get_user(timeout, (int __user *)argp))
202 return -EFAULT;
203 gef_wdt_set_timeout(timeout);
204 /* Fall through */
205
206 case WDIOC_GETTIMEOUT:
207 if (put_user(gef_wdt_timeout, (int __user *)argp))
208 return -EFAULT;
209 break;
210
211 default:
212 return -ENOTTY;
213 }
214
215 return 0;
216}
217
218static int gef_wdt_open(struct inode *inode, struct file *file)
219{
220 if (test_and_set_bit(GEF_WDOG_FLAG_OPENED, &wdt_flags))
221 return -EBUSY;
222
223 if (nowayout)
224 __module_get(THIS_MODULE);
225
226 gef_wdt_handler_enable();
227
228 return nonseekable_open(inode, file);
229}
230
231static int gef_wdt_release(struct inode *inode, struct file *file)
232{
233 if (expect_close == 42)
234 gef_wdt_handler_disable();
235 else {
236 printk(KERN_CRIT
237 "gef_wdt: unexpected close, not stopping timer!\n");
238 gef_wdt_service();
239 }
240 expect_close = 0;
241
242 clear_bit(GEF_WDOG_FLAG_OPENED, &wdt_flags);
243
244 return 0;
245}
246
247static const struct file_operations gef_wdt_fops = {
248 .owner = THIS_MODULE,
249 .llseek = no_llseek,
250 .write = gef_wdt_write,
251 .unlocked_ioctl = gef_wdt_ioctl,
252 .open = gef_wdt_open,
253 .release = gef_wdt_release,
254};
255
256static struct miscdevice gef_wdt_miscdev = {
257 .minor = WATCHDOG_MINOR,
258 .name = "watchdog",
259 .fops = &gef_wdt_fops,
260};
261
262
263static int __devinit gef_wdt_probe(struct of_device *dev,
264 const struct of_device_id *match)
265{
266 int timeout = 10;
267 u32 freq;
268
269 bus_clk = 133; /* in MHz */
270
271 freq = fsl_get_sys_freq();
272 if (freq > 0)
273 bus_clk = freq;
274
275 /* Map devices registers into memory */
276 gef_wdt_regs = of_iomap(dev->node, 0);
277 if (gef_wdt_regs == NULL)
278 return -ENOMEM;
279
280 gef_wdt_set_timeout(timeout);
281
282 gef_wdt_handler_disable(); /* in case timer was already running */
283
284 return misc_register(&gef_wdt_miscdev);
285}
286
287static int __devexit gef_wdt_remove(struct platform_device *dev)
288{
289 misc_deregister(&gef_wdt_miscdev);
290
291 gef_wdt_handler_disable();
292
293 iounmap(gef_wdt_regs);
294
295 return 0;
296}
297
298static const struct of_device_id gef_wdt_ids[] = {
299 {
300 .compatible = "gef,fpga-wdt",
301 },
302 {},
303};
304
305static struct of_platform_driver gef_wdt_driver = {
306 .owner = THIS_MODULE,
307 .name = "gef_wdt",
308 .match_table = gef_wdt_ids,
309 .probe = gef_wdt_probe,
310};
311
312static int __init gef_wdt_init(void)
313{
314 printk(KERN_INFO "GE Fanuc watchdog driver\n");
315 return of_register_platform_driver(&gef_wdt_driver);
316}
317
318static void __exit gef_wdt_exit(void)
319{
320 of_unregister_platform_driver(&gef_wdt_driver);
321}
322
323module_init(gef_wdt_init);
324module_exit(gef_wdt_exit);
325
326MODULE_AUTHOR("Martyn Welch <martyn.welch@gefanuc.com>");
327MODULE_DESCRIPTION("GE Fanuc watchdog driver");
328MODULE_LICENSE("GPL");
329MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
330MODULE_ALIAS("platform: gef_wdt");
diff --git a/drivers/watchdog/pika_wdt.c b/drivers/watchdog/pika_wdt.c
new file mode 100644
index 00000000000..2d22e996e99
--- /dev/null
+++ b/drivers/watchdog/pika_wdt.c
@@ -0,0 +1,301 @@
1/*
2 * PIKA FPGA based Watchdog Timer
3 *
4 * Copyright (c) 2008 PIKA Technologies
5 * Sean MacLennan <smaclennan@pikatech.com>
6 */
7
8#include <linux/init.h>
9#include <linux/errno.h>
10#include <linux/module.h>
11#include <linux/moduleparam.h>
12#include <linux/types.h>
13#include <linux/kernel.h>
14#include <linux/fs.h>
15#include <linux/miscdevice.h>
16#include <linux/watchdog.h>
17#include <linux/reboot.h>
18#include <linux/jiffies.h>
19#include <linux/timer.h>
20#include <linux/bitops.h>
21#include <linux/uaccess.h>
22#include <linux/io.h>
23#include <linux/of_platform.h>
24
25#define DRV_NAME "PIKA-WDT"
26#define PFX DRV_NAME ": "
27
28/* Hardware timeout in seconds */
29#define WDT_HW_TIMEOUT 2
30
31/* Timer heartbeat (500ms) */
32#define WDT_TIMEOUT (HZ/2)
33
34/* User land timeout */
35#define WDT_HEARTBEAT 15
36static int heartbeat = WDT_HEARTBEAT;
37module_param(heartbeat, int, 0);
38MODULE_PARM_DESC(heartbeat, "Watchdog heartbeats in seconds. "
39 "(default = " __MODULE_STRING(WDT_HEARTBEAT) ")");
40
41static int nowayout = WATCHDOG_NOWAYOUT;
42module_param(nowayout, int, 0);
43MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started "
44 "(default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
45
46static struct {
47 void __iomem *fpga;
48 unsigned long next_heartbeat; /* the next_heartbeat for the timer */
49 unsigned long open;
50 char expect_close;
51 int bootstatus;
52 struct timer_list timer; /* The timer that pings the watchdog */
53} pikawdt_private;
54
55static struct watchdog_info ident = {
56 .identity = DRV_NAME,
57 .options = WDIOF_CARDRESET |
58 WDIOF_SETTIMEOUT |
59 WDIOF_KEEPALIVEPING |
60 WDIOF_MAGICCLOSE,
61};
62
63/*
64 * Reload the watchdog timer. (ie, pat the watchdog)
65 */
66static inline void pikawdt_reset(void)
67{
68 /* -- FPGA: Reset Control Register (32bit R/W) (Offset: 0x14) --
69 * Bit 7, WTCHDG_EN: When set to 1, the watchdog timer is enabled.
70 * Once enabled, it cannot be disabled. The watchdog can be
71 * kicked by performing any write access to the reset
72 * control register (this register).
73 * Bit 8-11, WTCHDG_TIMEOUT_SEC: Sets the watchdog timeout value in
74 * seconds. Valid ranges are 1 to 15 seconds. The value can
75 * be modified dynamically.
76 */
77 unsigned reset = in_be32(pikawdt_private.fpga + 0x14);
78 /* enable with max timeout - 15 seconds */
79 reset |= (1 << 7) + (WDT_HW_TIMEOUT << 8);
80 out_be32(pikawdt_private.fpga + 0x14, reset);
81}
82
83/*
84 * Timer tick
85 */
86static void pikawdt_ping(unsigned long data)
87{
88 if (time_before(jiffies, pikawdt_private.next_heartbeat) ||
89 (!nowayout && !pikawdt_private.open)) {
90 pikawdt_reset();
91 mod_timer(&pikawdt_private.timer, jiffies + WDT_TIMEOUT);
92 } else
93 printk(KERN_CRIT PFX "I will reset your machine !\n");
94}
95
96
97static void pikawdt_keepalive(void)
98{
99 pikawdt_private.next_heartbeat = jiffies + heartbeat * HZ;
100}
101
102static void pikawdt_start(void)
103{
104 pikawdt_keepalive();
105 mod_timer(&pikawdt_private.timer, jiffies + WDT_TIMEOUT);
106}
107
108/*
109 * Watchdog device is opened, and watchdog starts running.
110 */
111static int pikawdt_open(struct inode *inode, struct file *file)
112{
113 /* /dev/watchdog can only be opened once */
114 if (test_and_set_bit(0, &pikawdt_private.open))
115 return -EBUSY;
116
117 pikawdt_start();
118
119 return nonseekable_open(inode, file);
120}
121
122/*
123 * Close the watchdog device.
124 */
125static int pikawdt_release(struct inode *inode, struct file *file)
126{
127 /* stop internal ping */
128 if (!pikawdt_private.expect_close)
129 del_timer(&pikawdt_private.timer);
130
131 clear_bit(0, &pikawdt_private.open);
132 pikawdt_private.expect_close = 0;
133 return 0;
134}
135
136/*
137 * Pat the watchdog whenever device is written to.
138 */
139static ssize_t pikawdt_write(struct file *file, const char __user *data,
140 size_t len, loff_t *ppos)
141{
142 if (!len)
143 return 0;
144
145 /* Scan for magic character */
146 if (!nowayout) {
147 size_t i;
148
149 pikawdt_private.expect_close = 0;
150
151 for (i = 0; i < len; i++) {
152 char c;
153 if (get_user(c, data + i))
154 return -EFAULT;
155 if (c == 'V') {
156 pikawdt_private.expect_close = 42;
157 break;
158 }
159 }
160 }
161
162 pikawdt_keepalive();
163
164 return len;
165}
166
167/*
168 * Handle commands from user-space.
169 */
170static long pikawdt_ioctl(struct file *file,
171 unsigned int cmd, unsigned long arg)
172{
173 void __user *argp = (void __user *)arg;
174 int __user *p = argp;
175 int new_value;
176
177 switch (cmd) {
178 case WDIOC_GETSUPPORT:
179 return copy_to_user(argp, &ident, sizeof(ident)) ? -EFAULT : 0;
180
181 case WDIOC_GETSTATUS:
182 return put_user(0, p);
183
184 case WDIOC_GETBOOTSTATUS:
185 return put_user(pikawdt_private.bootstatus, p);
186
187 case WDIOC_KEEPALIVE:
188 pikawdt_keepalive();
189 return 0;
190
191 case WDIOC_SETTIMEOUT:
192 if (get_user(new_value, p))
193 return -EFAULT;
194
195 heartbeat = new_value;
196 pikawdt_keepalive();
197
198 return put_user(new_value, p); /* return current value */
199
200 case WDIOC_GETTIMEOUT:
201 return put_user(heartbeat, p);
202 }
203 return -ENOTTY;
204}
205
206
207static const struct file_operations pikawdt_fops = {
208 .owner = THIS_MODULE,
209 .llseek = no_llseek,
210 .open = pikawdt_open,
211 .release = pikawdt_release,
212 .write = pikawdt_write,
213 .unlocked_ioctl = pikawdt_ioctl,
214};
215
216static struct miscdevice pikawdt_miscdev = {
217 .minor = WATCHDOG_MINOR,
218 .name = "watchdog",
219 .fops = &pikawdt_fops,
220};
221
222static int __init pikawdt_init(void)
223{
224 struct device_node *np;
225 void __iomem *fpga;
226 static u32 post1;
227 int ret;
228
229 np = of_find_compatible_node(NULL, NULL, "pika,fpga");
230 if (np == NULL) {
231 printk(KERN_ERR PFX "Unable to find fpga.\n");
232 return -ENOENT;
233 }
234
235 pikawdt_private.fpga = of_iomap(np, 0);
236 of_node_put(np);
237 if (pikawdt_private.fpga == NULL) {
238 printk(KERN_ERR PFX "Unable to map fpga.\n");
239 return -ENOMEM;
240 }
241
242 ident.firmware_version = in_be32(pikawdt_private.fpga + 0x1c) & 0xffff;
243
244 /* POST information is in the sd area. */
245 np = of_find_compatible_node(NULL, NULL, "pika,fpga-sd");
246 if (np == NULL) {
247 printk(KERN_ERR PFX "Unable to find fpga-sd.\n");
248 ret = -ENOENT;
249 goto out;
250 }
251
252 fpga = of_iomap(np, 0);
253 of_node_put(np);
254 if (fpga == NULL) {
255 printk(KERN_ERR PFX "Unable to map fpga-sd.\n");
256 ret = -ENOMEM;
257 goto out;
258 }
259
260 /* -- FPGA: POST Test Results Register 1 (32bit R/W) (Offset: 0x4040) --
261 * Bit 31, WDOG: Set to 1 when the last reset was caused by a watchdog
262 * timeout.
263 */
264 post1 = in_be32(fpga + 0x40);
265 if (post1 & 0x80000000)
266 pikawdt_private.bootstatus = WDIOF_CARDRESET;
267
268 iounmap(fpga);
269
270 setup_timer(&pikawdt_private.timer, pikawdt_ping, 0);
271
272 ret = misc_register(&pikawdt_miscdev);
273 if (ret) {
274 printk(KERN_ERR PFX "Unable to register miscdev.\n");
275 goto out;
276 }
277
278 printk(KERN_INFO PFX "initialized. heartbeat=%d sec (nowayout=%d)\n",
279 heartbeat, nowayout);
280 return 0;
281
282out:
283 iounmap(pikawdt_private.fpga);
284 return ret;
285}
286
287static void __exit pikawdt_exit(void)
288{
289 misc_deregister(&pikawdt_miscdev);
290
291 iounmap(pikawdt_private.fpga);
292}
293
294module_init(pikawdt_init);
295module_exit(pikawdt_exit);
296
297MODULE_AUTHOR("Sean MacLennan <smaclennan@pikatech.com>");
298MODULE_DESCRIPTION("PIKA FPGA based Watchdog Timer");
299MODULE_LICENSE("GPL");
300MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
301
diff --git a/drivers/watchdog/wm8350_wdt.c b/drivers/watchdog/wm8350_wdt.c
index 2bc0d4d4b41..a2d2e8eb228 100644
--- a/drivers/watchdog/wm8350_wdt.c
+++ b/drivers/watchdog/wm8350_wdt.c
@@ -279,7 +279,7 @@ static struct miscdevice wm8350_wdt_miscdev = {
279 .fops = &wm8350_wdt_fops, 279 .fops = &wm8350_wdt_fops,
280}; 280};
281 281
282static int wm8350_wdt_probe(struct platform_device *pdev) 282static int __devinit wm8350_wdt_probe(struct platform_device *pdev)
283{ 283{
284 struct wm8350 *wm8350 = platform_get_drvdata(pdev); 284 struct wm8350 *wm8350 = platform_get_drvdata(pdev);
285 285
@@ -296,7 +296,7 @@ static int wm8350_wdt_probe(struct platform_device *pdev)
296 return misc_register(&wm8350_wdt_miscdev); 296 return misc_register(&wm8350_wdt_miscdev);
297} 297}
298 298
299static int __exit wm8350_wdt_remove(struct platform_device *pdev) 299static int __devexit wm8350_wdt_remove(struct platform_device *pdev)
300{ 300{
301 misc_deregister(&wm8350_wdt_miscdev); 301 misc_deregister(&wm8350_wdt_miscdev);
302 302
@@ -305,7 +305,7 @@ static int __exit wm8350_wdt_remove(struct platform_device *pdev)
305 305
306static struct platform_driver wm8350_wdt_driver = { 306static struct platform_driver wm8350_wdt_driver = {
307 .probe = wm8350_wdt_probe, 307 .probe = wm8350_wdt_probe,
308 .remove = wm8350_wdt_remove, 308 .remove = __devexit_p(wm8350_wdt_remove),
309 .driver = { 309 .driver = {
310 .name = "wm8350-wdt", 310 .name = "wm8350-wdt",
311 }, 311 },
diff --git a/drivers/xen/events.c b/drivers/xen/events.c
index eb0dfdeaa94..3141e149d59 100644
--- a/drivers/xen/events.c
+++ b/drivers/xen/events.c
@@ -26,6 +26,7 @@
26#include <linux/irq.h> 26#include <linux/irq.h>
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/string.h> 28#include <linux/string.h>
29#include <linux/bootmem.h>
29 30
30#include <asm/ptrace.h> 31#include <asm/ptrace.h>
31#include <asm/irq.h> 32#include <asm/irq.h>
@@ -75,7 +76,14 @@ enum {
75static int evtchn_to_irq[NR_EVENT_CHANNELS] = { 76static int evtchn_to_irq[NR_EVENT_CHANNELS] = {
76 [0 ... NR_EVENT_CHANNELS-1] = -1 77 [0 ... NR_EVENT_CHANNELS-1] = -1
77}; 78};
78static unsigned long cpu_evtchn_mask[NR_CPUS][NR_EVENT_CHANNELS/BITS_PER_LONG]; 79struct cpu_evtchn_s {
80 unsigned long bits[NR_EVENT_CHANNELS/BITS_PER_LONG];
81};
82static struct cpu_evtchn_s *cpu_evtchn_mask_p;
83static inline unsigned long *cpu_evtchn_mask(int cpu)
84{
85 return cpu_evtchn_mask_p[cpu].bits;
86}
79static u8 cpu_evtchn[NR_EVENT_CHANNELS]; 87static u8 cpu_evtchn[NR_EVENT_CHANNELS];
80 88
81/* Reference counts for bindings to IRQs. */ 89/* Reference counts for bindings to IRQs. */
@@ -115,7 +123,7 @@ static inline unsigned long active_evtchns(unsigned int cpu,
115 unsigned int idx) 123 unsigned int idx)
116{ 124{
117 return (sh->evtchn_pending[idx] & 125 return (sh->evtchn_pending[idx] &
118 cpu_evtchn_mask[cpu][idx] & 126 cpu_evtchn_mask(cpu)[idx] &
119 ~sh->evtchn_mask[idx]); 127 ~sh->evtchn_mask[idx]);
120} 128}
121 129
@@ -125,11 +133,11 @@ static void bind_evtchn_to_cpu(unsigned int chn, unsigned int cpu)
125 133
126 BUG_ON(irq == -1); 134 BUG_ON(irq == -1);
127#ifdef CONFIG_SMP 135#ifdef CONFIG_SMP
128 irq_to_desc(irq)->affinity = cpumask_of_cpu(cpu); 136 cpumask_copy(irq_to_desc(irq)->affinity, cpumask_of(cpu));
129#endif 137#endif
130 138
131 __clear_bit(chn, cpu_evtchn_mask[cpu_evtchn[chn]]); 139 __clear_bit(chn, cpu_evtchn_mask(cpu_evtchn[chn]));
132 __set_bit(chn, cpu_evtchn_mask[cpu]); 140 __set_bit(chn, cpu_evtchn_mask(cpu));
133 141
134 cpu_evtchn[chn] = cpu; 142 cpu_evtchn[chn] = cpu;
135} 143}
@@ -142,12 +150,12 @@ static void init_evtchn_cpu_bindings(void)
142 150
143 /* By default all event channels notify CPU#0. */ 151 /* By default all event channels notify CPU#0. */
144 for_each_irq_desc(i, desc) { 152 for_each_irq_desc(i, desc) {
145 desc->affinity = cpumask_of_cpu(0); 153 cpumask_copy(desc->affinity, cpumask_of(0));
146 } 154 }
147#endif 155#endif
148 156
149 memset(cpu_evtchn, 0, sizeof(cpu_evtchn)); 157 memset(cpu_evtchn, 0, sizeof(cpu_evtchn));
150 memset(cpu_evtchn_mask[0], ~0, sizeof(cpu_evtchn_mask[0])); 158 memset(cpu_evtchn_mask(0), ~0, sizeof(cpu_evtchn_mask(0)));
151} 159}
152 160
153static inline unsigned int cpu_from_evtchn(unsigned int evtchn) 161static inline unsigned int cpu_from_evtchn(unsigned int evtchn)
@@ -822,6 +830,10 @@ static struct irq_chip xen_dynamic_chip __read_mostly = {
822void __init xen_init_IRQ(void) 830void __init xen_init_IRQ(void)
823{ 831{
824 int i; 832 int i;
833 size_t size = nr_cpu_ids * sizeof(struct cpu_evtchn_s);
834
835 cpu_evtchn_mask_p = alloc_bootmem(size);
836 BUG_ON(cpu_evtchn_mask_p == NULL);
825 837
826 init_evtchn_cpu_bindings(); 838 init_evtchn_cpu_bindings();
827 839
diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c
index 9b91617b958..e7e83b65c18 100644
--- a/drivers/xen/manage.c
+++ b/drivers/xen/manage.c
@@ -100,7 +100,7 @@ static void do_suspend(void)
100 /* XXX use normal device tree? */ 100 /* XXX use normal device tree? */
101 xenbus_suspend(); 101 xenbus_suspend();
102 102
103 err = stop_machine(xen_suspend, &cancelled, &cpumask_of_cpu(0)); 103 err = stop_machine(xen_suspend, &cancelled, cpumask_of(0));
104 if (err) { 104 if (err) {
105 printk(KERN_ERR "failed to start xen_suspend: %d\n", err); 105 printk(KERN_ERR "failed to start xen_suspend: %d\n", err);
106 goto out; 106 goto out;
diff --git a/drivers/zorro/.gitignore b/drivers/zorro/.gitignore
new file mode 100644
index 00000000000..34f980bd8ff
--- /dev/null
+++ b/drivers/zorro/.gitignore
@@ -0,0 +1,2 @@
1devlist.h
2gen-devlist
diff --git a/drivers/zorro/zorro-sysfs.c b/drivers/zorro/zorro-sysfs.c
index 5290552d2ef..1d2a772ea14 100644
--- a/drivers/zorro/zorro-sysfs.c
+++ b/drivers/zorro/zorro-sysfs.c
@@ -77,17 +77,21 @@ static struct bin_attribute zorro_config_attr = {
77 .read = zorro_read_config, 77 .read = zorro_read_config,
78}; 78};
79 79
80void zorro_create_sysfs_dev_files(struct zorro_dev *z) 80int zorro_create_sysfs_dev_files(struct zorro_dev *z)
81{ 81{
82 struct device *dev = &z->dev; 82 struct device *dev = &z->dev;
83 int error;
83 84
84 /* current configuration's attributes */ 85 /* current configuration's attributes */
85 device_create_file(dev, &dev_attr_id); 86 if ((error = device_create_file(dev, &dev_attr_id)) ||
86 device_create_file(dev, &dev_attr_type); 87 (error = device_create_file(dev, &dev_attr_type)) ||
87 device_create_file(dev, &dev_attr_serial); 88 (error = device_create_file(dev, &dev_attr_serial)) ||
88 device_create_file(dev, &dev_attr_slotaddr); 89 (error = device_create_file(dev, &dev_attr_slotaddr)) ||
89 device_create_file(dev, &dev_attr_slotsize); 90 (error = device_create_file(dev, &dev_attr_slotsize)) ||
90 device_create_file(dev, &dev_attr_resource); 91 (error = device_create_file(dev, &dev_attr_resource)) ||
91 sysfs_create_bin_file(&dev->kobj, &zorro_config_attr); 92 (error = sysfs_create_bin_file(&dev->kobj, &zorro_config_attr)))
93 return error;
94
95 return 0;
92} 96}
93 97
diff --git a/drivers/zorro/zorro.c b/drivers/zorro/zorro.c
index dff16d9767d..a1585d6f648 100644
--- a/drivers/zorro/zorro.c
+++ b/drivers/zorro/zorro.c
@@ -130,6 +130,7 @@ static int __init zorro_init(void)
130{ 130{
131 struct zorro_dev *z; 131 struct zorro_dev *z;
132 unsigned int i; 132 unsigned int i;
133 int error;
133 134
134 if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(ZORRO)) 135 if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(ZORRO))
135 return 0; 136 return 0;
@@ -140,7 +141,11 @@ static int __init zorro_init(void)
140 /* Initialize the Zorro bus */ 141 /* Initialize the Zorro bus */
141 INIT_LIST_HEAD(&zorro_bus.devices); 142 INIT_LIST_HEAD(&zorro_bus.devices);
142 strcpy(zorro_bus.dev.bus_id, "zorro"); 143 strcpy(zorro_bus.dev.bus_id, "zorro");
143 device_register(&zorro_bus.dev); 144 error = device_register(&zorro_bus.dev);
145 if (error) {
146 pr_err("Zorro: Error registering zorro_bus\n");
147 return error;
148 }
144 149
145 /* Request the resources */ 150 /* Request the resources */
146 zorro_bus.num_resources = AMIGAHW_PRESENT(ZORRO3) ? 4 : 2; 151 zorro_bus.num_resources = AMIGAHW_PRESENT(ZORRO3) ? 4 : 2;
@@ -160,15 +165,19 @@ static int __init zorro_init(void)
160 zorro_name_device(z); 165 zorro_name_device(z);
161 z->resource.name = z->name; 166 z->resource.name = z->name;
162 if (request_resource(zorro_find_parent_resource(z), &z->resource)) 167 if (request_resource(zorro_find_parent_resource(z), &z->resource))
163 printk(KERN_ERR "Zorro: Address space collision on device %s " 168 pr_err("Zorro: Address space collision on device %s %pR\n",
164 "[%lx:%lx]\n", 169 z->name, &z->resource);
165 z->name, (unsigned long)zorro_resource_start(z),
166 (unsigned long)zorro_resource_end(z));
167 sprintf(z->dev.bus_id, "%02x", i); 170 sprintf(z->dev.bus_id, "%02x", i);
168 z->dev.parent = &zorro_bus.dev; 171 z->dev.parent = &zorro_bus.dev;
169 z->dev.bus = &zorro_bus_type; 172 z->dev.bus = &zorro_bus_type;
170 device_register(&z->dev); 173 error = device_register(&z->dev);
171 zorro_create_sysfs_dev_files(z); 174 if (error) {
175 pr_err("Zorro: Error registering device %s\n", z->name);
176 continue;
177 }
178 error = zorro_create_sysfs_dev_files(z);
179 if (error)
180 dev_err(&z->dev, "Error creating sysfs files\n");
172 } 181 }
173 182
174 /* Mark all available Zorro II memory */ 183 /* Mark all available Zorro II memory */
diff --git a/drivers/zorro/zorro.h b/drivers/zorro/zorro.h
index 5c91adac4df..b682d5ccd63 100644
--- a/drivers/zorro/zorro.h
+++ b/drivers/zorro/zorro.h
@@ -1,4 +1,4 @@
1 1
2extern void zorro_name_device(struct zorro_dev *z); 2extern void zorro_name_device(struct zorro_dev *z);
3extern void zorro_create_sysfs_dev_files(struct zorro_dev *z); 3extern int zorro_create_sysfs_dev_files(struct zorro_dev *z);
4 4