aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/Makefile2
-rw-r--r--drivers/block/cciss.c5
-rw-r--r--drivers/hwmon/Kconfig10
-rw-r--r--drivers/hwmon/Makefile1
-rw-r--r--drivers/hwmon/f71805f.c908
-rw-r--r--drivers/hwmon/it87.c8
-rw-r--r--drivers/hwmon/lm77.c8
-rw-r--r--drivers/hwmon/w83792d.c31
-rw-r--r--drivers/i2c/algos/i2c-algo-sibyte.c2
-rw-r--r--drivers/i2c/busses/Kconfig1
-rw-r--r--drivers/i2c/busses/i2c-i801.c2
-rw-r--r--drivers/i2c/busses/i2c-parport-light.c9
-rw-r--r--drivers/i2c/busses/i2c-parport.c7
-rw-r--r--drivers/i2c/busses/i2c-pxa.c2
-rw-r--r--drivers/i2c/i2c-core.c15
-rw-r--r--drivers/ide/ide-disk.c6
-rw-r--r--drivers/media/dvb/b2c2/Kconfig2
-rw-r--r--drivers/media/dvb/b2c2/flexcop-common.h2
-rw-r--r--drivers/media/dvb/b2c2/flexcop-dma.c35
-rw-r--r--drivers/media/dvb/b2c2/flexcop-fe-tuner.c9
-rw-r--r--drivers/media/dvb/b2c2/flexcop-misc.c6
-rw-r--r--drivers/media/dvb/b2c2/flexcop-pci.c6
-rw-r--r--drivers/media/dvb/b2c2/flexcop-reg.h4
-rw-r--r--drivers/media/dvb/bt8xx/bt878.c44
-rw-r--r--drivers/media/dvb/bt8xx/bt878.h17
-rw-r--r--drivers/media/dvb/dvb-usb/Kconfig12
-rw-r--r--drivers/media/dvb/dvb-usb/cxusb.c12
-rw-r--r--drivers/media/dvb/dvb-usb/digitv.c13
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-firmware.c8
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb.h1
-rw-r--r--drivers/media/dvb/dvb-usb/vp702x.c6
-rw-r--r--drivers/media/dvb/dvb-usb/vp702x.h2
-rw-r--r--drivers/media/dvb/dvb-usb/vp7045-fe.c6
-rw-r--r--drivers/media/dvb/frontends/Kconfig24
-rw-r--r--drivers/media/dvb/frontends/Makefile3
-rw-r--r--drivers/media/dvb/frontends/at76c651.c450
-rw-r--r--drivers/media/dvb/frontends/at76c651.h47
-rw-r--r--drivers/media/dvb/frontends/dvb-pll.c8
-rw-r--r--drivers/media/dvb/frontends/dvb-pll.h2
-rw-r--r--drivers/media/dvb/frontends/nxt2002.c706
-rw-r--r--drivers/media/dvb/frontends/nxt2002.h23
-rw-r--r--drivers/media/dvb/frontends/nxt200x.c58
-rw-r--r--drivers/media/dvb/frontends/tda80xx.c734
-rw-r--r--drivers/media/dvb/frontends/tda80xx.h51
-rw-r--r--drivers/media/dvb/ttpci/av7110.c14
-rw-r--r--drivers/media/dvb/ttpci/av7110.h2
-rw-r--r--drivers/media/dvb/ttpci/av7110_ir.c26
-rw-r--r--drivers/media/video/bttv-driver.c2
-rw-r--r--drivers/media/video/cx25840/cx25840-core.c50
-rw-r--r--drivers/media/video/cx88/Kconfig12
-rw-r--r--drivers/media/video/cx88/Makefile5
-rw-r--r--drivers/media/video/cx88/cx88-alsa.c6
-rw-r--r--drivers/media/video/cx88/cx88-cards.c6
-rw-r--r--drivers/media/video/cx88/cx88-core.c10
-rw-r--r--drivers/media/video/cx88/cx88-input.c1
-rw-r--r--drivers/media/video/em28xx/em28xx-core.c17
-rw-r--r--drivers/media/video/em28xx/em28xx-i2c.c8
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c3
-rw-r--r--drivers/media/video/saa7134/saa7134-cards.c47
-rw-r--r--drivers/media/video/saa7134/saa7134-dvb.c2
-rw-r--r--drivers/media/video/saa7134/saa7134.h2
-rw-r--r--drivers/media/video/stradis.c15
-rw-r--r--drivers/media/video/tda9887.c9
-rw-r--r--drivers/media/video/tuner-core.c8
-rw-r--r--drivers/media/video/tvaudio.c9
-rw-r--r--drivers/media/video/tvp5150.c32
-rw-r--r--drivers/net/8139too.c38
-rw-r--r--drivers/net/Kconfig7
-rw-r--r--drivers/net/bonding/bond_main.c15
-rw-r--r--drivers/net/bonding/bond_sysfs.c6
-rw-r--r--drivers/net/e100.c2
-rw-r--r--drivers/net/gianfar.c24
-rw-r--r--drivers/net/gianfar.h8
-rw-r--r--drivers/net/gianfar_ethtool.c8
-rw-r--r--drivers/net/gianfar_mii.c17
-rw-r--r--drivers/net/r8169.c13
-rw-r--r--drivers/net/sis900.h1
-rw-r--r--drivers/net/sky2.c186
-rw-r--r--drivers/net/sky2.h9
-rw-r--r--drivers/net/tulip/uli526x.c2
-rw-r--r--drivers/net/wan/dscc4.c2
-rw-r--r--drivers/serial/68328serial.c4
-rw-r--r--drivers/serial/68360serial.c4
-rw-r--r--drivers/serial/mcfserial.c16
84 files changed, 1547 insertions, 2409 deletions
diff --git a/drivers/Makefile b/drivers/Makefile
index 619dd964c51c..5c69b86db624 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -69,7 +69,7 @@ obj-$(CONFIG_EISA) += eisa/
69obj-$(CONFIG_CPU_FREQ) += cpufreq/ 69obj-$(CONFIG_CPU_FREQ) += cpufreq/
70obj-$(CONFIG_MMC) += mmc/ 70obj-$(CONFIG_MMC) += mmc/
71obj-$(CONFIG_INFINIBAND) += infiniband/ 71obj-$(CONFIG_INFINIBAND) += infiniband/
72obj-$(CONFIG_SGI_IOC4) += sn/ 72obj-$(CONFIG_SGI_SN) += sn/
73obj-y += firmware/ 73obj-y += firmware/
74obj-$(CONFIG_CRYPTO) += crypto/ 74obj-$(CONFIG_CRYPTO) += crypto/
75obj-$(CONFIG_SUPERH) += sh/ 75obj-$(CONFIG_SUPERH) += sh/
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 12d7b9bdfa93..0d65394707db 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -2183,6 +2183,7 @@ static void cciss_softirq_done(struct request *rq)
2183{ 2183{
2184 CommandList_struct *cmd = rq->completion_data; 2184 CommandList_struct *cmd = rq->completion_data;
2185 ctlr_info_t *h = hba[cmd->ctlr]; 2185 ctlr_info_t *h = hba[cmd->ctlr];
2186 unsigned long flags;
2186 u64bit temp64; 2187 u64bit temp64;
2187 int i, ddir; 2188 int i, ddir;
2188 2189
@@ -2205,10 +2206,10 @@ static void cciss_softirq_done(struct request *rq)
2205 printk("Done with %p\n", rq); 2206 printk("Done with %p\n", rq);
2206#endif /* CCISS_DEBUG */ 2207#endif /* CCISS_DEBUG */
2207 2208
2208 spin_lock_irq(&h->lock); 2209 spin_lock_irqsave(&h->lock, flags);
2209 end_that_request_last(rq, rq->errors); 2210 end_that_request_last(rq, rq->errors);
2210 cmd_free(h, cmd,1); 2211 cmd_free(h, cmd,1);
2211 spin_unlock_irq(&h->lock); 2212 spin_unlock_irqrestore(&h->lock, flags);
2212} 2213}
2213 2214
2214/* checks the status of the job and calls complete buffers to mark all 2215/* checks the status of the job and calls complete buffers to mark all
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index c58295914365..7230d4e08196 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -113,6 +113,16 @@ config SENSORS_DS1621
113 This driver can also be built as a module. If so, the module 113 This driver can also be built as a module. If so, the module
114 will be called ds1621. 114 will be called ds1621.
115 115
116config SENSORS_F71805F
117 tristate "Fintek F71805F/FG"
118 depends on HWMON && EXPERIMENTAL
119 help
120 If you say yes here you get support for hardware monitoring
121 features of the Fintek F71805F/FG chips.
122
123 This driver can also be built as a module. If so, the module
124 will be called f71805f.
125
116config SENSORS_FSCHER 126config SENSORS_FSCHER
117 tristate "FSC Hermes" 127 tristate "FSC Hermes"
118 depends on HWMON && I2C && EXPERIMENTAL 128 depends on HWMON && I2C && EXPERIMENTAL
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
index 06d4a1d14105..fbdb8d911a72 100644
--- a/drivers/hwmon/Makefile
+++ b/drivers/hwmon/Makefile
@@ -18,6 +18,7 @@ obj-$(CONFIG_SENSORS_ADM1031) += adm1031.o
18obj-$(CONFIG_SENSORS_ADM9240) += adm9240.o 18obj-$(CONFIG_SENSORS_ADM9240) += adm9240.o
19obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o 19obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o
20obj-$(CONFIG_SENSORS_DS1621) += ds1621.o 20obj-$(CONFIG_SENSORS_DS1621) += ds1621.o
21obj-$(CONFIG_SENSORS_F71805F) += f71805f.o
21obj-$(CONFIG_SENSORS_FSCHER) += fscher.o 22obj-$(CONFIG_SENSORS_FSCHER) += fscher.o
22obj-$(CONFIG_SENSORS_FSCPOS) += fscpos.o 23obj-$(CONFIG_SENSORS_FSCPOS) += fscpos.o
23obj-$(CONFIG_SENSORS_GL518SM) += gl518sm.o 24obj-$(CONFIG_SENSORS_GL518SM) += gl518sm.o
diff --git a/drivers/hwmon/f71805f.c b/drivers/hwmon/f71805f.c
new file mode 100644
index 000000000000..e029e0a94ecc
--- /dev/null
+++ b/drivers/hwmon/f71805f.c
@@ -0,0 +1,908 @@
1/*
2 * f71805f.c - driver for the Fintek F71805F/FG Super-I/O chip integrated
3 * hardware monitoring features
4 * Copyright (C) 2005 Jean Delvare <khali@linux-fr.org>
5 *
6 * The F71805F/FG is a LPC Super-I/O chip made by Fintek. It integrates
7 * complete hardware monitoring features: voltage, fan and temperature
8 * sensors, and manual and automatic fan speed control.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 */
24
25#include <linux/module.h>
26#include <linux/init.h>
27#include <linux/slab.h>
28#include <linux/jiffies.h>
29#include <linux/platform_device.h>
30#include <linux/hwmon.h>
31#include <linux/hwmon-sysfs.h>
32#include <linux/err.h>
33#include <asm/io.h>
34
35static struct platform_device *pdev;
36
37#define DRVNAME "f71805f"
38
39/*
40 * Super-I/O constants and functions
41 */
42
43#define F71805F_LD_HWM 0x04
44
45#define SIO_REG_LDSEL 0x07 /* Logical device select */
46#define SIO_REG_DEVID 0x20 /* Device ID (2 bytes) */
47#define SIO_REG_DEVREV 0x22 /* Device revision */
48#define SIO_REG_MANID 0x23 /* Fintek ID (2 bytes) */
49#define SIO_REG_ENABLE 0x30 /* Logical device enable */
50#define SIO_REG_ADDR 0x60 /* Logical device address (2 bytes) */
51
52#define SIO_FINTEK_ID 0x1934
53#define SIO_F71805F_ID 0x0406
54
55static inline int
56superio_inb(int base, int reg)
57{
58 outb(reg, base);
59 return inb(base + 1);
60}
61
62static int
63superio_inw(int base, int reg)
64{
65 int val;
66 outb(reg++, base);
67 val = inb(base + 1) << 8;
68 outb(reg, base);
69 val |= inb(base + 1);
70 return val;
71}
72
73static inline void
74superio_select(int base, int ld)
75{
76 outb(SIO_REG_LDSEL, base);
77 outb(ld, base + 1);
78}
79
80static inline void
81superio_enter(int base)
82{
83 outb(0x87, base);
84 outb(0x87, base);
85}
86
87static inline void
88superio_exit(int base)
89{
90 outb(0xaa, base);
91}
92
93/*
94 * ISA constants
95 */
96
97#define REGION_LENGTH 2
98#define ADDR_REG_OFFSET 0
99#define DATA_REG_OFFSET 1
100
101static struct resource f71805f_resource __initdata = {
102 .flags = IORESOURCE_IO,
103};
104
105/*
106 * Registers
107 */
108
109/* in nr from 0 to 8 (8-bit values) */
110#define F71805F_REG_IN(nr) (0x10 + (nr))
111#define F71805F_REG_IN_HIGH(nr) (0x40 + 2 * (nr))
112#define F71805F_REG_IN_LOW(nr) (0x41 + 2 * (nr))
113/* fan nr from 0 to 2 (12-bit values, two registers) */
114#define F71805F_REG_FAN(nr) (0x20 + 2 * (nr))
115#define F71805F_REG_FAN_LOW(nr) (0x28 + 2 * (nr))
116#define F71805F_REG_FAN_CTRL(nr) (0x60 + 16 * (nr))
117/* temp nr from 0 to 2 (8-bit values) */
118#define F71805F_REG_TEMP(nr) (0x1B + (nr))
119#define F71805F_REG_TEMP_HIGH(nr) (0x54 + 2 * (nr))
120#define F71805F_REG_TEMP_HYST(nr) (0x55 + 2 * (nr))
121#define F71805F_REG_TEMP_MODE 0x01
122
123#define F71805F_REG_START 0x00
124/* status nr from 0 to 2 */
125#define F71805F_REG_STATUS(nr) (0x36 + (nr))
126
127/*
128 * Data structures and manipulation thereof
129 */
130
131struct f71805f_data {
132 unsigned short addr;
133 const char *name;
134 struct semaphore lock;
135 struct class_device *class_dev;
136
137 struct semaphore update_lock;
138 char valid; /* !=0 if following fields are valid */
139 unsigned long last_updated; /* In jiffies */
140 unsigned long last_limits; /* In jiffies */
141
142 /* Register values */
143 u8 in[9];
144 u8 in_high[9];
145 u8 in_low[9];
146 u16 fan[3];
147 u16 fan_low[3];
148 u8 fan_enabled; /* Read once at init time */
149 u8 temp[3];
150 u8 temp_high[3];
151 u8 temp_hyst[3];
152 u8 temp_mode;
153 u8 alarms[3];
154};
155
156static inline long in_from_reg(u8 reg)
157{
158 return (reg * 8);
159}
160
161/* The 2 least significant bits are not used */
162static inline u8 in_to_reg(long val)
163{
164 if (val <= 0)
165 return 0;
166 if (val >= 2016)
167 return 0xfc;
168 return (((val + 16) / 32) << 2);
169}
170
171/* in0 is downscaled by a factor 2 internally */
172static inline long in0_from_reg(u8 reg)
173{
174 return (reg * 16);
175}
176
177static inline u8 in0_to_reg(long val)
178{
179 if (val <= 0)
180 return 0;
181 if (val >= 4032)
182 return 0xfc;
183 return (((val + 32) / 64) << 2);
184}
185
186/* The 4 most significant bits are not used */
187static inline long fan_from_reg(u16 reg)
188{
189 reg &= 0xfff;
190 if (!reg || reg == 0xfff)
191 return 0;
192 return (1500000 / reg);
193}
194
195static inline u16 fan_to_reg(long rpm)
196{
197 /* If the low limit is set below what the chip can measure,
198 store the largest possible 12-bit value in the registers,
199 so that no alarm will ever trigger. */
200 if (rpm < 367)
201 return 0xfff;
202 return (1500000 / rpm);
203}
204
205static inline long temp_from_reg(u8 reg)
206{
207 return (reg * 1000);
208}
209
210static inline u8 temp_to_reg(long val)
211{
212 if (val < 0)
213 val = 0;
214 else if (val > 1000 * 0xff)
215 val = 0xff;
216 return ((val + 500) / 1000);
217}
218
219/*
220 * Device I/O access
221 */
222
223static u8 f71805f_read8(struct f71805f_data *data, u8 reg)
224{
225 u8 val;
226
227 down(&data->lock);
228 outb(reg, data->addr + ADDR_REG_OFFSET);
229 val = inb(data->addr + DATA_REG_OFFSET);
230 up(&data->lock);
231
232 return val;
233}
234
235static void f71805f_write8(struct f71805f_data *data, u8 reg, u8 val)
236{
237 down(&data->lock);
238 outb(reg, data->addr + ADDR_REG_OFFSET);
239 outb(val, data->addr + DATA_REG_OFFSET);
240 up(&data->lock);
241}
242
243/* It is important to read the MSB first, because doing so latches the
244 value of the LSB, so we are sure both bytes belong to the same value. */
245static u16 f71805f_read16(struct f71805f_data *data, u8 reg)
246{
247 u16 val;
248
249 down(&data->lock);
250 outb(reg, data->addr + ADDR_REG_OFFSET);
251 val = inb(data->addr + DATA_REG_OFFSET) << 8;
252 outb(++reg, data->addr + ADDR_REG_OFFSET);
253 val |= inb(data->addr + DATA_REG_OFFSET);
254 up(&data->lock);
255
256 return val;
257}
258
259static void f71805f_write16(struct f71805f_data *data, u8 reg, u16 val)
260{
261 down(&data->lock);
262 outb(reg, data->addr + ADDR_REG_OFFSET);
263 outb(val >> 8, data->addr + DATA_REG_OFFSET);
264 outb(++reg, data->addr + ADDR_REG_OFFSET);
265 outb(val & 0xff, data->addr + DATA_REG_OFFSET);
266 up(&data->lock);
267}
268
269static struct f71805f_data *f71805f_update_device(struct device *dev)
270{
271 struct f71805f_data *data = dev_get_drvdata(dev);
272 int nr;
273
274 down(&data->update_lock);
275
276 /* Limit registers cache is refreshed after 60 seconds */
277 if (time_after(jiffies, data->last_updated + 60 * HZ)
278 || !data->valid) {
279 for (nr = 0; nr < 9; nr++) {
280 data->in_high[nr] = f71805f_read8(data,
281 F71805F_REG_IN_HIGH(nr));
282 data->in_low[nr] = f71805f_read8(data,
283 F71805F_REG_IN_LOW(nr));
284 }
285 for (nr = 0; nr < 3; nr++) {
286 if (data->fan_enabled & (1 << nr))
287 data->fan_low[nr] = f71805f_read16(data,
288 F71805F_REG_FAN_LOW(nr));
289 }
290 for (nr = 0; nr < 3; nr++) {
291 data->temp_high[nr] = f71805f_read8(data,
292 F71805F_REG_TEMP_HIGH(nr));
293 data->temp_hyst[nr] = f71805f_read8(data,
294 F71805F_REG_TEMP_HYST(nr));
295 }
296 data->temp_mode = f71805f_read8(data, F71805F_REG_TEMP_MODE);
297
298 data->last_limits = jiffies;
299 }
300
301 /* Measurement registers cache is refreshed after 1 second */
302 if (time_after(jiffies, data->last_updated + HZ)
303 || !data->valid) {
304 for (nr = 0; nr < 9; nr++) {
305 data->in[nr] = f71805f_read8(data,
306 F71805F_REG_IN(nr));
307 }
308 for (nr = 0; nr < 3; nr++) {
309 if (data->fan_enabled & (1 << nr))
310 data->fan[nr] = f71805f_read16(data,
311 F71805F_REG_FAN(nr));
312 }
313 for (nr = 0; nr < 3; nr++) {
314 data->temp[nr] = f71805f_read8(data,
315 F71805F_REG_TEMP(nr));
316 }
317 for (nr = 0; nr < 3; nr++) {
318 data->alarms[nr] = f71805f_read8(data,
319 F71805F_REG_STATUS(nr));
320 }
321
322 data->last_updated = jiffies;
323 data->valid = 1;
324 }
325
326 up(&data->update_lock);
327
328 return data;
329}
330
331/*
332 * Sysfs interface
333 */
334
335static ssize_t show_in0(struct device *dev, struct device_attribute *devattr,
336 char *buf)
337{
338 struct f71805f_data *data = f71805f_update_device(dev);
339
340 return sprintf(buf, "%ld\n", in0_from_reg(data->in[0]));
341}
342
343static ssize_t show_in0_max(struct device *dev, struct device_attribute
344 *devattr, char *buf)
345{
346 struct f71805f_data *data = f71805f_update_device(dev);
347
348 return sprintf(buf, "%ld\n", in0_from_reg(data->in_high[0]));
349}
350
351static ssize_t show_in0_min(struct device *dev, struct device_attribute
352 *devattr, char *buf)
353{
354 struct f71805f_data *data = f71805f_update_device(dev);
355
356 return sprintf(buf, "%ld\n", in0_from_reg(data->in_low[0]));
357}
358
359static ssize_t set_in0_max(struct device *dev, struct device_attribute
360 *devattr, const char *buf, size_t count)
361{
362 struct f71805f_data *data = dev_get_drvdata(dev);
363 long val = simple_strtol(buf, NULL, 10);
364
365 down(&data->update_lock);
366 data->in_high[0] = in0_to_reg(val);
367 f71805f_write8(data, F71805F_REG_IN_HIGH(0), data->in_high[0]);
368 up(&data->update_lock);
369
370 return count;
371}
372
373static ssize_t set_in0_min(struct device *dev, struct device_attribute
374 *devattr, const char *buf, size_t count)
375{
376 struct f71805f_data *data = dev_get_drvdata(dev);
377 long val = simple_strtol(buf, NULL, 10);
378
379 down(&data->update_lock);
380 data->in_low[0] = in0_to_reg(val);
381 f71805f_write8(data, F71805F_REG_IN_LOW(0), data->in_low[0]);
382 up(&data->update_lock);
383
384 return count;
385}
386
387static DEVICE_ATTR(in0_input, S_IRUGO, show_in0, NULL);
388static DEVICE_ATTR(in0_max, S_IRUGO| S_IWUSR, show_in0_max, set_in0_max);
389static DEVICE_ATTR(in0_min, S_IRUGO| S_IWUSR, show_in0_min, set_in0_min);
390
391static ssize_t show_in(struct device *dev, struct device_attribute *devattr,
392 char *buf)
393{
394 struct f71805f_data *data = f71805f_update_device(dev);
395 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
396 int nr = attr->index;
397
398 return sprintf(buf, "%ld\n", in_from_reg(data->in[nr]));
399}
400
401static ssize_t show_in_max(struct device *dev, struct device_attribute
402 *devattr, char *buf)
403{
404 struct f71805f_data *data = f71805f_update_device(dev);
405 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
406 int nr = attr->index;
407
408 return sprintf(buf, "%ld\n", in_from_reg(data->in_high[nr]));
409}
410
411static ssize_t show_in_min(struct device *dev, struct device_attribute
412 *devattr, char *buf)
413{
414 struct f71805f_data *data = f71805f_update_device(dev);
415 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
416 int nr = attr->index;
417
418 return sprintf(buf, "%ld\n", in_from_reg(data->in_low[nr]));
419}
420
421static ssize_t set_in_max(struct device *dev, struct device_attribute
422 *devattr, const char *buf, size_t count)
423{
424 struct f71805f_data *data = dev_get_drvdata(dev);
425 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
426 int nr = attr->index;
427 long val = simple_strtol(buf, NULL, 10);
428
429 down(&data->update_lock);
430 data->in_high[nr] = in_to_reg(val);
431 f71805f_write8(data, F71805F_REG_IN_HIGH(nr), data->in_high[nr]);
432 up(&data->update_lock);
433
434 return count;
435}
436
437static ssize_t set_in_min(struct device *dev, struct device_attribute
438 *devattr, const char *buf, size_t count)
439{
440 struct f71805f_data *data = dev_get_drvdata(dev);
441 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
442 int nr = attr->index;
443 long val = simple_strtol(buf, NULL, 10);
444
445 down(&data->update_lock);
446 data->in_low[nr] = in_to_reg(val);
447 f71805f_write8(data, F71805F_REG_IN_LOW(nr), data->in_low[nr]);
448 up(&data->update_lock);
449
450 return count;
451}
452
453#define sysfs_in(offset) \
454static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \
455 show_in, NULL, offset); \
456static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \
457 show_in_max, set_in_max, offset); \
458static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
459 show_in_min, set_in_min, offset)
460
461sysfs_in(1);
462sysfs_in(2);
463sysfs_in(3);
464sysfs_in(4);
465sysfs_in(5);
466sysfs_in(6);
467sysfs_in(7);
468sysfs_in(8);
469
470static ssize_t show_fan(struct device *dev, struct device_attribute *devattr,
471 char *buf)
472{
473 struct f71805f_data *data = f71805f_update_device(dev);
474 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
475 int nr = attr->index;
476
477 return sprintf(buf, "%ld\n", fan_from_reg(data->fan[nr]));
478}
479
480static ssize_t show_fan_min(struct device *dev, struct device_attribute
481 *devattr, char *buf)
482{
483 struct f71805f_data *data = f71805f_update_device(dev);
484 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
485 int nr = attr->index;
486
487 return sprintf(buf, "%ld\n", fan_from_reg(data->fan_low[nr]));
488}
489
490static ssize_t set_fan_min(struct device *dev, struct device_attribute
491 *devattr, const char *buf, size_t count)
492{
493 struct f71805f_data *data = dev_get_drvdata(dev);
494 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
495 int nr = attr->index;
496 long val = simple_strtol(buf, NULL, 10);
497
498 down(&data->update_lock);
499 data->fan_low[nr] = fan_to_reg(val);
500 f71805f_write16(data, F71805F_REG_FAN_LOW(nr), data->fan_low[nr]);
501 up(&data->update_lock);
502
503 return count;
504}
505
506#define sysfs_fan(offset) \
507static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \
508 show_fan, NULL, offset - 1); \
509static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
510 show_fan_min, set_fan_min, offset - 1)
511
512sysfs_fan(1);
513sysfs_fan(2);
514sysfs_fan(3);
515
516static ssize_t show_temp(struct device *dev, struct device_attribute *devattr,
517 char *buf)
518{
519 struct f71805f_data *data = f71805f_update_device(dev);
520 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
521 int nr = attr->index;
522
523 return sprintf(buf, "%ld\n", temp_from_reg(data->temp[nr]));
524}
525
526static ssize_t show_temp_max(struct device *dev, struct device_attribute
527 *devattr, char *buf)
528{
529 struct f71805f_data *data = f71805f_update_device(dev);
530 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
531 int nr = attr->index;
532
533 return sprintf(buf, "%ld\n", temp_from_reg(data->temp_high[nr]));
534}
535
536static ssize_t show_temp_hyst(struct device *dev, struct device_attribute
537 *devattr, char *buf)
538{
539 struct f71805f_data *data = f71805f_update_device(dev);
540 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
541 int nr = attr->index;
542
543 return sprintf(buf, "%ld\n", temp_from_reg(data->temp_hyst[nr]));
544}
545
546static ssize_t show_temp_type(struct device *dev, struct device_attribute
547 *devattr, char *buf)
548{
549 struct f71805f_data *data = f71805f_update_device(dev);
550 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
551 int nr = attr->index;
552
553 /* 3 is diode, 4 is thermistor */
554 return sprintf(buf, "%u\n", (data->temp_mode & (1 << nr)) ? 3 : 4);
555}
556
557static ssize_t set_temp_max(struct device *dev, struct device_attribute
558 *devattr, const char *buf, size_t count)
559{
560 struct f71805f_data *data = dev_get_drvdata(dev);
561 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
562 int nr = attr->index;
563 long val = simple_strtol(buf, NULL, 10);
564
565 down(&data->update_lock);
566 data->temp_high[nr] = temp_to_reg(val);
567 f71805f_write8(data, F71805F_REG_TEMP_HIGH(nr), data->temp_high[nr]);
568 up(&data->update_lock);
569
570 return count;
571}
572
573static ssize_t set_temp_hyst(struct device *dev, struct device_attribute
574 *devattr, const char *buf, size_t count)
575{
576 struct f71805f_data *data = dev_get_drvdata(dev);
577 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
578 int nr = attr->index;
579 long val = simple_strtol(buf, NULL, 10);
580
581 down(&data->update_lock);
582 data->temp_hyst[nr] = temp_to_reg(val);
583 f71805f_write8(data, F71805F_REG_TEMP_HYST(nr), data->temp_hyst[nr]);
584 up(&data->update_lock);
585
586 return count;
587}
588
589#define sysfs_temp(offset) \
590static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \
591 show_temp, NULL, offset - 1); \
592static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \
593 show_temp_max, set_temp_max, offset - 1); \
594static SENSOR_DEVICE_ATTR(temp##offset##_max_hyst, S_IRUGO | S_IWUSR, \
595 show_temp_hyst, set_temp_hyst, offset - 1); \
596static SENSOR_DEVICE_ATTR(temp##offset##_type, S_IRUGO, \
597 show_temp_type, NULL, offset - 1)
598
599sysfs_temp(1);
600sysfs_temp(2);
601sysfs_temp(3);
602
603static ssize_t show_alarms_in(struct device *dev, struct device_attribute
604 *devattr, char *buf)
605{
606 struct f71805f_data *data = f71805f_update_device(dev);
607
608 return sprintf(buf, "%d\n", data->alarms[0] |
609 ((data->alarms[1] & 0x01) << 8));
610}
611
612static ssize_t show_alarms_fan(struct device *dev, struct device_attribute
613 *devattr, char *buf)
614{
615 struct f71805f_data *data = f71805f_update_device(dev);
616
617 return sprintf(buf, "%d\n", data->alarms[2] & 0x07);
618}
619
620static ssize_t show_alarms_temp(struct device *dev, struct device_attribute
621 *devattr, char *buf)
622{
623 struct f71805f_data *data = f71805f_update_device(dev);
624
625 return sprintf(buf, "%d\n", (data->alarms[1] >> 3) & 0x07);
626}
627
628static DEVICE_ATTR(alarms_in, S_IRUGO, show_alarms_in, NULL);
629static DEVICE_ATTR(alarms_fan, S_IRUGO, show_alarms_fan, NULL);
630static DEVICE_ATTR(alarms_temp, S_IRUGO, show_alarms_temp, NULL);
631
632static ssize_t show_name(struct device *dev, struct device_attribute
633 *devattr, char *buf)
634{
635 struct f71805f_data *data = dev_get_drvdata(dev);
636
637 return sprintf(buf, "%s\n", data->name);
638}
639
640static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
641
642/*
643 * Device registration and initialization
644 */
645
646static void __devinit f71805f_init_device(struct f71805f_data *data)
647{
648 u8 reg;
649 int i;
650
651 reg = f71805f_read8(data, F71805F_REG_START);
652 if ((reg & 0x41) != 0x01) {
653 printk(KERN_DEBUG DRVNAME ": Starting monitoring "
654 "operations\n");
655 f71805f_write8(data, F71805F_REG_START, (reg | 0x01) & ~0x40);
656 }
657
658 /* Fan monitoring can be disabled. If it is, we won't be polling
659 the register values, and won't create the related sysfs files. */
660 for (i = 0; i < 3; i++) {
661 reg = f71805f_read8(data, F71805F_REG_FAN_CTRL(i));
662 if (!(reg & 0x80))
663 data->fan_enabled |= (1 << i);
664 }
665}
666
667static int __devinit f71805f_probe(struct platform_device *pdev)
668{
669 struct f71805f_data *data;
670 struct resource *res;
671 int err;
672
673 if (!(data = kzalloc(sizeof(struct f71805f_data), GFP_KERNEL))) {
674 err = -ENOMEM;
675 printk(KERN_ERR DRVNAME ": Out of memory\n");
676 goto exit;
677 }
678
679 res = platform_get_resource(pdev, IORESOURCE_IO, 0);
680 data->addr = res->start;
681 init_MUTEX(&data->lock);
682 data->name = "f71805f";
683 init_MUTEX(&data->update_lock);
684
685 platform_set_drvdata(pdev, data);
686
687 data->class_dev = hwmon_device_register(&pdev->dev);
688 if (IS_ERR(data->class_dev)) {
689 err = PTR_ERR(data->class_dev);
690 dev_err(&pdev->dev, "Class registration failed (%d)\n", err);
691 goto exit_free;
692 }
693
694 /* Initialize the F71805F chip */
695 f71805f_init_device(data);
696
697 /* Register sysfs interface files */
698 device_create_file(&pdev->dev, &dev_attr_in0_input);
699 device_create_file(&pdev->dev, &dev_attr_in0_max);
700 device_create_file(&pdev->dev, &dev_attr_in0_min);
701 device_create_file(&pdev->dev, &sensor_dev_attr_in1_input.dev_attr);
702 device_create_file(&pdev->dev, &sensor_dev_attr_in2_input.dev_attr);
703 device_create_file(&pdev->dev, &sensor_dev_attr_in3_input.dev_attr);
704 device_create_file(&pdev->dev, &sensor_dev_attr_in4_input.dev_attr);
705 device_create_file(&pdev->dev, &sensor_dev_attr_in5_input.dev_attr);
706 device_create_file(&pdev->dev, &sensor_dev_attr_in6_input.dev_attr);
707 device_create_file(&pdev->dev, &sensor_dev_attr_in7_input.dev_attr);
708 device_create_file(&pdev->dev, &sensor_dev_attr_in8_input.dev_attr);
709 device_create_file(&pdev->dev, &sensor_dev_attr_in1_max.dev_attr);
710 device_create_file(&pdev->dev, &sensor_dev_attr_in2_max.dev_attr);
711 device_create_file(&pdev->dev, &sensor_dev_attr_in3_max.dev_attr);
712 device_create_file(&pdev->dev, &sensor_dev_attr_in4_max.dev_attr);
713 device_create_file(&pdev->dev, &sensor_dev_attr_in5_max.dev_attr);
714 device_create_file(&pdev->dev, &sensor_dev_attr_in6_max.dev_attr);
715 device_create_file(&pdev->dev, &sensor_dev_attr_in7_max.dev_attr);
716 device_create_file(&pdev->dev, &sensor_dev_attr_in8_max.dev_attr);
717 device_create_file(&pdev->dev, &sensor_dev_attr_in1_min.dev_attr);
718 device_create_file(&pdev->dev, &sensor_dev_attr_in2_min.dev_attr);
719 device_create_file(&pdev->dev, &sensor_dev_attr_in3_min.dev_attr);
720 device_create_file(&pdev->dev, &sensor_dev_attr_in4_min.dev_attr);
721 device_create_file(&pdev->dev, &sensor_dev_attr_in5_min.dev_attr);
722 device_create_file(&pdev->dev, &sensor_dev_attr_in6_min.dev_attr);
723 device_create_file(&pdev->dev, &sensor_dev_attr_in7_min.dev_attr);
724 device_create_file(&pdev->dev, &sensor_dev_attr_in8_min.dev_attr);
725 if (data->fan_enabled & (1 << 0)) {
726 device_create_file(&pdev->dev,
727 &sensor_dev_attr_fan1_input.dev_attr);
728 device_create_file(&pdev->dev,
729 &sensor_dev_attr_fan1_min.dev_attr);
730 }
731 if (data->fan_enabled & (1 << 1)) {
732 device_create_file(&pdev->dev,
733 &sensor_dev_attr_fan2_input.dev_attr);
734 device_create_file(&pdev->dev,
735 &sensor_dev_attr_fan2_min.dev_attr);
736 }
737 if (data->fan_enabled & (1 << 2)) {
738 device_create_file(&pdev->dev,
739 &sensor_dev_attr_fan3_input.dev_attr);
740 device_create_file(&pdev->dev,
741 &sensor_dev_attr_fan3_min.dev_attr);
742 }
743 device_create_file(&pdev->dev,
744 &sensor_dev_attr_temp1_input.dev_attr);
745 device_create_file(&pdev->dev,
746 &sensor_dev_attr_temp2_input.dev_attr);
747 device_create_file(&pdev->dev,
748 &sensor_dev_attr_temp3_input.dev_attr);
749 device_create_file(&pdev->dev, &sensor_dev_attr_temp1_max.dev_attr);
750 device_create_file(&pdev->dev, &sensor_dev_attr_temp2_max.dev_attr);
751 device_create_file(&pdev->dev, &sensor_dev_attr_temp3_max.dev_attr);
752 device_create_file(&pdev->dev,
753 &sensor_dev_attr_temp1_max_hyst.dev_attr);
754 device_create_file(&pdev->dev,
755 &sensor_dev_attr_temp2_max_hyst.dev_attr);
756 device_create_file(&pdev->dev,
757 &sensor_dev_attr_temp3_max_hyst.dev_attr);
758 device_create_file(&pdev->dev, &sensor_dev_attr_temp1_type.dev_attr);
759 device_create_file(&pdev->dev, &sensor_dev_attr_temp2_type.dev_attr);
760 device_create_file(&pdev->dev, &sensor_dev_attr_temp3_type.dev_attr);
761 device_create_file(&pdev->dev, &dev_attr_alarms_in);
762 device_create_file(&pdev->dev, &dev_attr_alarms_fan);
763 device_create_file(&pdev->dev, &dev_attr_alarms_temp);
764 device_create_file(&pdev->dev, &dev_attr_name);
765
766 return 0;
767
768exit_free:
769 kfree(data);
770exit:
771 return err;
772}
773
774static int __devexit f71805f_remove(struct platform_device *pdev)
775{
776 struct f71805f_data *data = platform_get_drvdata(pdev);
777
778 platform_set_drvdata(pdev, NULL);
779 hwmon_device_unregister(data->class_dev);
780 kfree(data);
781
782 return 0;
783}
784
785static struct platform_driver f71805f_driver = {
786 .driver = {
787 .owner = THIS_MODULE,
788 .name = DRVNAME,
789 },
790 .probe = f71805f_probe,
791 .remove = __devexit_p(f71805f_remove),
792};
793
794static int __init f71805f_device_add(unsigned short address)
795{
796 int err;
797
798 pdev = platform_device_alloc(DRVNAME, address);
799 if (!pdev) {
800 err = -ENOMEM;
801 printk(KERN_ERR DRVNAME ": Device allocation failed\n");
802 goto exit;
803 }
804
805 f71805f_resource.start = address;
806 f71805f_resource.end = address + REGION_LENGTH - 1;
807 f71805f_resource.name = pdev->name;
808 err = platform_device_add_resources(pdev, &f71805f_resource, 1);
809 if (err) {
810 printk(KERN_ERR DRVNAME ": Device resource addition failed "
811 "(%d)\n", err);
812 goto exit_device_put;
813 }
814
815 err = platform_device_add(pdev);
816 if (err) {
817 printk(KERN_ERR DRVNAME ": Device addition failed (%d)\n",
818 err);
819 goto exit_device_put;
820 }
821
822 return 0;
823
824exit_device_put:
825 platform_device_put(pdev);
826exit:
827 return err;
828}
829
830static int __init f71805f_find(int sioaddr, unsigned short *address)
831{
832 int err = -ENODEV;
833 u16 devid;
834
835 superio_enter(sioaddr);
836
837 devid = superio_inw(sioaddr, SIO_REG_MANID);
838 if (devid != SIO_FINTEK_ID)
839 goto exit;
840
841 devid = superio_inw(sioaddr, SIO_REG_DEVID);
842 if (devid != SIO_F71805F_ID) {
843 printk(KERN_INFO DRVNAME ": Unsupported Fintek device, "
844 "skipping\n");
845 goto exit;
846 }
847
848 superio_select(sioaddr, F71805F_LD_HWM);
849 if (!(superio_inb(sioaddr, SIO_REG_ENABLE) & 0x01)) {
850 printk(KERN_WARNING DRVNAME ": Device not activated, "
851 "skipping\n");
852 goto exit;
853 }
854
855 *address = superio_inw(sioaddr, SIO_REG_ADDR);
856 if (*address == 0) {
857 printk(KERN_WARNING DRVNAME ": Base address not set, "
858 "skipping\n");
859 goto exit;
860 }
861
862 err = 0;
863 printk(KERN_INFO DRVNAME ": Found F71805F chip at %#x, revision %u\n",
864 *address, superio_inb(sioaddr, SIO_REG_DEVREV));
865
866exit:
867 superio_exit(sioaddr);
868 return err;
869}
870
871static int __init f71805f_init(void)
872{
873 int err;
874 unsigned short address;
875
876 if (f71805f_find(0x2e, &address)
877 && f71805f_find(0x4e, &address))
878 return -ENODEV;
879
880 err = platform_driver_register(&f71805f_driver);
881 if (err)
882 goto exit;
883
884 /* Sets global pdev as a side effect */
885 err = f71805f_device_add(address);
886 if (err)
887 goto exit_driver;
888
889 return 0;
890
891exit_driver:
892 platform_driver_unregister(&f71805f_driver);
893exit:
894 return err;
895}
896
897static void __exit f71805f_exit(void)
898{
899 platform_device_unregister(pdev);
900 platform_driver_unregister(&f71805f_driver);
901}
902
903MODULE_AUTHOR("Jean Delvare <khali@linux-fr>");
904MODULE_LICENSE("GPL");
905MODULE_DESCRIPTION("F71805F hardware monitoring driver");
906
907module_init(f71805f_init);
908module_exit(f71805f_exit);
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
index 0da7c9c508c3..e87d52c59940 100644
--- a/drivers/hwmon/it87.c
+++ b/drivers/hwmon/it87.c
@@ -45,8 +45,7 @@
45 45
46 46
47/* Addresses to scan */ 47/* Addresses to scan */
48static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 48static unsigned short normal_i2c[] = { 0x2d, I2C_CLIENT_END };
49 0x2e, 0x2f, I2C_CLIENT_END };
50static unsigned short isa_address; 49static unsigned short isa_address;
51 50
52/* Insmod parameters */ 51/* Insmod parameters */
@@ -830,6 +829,11 @@ static int it87_detect(struct i2c_adapter *adapter, int address, int kind)
830 if ((err = i2c_attach_client(new_client))) 829 if ((err = i2c_attach_client(new_client)))
831 goto ERROR2; 830 goto ERROR2;
832 831
832 if (!is_isa)
833 dev_info(&new_client->dev, "The I2C interface to IT87xxF "
834 "hardware monitoring chips is deprecated. Please "
835 "report if you still rely on it.\n");
836
833 /* Check PWM configuration */ 837 /* Check PWM configuration */
834 enable_pwm_interface = it87_check_pwm(new_client); 838 enable_pwm_interface = it87_check_pwm(new_client);
835 839
diff --git a/drivers/hwmon/lm77.c b/drivers/hwmon/lm77.c
index a2f420d01fb7..df9e02aaa70a 100644
--- a/drivers/hwmon/lm77.c
+++ b/drivers/hwmon/lm77.c
@@ -87,15 +87,15 @@ static struct i2c_driver lm77_driver = {
87 87
88/* In the temperature registers, the low 3 bits are not part of the 88/* In the temperature registers, the low 3 bits are not part of the
89 temperature values; they are the status bits. */ 89 temperature values; they are the status bits. */
90static inline u16 LM77_TEMP_TO_REG(int temp) 90static inline s16 LM77_TEMP_TO_REG(int temp)
91{ 91{
92 int ntemp = SENSORS_LIMIT(temp, LM77_TEMP_MIN, LM77_TEMP_MAX); 92 int ntemp = SENSORS_LIMIT(temp, LM77_TEMP_MIN, LM77_TEMP_MAX);
93 return (u16)((ntemp / 500) * 8); 93 return (ntemp / 500) * 8;
94} 94}
95 95
96static inline int LM77_TEMP_FROM_REG(u16 reg) 96static inline int LM77_TEMP_FROM_REG(s16 reg)
97{ 97{
98 return ((int)reg / 8) * 500; 98 return (reg / 8) * 500;
99} 99}
100 100
101/* sysfs stuff */ 101/* sysfs stuff */
diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c
index b176bf0c4c7b..a2f6bb676235 100644
--- a/drivers/hwmon/w83792d.c
+++ b/drivers/hwmon/w83792d.c
@@ -303,10 +303,6 @@ struct w83792d_data {
303static int w83792d_attach_adapter(struct i2c_adapter *adapter); 303static int w83792d_attach_adapter(struct i2c_adapter *adapter);
304static int w83792d_detect(struct i2c_adapter *adapter, int address, int kind); 304static int w83792d_detect(struct i2c_adapter *adapter, int address, int kind);
305static int w83792d_detach_client(struct i2c_client *client); 305static int w83792d_detach_client(struct i2c_client *client);
306
307static int w83792d_read_value(struct i2c_client *client, u8 register);
308static int w83792d_write_value(struct i2c_client *client, u8 register,
309 u8 value);
310static struct w83792d_data *w83792d_update_device(struct device *dev); 306static struct w83792d_data *w83792d_update_device(struct device *dev);
311 307
312#ifdef DEBUG 308#ifdef DEBUG
@@ -329,6 +325,20 @@ static inline long in_count_from_reg(int nr, struct w83792d_data *data)
329 return ((data->in[nr] << 2) | ((data->low_bits >> (2 * nr)) & 0x03)); 325 return ((data->in[nr] << 2) | ((data->low_bits >> (2 * nr)) & 0x03));
330} 326}
331 327
328/* The SMBus locks itself. The Winbond W83792D chip has a bank register,
329 but the driver only accesses registers in bank 0, so we don't have
330 to switch banks and lock access between switches. */
331static inline int w83792d_read_value(struct i2c_client *client, u8 reg)
332{
333 return i2c_smbus_read_byte_data(client, reg);
334}
335
336static inline int
337w83792d_write_value(struct i2c_client *client, u8 reg, u8 value)
338{
339 return i2c_smbus_write_byte_data(client, reg, value);
340}
341
332/* following are the sysfs callback functions */ 342/* following are the sysfs callback functions */
333static ssize_t show_in(struct device *dev, struct device_attribute *attr, 343static ssize_t show_in(struct device *dev, struct device_attribute *attr,
334 char *buf) 344 char *buf)
@@ -1386,19 +1396,6 @@ w83792d_detach_client(struct i2c_client *client)
1386 return 0; 1396 return 0;
1387} 1397}
1388 1398
1389/* The SMBus locks itself. The Winbond W83792D chip has a bank register,
1390 but the driver only accesses registers in bank 0, so we don't have
1391 to switch banks and lock access between switches. */
1392static int w83792d_read_value(struct i2c_client *client, u8 reg)
1393{
1394 return i2c_smbus_read_byte_data(client, reg);
1395}
1396
1397static int w83792d_write_value(struct i2c_client *client, u8 reg, u8 value)
1398{
1399 return i2c_smbus_write_byte_data(client, reg, value);
1400}
1401
1402static void 1399static void
1403w83792d_init_client(struct i2c_client *client) 1400w83792d_init_client(struct i2c_client *client)
1404{ 1401{
diff --git a/drivers/i2c/algos/i2c-algo-sibyte.c b/drivers/i2c/algos/i2c-algo-sibyte.c
index 938848ae162d..3df3f09995c2 100644
--- a/drivers/i2c/algos/i2c-algo-sibyte.c
+++ b/drivers/i2c/algos/i2c-algo-sibyte.c
@@ -202,7 +202,7 @@ EXPORT_SYMBOL(i2c_sibyte_del_bus);
202#ifdef MODULE 202#ifdef MODULE
203MODULE_AUTHOR("Kip Walker, Broadcom Corp."); 203MODULE_AUTHOR("Kip Walker, Broadcom Corp.");
204MODULE_DESCRIPTION("SiByte I2C-Bus algorithm"); 204MODULE_DESCRIPTION("SiByte I2C-Bus algorithm");
205MODULE_PARM(bit_scan, "i"); 205module_param(bit_scan, int, 0);
206MODULE_PARM_DESC(bit_scan, "Scan for active chips on the bus"); 206MODULE_PARM_DESC(bit_scan, "Scan for active chips on the bus");
207MODULE_LICENSE("GPL"); 207MODULE_LICENSE("GPL");
208 208
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 08d5b8fed2dc..ff92735c7c85 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -124,6 +124,7 @@ config I2C_I801
124 ICH6 124 ICH6
125 ICH7 125 ICH7
126 ESB2 126 ESB2
127 ICH8
127 128
128 This driver can also be built as a module. If so, the module 129 This driver can also be built as a module. If so, the module
129 will be called i2c-i801. 130 will be called i2c-i801.
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index 1c752ddc10e2..8e0f3158215f 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -32,6 +32,7 @@
32 ICH6 266A 32 ICH6 266A
33 ICH7 27DA 33 ICH7 27DA
34 ESB2 269B 34 ESB2 269B
35 ICH8 283E
35 This driver supports several versions of Intel's I/O Controller Hubs (ICH). 36 This driver supports several versions of Intel's I/O Controller Hubs (ICH).
36 For SMBus support, they are similar to the PIIX4 and are part 37 For SMBus support, they are similar to the PIIX4 and are part
37 of Intel's '810' and other chipsets. 38 of Intel's '810' and other chipsets.
@@ -527,6 +528,7 @@ static struct pci_device_id i801_ids[] = {
527 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_16) }, 528 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_16) },
528 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_17) }, 529 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_17) },
529 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB2_17) }, 530 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB2_17) },
531 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_5) },
530 { 0, } 532 { 0, }
531}; 533};
532 534
diff --git a/drivers/i2c/busses/i2c-parport-light.c b/drivers/i2c/busses/i2c-parport-light.c
index 3e5eba9fcacb..c63025a4c861 100644
--- a/drivers/i2c/busses/i2c-parport-light.c
+++ b/drivers/i2c/busses/i2c-parport-light.c
@@ -121,14 +121,11 @@ static struct i2c_adapter parport_adapter = {
121 121
122static int __init i2c_parport_init(void) 122static int __init i2c_parport_init(void)
123{ 123{
124 int type_count; 124 if (type < 0 || type >= ARRAY_SIZE(adapter_parm)) {
125
126 type_count = sizeof(adapter_parm)/sizeof(struct adapter_parm);
127 if (type < 0 || type >= type_count) {
128 printk(KERN_WARNING "i2c-parport: invalid type (%d)\n", type); 125 printk(KERN_WARNING "i2c-parport: invalid type (%d)\n", type);
129 type = 0; 126 type = 0;
130 } 127 }
131 128
132 if (base == 0) { 129 if (base == 0) {
133 printk(KERN_INFO "i2c-parport: using default base 0x%x\n", DEFAULT_BASE); 130 printk(KERN_INFO "i2c-parport: using default base 0x%x\n", DEFAULT_BASE);
134 base = DEFAULT_BASE; 131 base = DEFAULT_BASE;
@@ -152,7 +149,7 @@ static int __init i2c_parport_init(void)
152 release_region(base, 3); 149 release_region(base, 3);
153 return -ENODEV; 150 return -ENODEV;
154 } 151 }
155 152
156 return 0; 153 return 0;
157} 154}
158 155
diff --git a/drivers/i2c/busses/i2c-parport.c b/drivers/i2c/busses/i2c-parport.c
index 2854d858fc9b..7e2e8cd1c14a 100644
--- a/drivers/i2c/busses/i2c-parport.c
+++ b/drivers/i2c/busses/i2c-parport.c
@@ -241,14 +241,11 @@ static struct parport_driver i2c_parport_driver = {
241 241
242static int __init i2c_parport_init(void) 242static int __init i2c_parport_init(void)
243{ 243{
244 int type_count; 244 if (type < 0 || type >= ARRAY_SIZE(adapter_parm)) {
245
246 type_count = sizeof(adapter_parm)/sizeof(struct adapter_parm);
247 if (type < 0 || type >= type_count) {
248 printk(KERN_WARNING "i2c-parport: invalid type (%d)\n", type); 245 printk(KERN_WARNING "i2c-parport: invalid type (%d)\n", type);
249 type = 0; 246 type = 0;
250 } 247 }
251 248
252 return parport_register_driver(&i2c_parport_driver); 249 return parport_register_driver(&i2c_parport_driver);
253} 250}
254 251
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index 86e2234faf80..7579f4b256a8 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -861,7 +861,7 @@ static irqreturn_t i2c_pxa_handler(int this_irq, void *dev_id, struct pt_regs *r
861 decode_ISR(isr); 861 decode_ISR(isr);
862 } 862 }
863 863
864 if (i2c->irqlogidx < sizeof(i2c->isrlog)/sizeof(u32)) 864 if (i2c->irqlogidx < ARRAY_SIZE(i2c->isrlog))
865 i2c->isrlog[i2c->irqlogidx++] = isr; 865 i2c->isrlog[i2c->irqlogidx++] = isr;
866 866
867 show_state(i2c); 867 show_state(i2c);
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 0ce58b506046..1a2c9ab5d9e3 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -946,6 +946,20 @@ s32 i2c_smbus_read_i2c_block_data(struct i2c_client *client, u8 command, u8 *val
946 } 946 }
947} 947}
948 948
949s32 i2c_smbus_write_i2c_block_data(struct i2c_client *client, u8 command,
950 u8 length, u8 *values)
951{
952 union i2c_smbus_data data;
953
954 if (length > I2C_SMBUS_BLOCK_MAX)
955 length = I2C_SMBUS_BLOCK_MAX;
956 data.block[0] = length;
957 memcpy(data.block + 1, values, length);
958 return i2c_smbus_xfer(client->adapter, client->addr, client->flags,
959 I2C_SMBUS_WRITE, command,
960 I2C_SMBUS_I2C_BLOCK_DATA, &data);
961}
962
949/* Simulate a SMBus command using the i2c protocol 963/* Simulate a SMBus command using the i2c protocol
950 No checking of parameters is done! */ 964 No checking of parameters is done! */
951static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, 965static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,
@@ -1150,6 +1164,7 @@ EXPORT_SYMBOL(i2c_smbus_read_word_data);
1150EXPORT_SYMBOL(i2c_smbus_write_word_data); 1164EXPORT_SYMBOL(i2c_smbus_write_word_data);
1151EXPORT_SYMBOL(i2c_smbus_write_block_data); 1165EXPORT_SYMBOL(i2c_smbus_write_block_data);
1152EXPORT_SYMBOL(i2c_smbus_read_i2c_block_data); 1166EXPORT_SYMBOL(i2c_smbus_read_i2c_block_data);
1167EXPORT_SYMBOL(i2c_smbus_write_i2c_block_data);
1153 1168
1154MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>"); 1169MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>");
1155MODULE_DESCRIPTION("I2C-Bus main module"); 1170MODULE_DESCRIPTION("I2C-Bus main module");
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 6c60a9d2afd8..09086b8b6486 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -190,7 +190,8 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
190 if (lba48) { 190 if (lba48) {
191 task_ioreg_t tasklets[10]; 191 task_ioreg_t tasklets[10];
192 192
193 pr_debug("%s: LBA=0x%012llx\n", drive->name, block); 193 pr_debug("%s: LBA=0x%012llx\n", drive->name,
194 (unsigned long long)block);
194 195
195 tasklets[0] = 0; 196 tasklets[0] = 0;
196 tasklets[1] = 0; 197 tasklets[1] = 0;
@@ -317,7 +318,8 @@ static ide_startstop_t ide_do_rw_disk (ide_drive_t *drive, struct request *rq, s
317 318
318 pr_debug("%s: %sing: block=%llu, sectors=%lu, buffer=0x%08lx\n", 319 pr_debug("%s: %sing: block=%llu, sectors=%lu, buffer=0x%08lx\n",
319 drive->name, rq_data_dir(rq) == READ ? "read" : "writ", 320 drive->name, rq_data_dir(rq) == READ ? "read" : "writ",
320 block, rq->nr_sectors, (unsigned long)rq->buffer); 321 (unsigned long long)block, rq->nr_sectors,
322 (unsigned long)rq->buffer);
321 323
322 if (hwif->rw_disk) 324 if (hwif->rw_disk)
323 hwif->rw_disk(drive, rq); 325 hwif->rw_disk(drive, rq);
diff --git a/drivers/media/dvb/b2c2/Kconfig b/drivers/media/dvb/b2c2/Kconfig
index 2583a865a58e..2963605c0ecc 100644
--- a/drivers/media/dvb/b2c2/Kconfig
+++ b/drivers/media/dvb/b2c2/Kconfig
@@ -4,7 +4,7 @@ config DVB_B2C2_FLEXCOP
4 select DVB_STV0299 4 select DVB_STV0299
5 select DVB_MT352 5 select DVB_MT352
6 select DVB_MT312 6 select DVB_MT312
7 select DVB_NXT2002 7 select DVB_NXT200X
8 select DVB_STV0297 8 select DVB_STV0297
9 select DVB_BCM3510 9 select DVB_BCM3510
10 select DVB_LGDT330X 10 select DVB_LGDT330X
diff --git a/drivers/media/dvb/b2c2/flexcop-common.h b/drivers/media/dvb/b2c2/flexcop-common.h
index 344a3c898460..7d7e1613c5a7 100644
--- a/drivers/media/dvb/b2c2/flexcop-common.h
+++ b/drivers/media/dvb/b2c2/flexcop-common.h
@@ -116,11 +116,9 @@ void flexcop_dma_free(struct flexcop_dma *dma);
116 116
117int flexcop_dma_control_timer_irq(struct flexcop_device *fc, flexcop_dma_index_t no, int onoff); 117int flexcop_dma_control_timer_irq(struct flexcop_device *fc, flexcop_dma_index_t no, int onoff);
118int flexcop_dma_control_size_irq(struct flexcop_device *fc, flexcop_dma_index_t no, int onoff); 118int flexcop_dma_control_size_irq(struct flexcop_device *fc, flexcop_dma_index_t no, int onoff);
119int flexcop_dma_control_packet_irq(struct flexcop_device *fc, flexcop_dma_index_t no, int onoff);
120int flexcop_dma_config(struct flexcop_device *fc, struct flexcop_dma *dma, flexcop_dma_index_t dma_idx); 119int flexcop_dma_config(struct flexcop_device *fc, struct flexcop_dma *dma, flexcop_dma_index_t dma_idx);
121int flexcop_dma_xfer_control(struct flexcop_device *fc, flexcop_dma_index_t dma_idx, flexcop_dma_addr_index_t index, int onoff); 120int flexcop_dma_xfer_control(struct flexcop_device *fc, flexcop_dma_index_t dma_idx, flexcop_dma_addr_index_t index, int onoff);
122int flexcop_dma_config_timer(struct flexcop_device *fc, flexcop_dma_index_t dma_idx, u8 cycles); 121int flexcop_dma_config_timer(struct flexcop_device *fc, flexcop_dma_index_t dma_idx, u8 cycles);
123int flexcop_dma_config_packet_count(struct flexcop_device *fc, flexcop_dma_index_t dma_idx, u8 packets);
124 122
125/* from flexcop-eeprom.c */ 123/* from flexcop-eeprom.c */
126/* the PCI part uses this call to get the MAC address, the USB part has its own */ 124/* the PCI part uses this call to get the MAC address, the USB part has its own */
diff --git a/drivers/media/dvb/b2c2/flexcop-dma.c b/drivers/media/dvb/b2c2/flexcop-dma.c
index cf4ed1df6086..6f592bc32d22 100644
--- a/drivers/media/dvb/b2c2/flexcop-dma.c
+++ b/drivers/media/dvb/b2c2/flexcop-dma.c
@@ -169,38 +169,3 @@ int flexcop_dma_config_timer(struct flexcop_device *fc,
169} 169}
170EXPORT_SYMBOL(flexcop_dma_config_timer); 170EXPORT_SYMBOL(flexcop_dma_config_timer);
171 171
172/* packet IRQ does not exist in FCII or FCIIb - according to data book and tests */
173int flexcop_dma_control_packet_irq(struct flexcop_device *fc,
174 flexcop_dma_index_t no,
175 int onoff)
176{
177 flexcop_ibi_value v = fc->read_ibi_reg(fc,ctrl_208);
178
179 deb_rdump("reg: %03x: %x\n",ctrl_208,v.raw);
180 if (no & FC_DMA_1)
181 v.ctrl_208.DMA1_Size_IRQ_Enable_sig = onoff;
182
183 if (no & FC_DMA_2)
184 v.ctrl_208.DMA2_Size_IRQ_Enable_sig = onoff;
185
186 fc->write_ibi_reg(fc,ctrl_208,v);
187 deb_rdump("reg: %03x: %x\n",ctrl_208,v.raw);
188
189 return 0;
190}
191EXPORT_SYMBOL(flexcop_dma_control_packet_irq);
192
193int flexcop_dma_config_packet_count(struct flexcop_device *fc,
194 flexcop_dma_index_t dma_idx,
195 u8 packets)
196{
197 flexcop_ibi_register r = (dma_idx & FC_DMA_1) ? dma1_004 : dma2_014;
198 flexcop_ibi_value v = fc->read_ibi_reg(fc,r);
199
200 flexcop_dma_remap(fc,dma_idx,1);
201
202 v.dma_0x4_remap.DMA_maxpackets = packets;
203 fc->write_ibi_reg(fc,r,v);
204 return 0;
205}
206EXPORT_SYMBOL(flexcop_dma_config_packet_count);
diff --git a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
index 0b940e152b79..390cc3a99ce6 100644
--- a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
+++ b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
@@ -9,7 +9,7 @@
9 9
10#include "stv0299.h" 10#include "stv0299.h"
11#include "mt352.h" 11#include "mt352.h"
12#include "nxt2002.h" 12#include "nxt200x.h"
13#include "bcm3510.h" 13#include "bcm3510.h"
14#include "stv0297.h" 14#include "stv0297.h"
15#include "mt312.h" 15#include "mt312.h"
@@ -343,9 +343,10 @@ static struct lgdt330x_config air2pc_atsc_hd5000_config = {
343 .clock_polarity_flip = 1, 343 .clock_polarity_flip = 1,
344}; 344};
345 345
346static struct nxt2002_config samsung_tbmv_config = { 346static struct nxt200x_config samsung_tbmv_config = {
347 .demod_address = 0x0a, 347 .demod_address = 0x0a,
348 .request_firmware = flexcop_fe_request_firmware, 348 .pll_address = 0xc2,
349 .pll_desc = &dvb_pll_samsung_tbmv,
349}; 350};
350 351
351static struct bcm3510_config air2pc_atsc_first_gen_config = { 352static struct bcm3510_config air2pc_atsc_first_gen_config = {
@@ -505,7 +506,7 @@ int flexcop_frontend_init(struct flexcop_device *fc)
505 info("found the mt352 at i2c address: 0x%02x",samsung_tdtc9251dh0_config.demod_address); 506 info("found the mt352 at i2c address: 0x%02x",samsung_tdtc9251dh0_config.demod_address);
506 } else 507 } else
507 /* try the air atsc 2nd generation (nxt2002) */ 508 /* try the air atsc 2nd generation (nxt2002) */
508 if ((fc->fe = nxt2002_attach(&samsung_tbmv_config, &fc->i2c_adap)) != NULL) { 509 if ((fc->fe = nxt200x_attach(&samsung_tbmv_config, &fc->i2c_adap)) != NULL) {
509 fc->dev_type = FC_AIR_ATSC2; 510 fc->dev_type = FC_AIR_ATSC2;
510 info("found the nxt2002 at i2c address: 0x%02x",samsung_tbmv_config.demod_address); 511 info("found the nxt2002 at i2c address: 0x%02x",samsung_tbmv_config.demod_address);
511 } else 512 } else
diff --git a/drivers/media/dvb/b2c2/flexcop-misc.c b/drivers/media/dvb/b2c2/flexcop-misc.c
index 62282d8dbfa8..167583bf0621 100644
--- a/drivers/media/dvb/b2c2/flexcop-misc.c
+++ b/drivers/media/dvb/b2c2/flexcop-misc.c
@@ -36,14 +36,14 @@ void flexcop_determine_revision(struct flexcop_device *fc)
36 /* bus parts have to decide if hw pid filtering is used or not. */ 36 /* bus parts have to decide if hw pid filtering is used or not. */
37} 37}
38 38
39const char *flexcop_revision_names[] = { 39static const char *flexcop_revision_names[] = {
40 "Unkown chip", 40 "Unkown chip",
41 "FlexCopII", 41 "FlexCopII",
42 "FlexCopIIb", 42 "FlexCopIIb",
43 "FlexCopIII", 43 "FlexCopIII",
44}; 44};
45 45
46const char *flexcop_device_names[] = { 46static const char *flexcop_device_names[] = {
47 "Unkown device", 47 "Unkown device",
48 "Air2PC/AirStar 2 DVB-T", 48 "Air2PC/AirStar 2 DVB-T",
49 "Air2PC/AirStar 2 ATSC 1st generation", 49 "Air2PC/AirStar 2 ATSC 1st generation",
@@ -54,7 +54,7 @@ const char *flexcop_device_names[] = {
54 "Air2PC/AirStar 2 ATSC 3rd generation (HD5000)", 54 "Air2PC/AirStar 2 ATSC 3rd generation (HD5000)",
55}; 55};
56 56
57const char *flexcop_bus_names[] = { 57static const char *flexcop_bus_names[] = {
58 "USB", 58 "USB",
59 "PCI", 59 "PCI",
60}; 60};
diff --git a/drivers/media/dvb/b2c2/flexcop-pci.c b/drivers/media/dvb/b2c2/flexcop-pci.c
index 2f76eb3fea40..9bc40bdcc282 100644
--- a/drivers/media/dvb/b2c2/flexcop-pci.c
+++ b/drivers/media/dvb/b2c2/flexcop-pci.c
@@ -161,8 +161,10 @@ static irqreturn_t flexcop_pci_isr(int irq, void *dev_id, struct pt_regs *regs)
161 fc->read_ibi_reg(fc,dma1_008).dma_0x8.dma_cur_addr << 2; 161 fc->read_ibi_reg(fc,dma1_008).dma_0x8.dma_cur_addr << 2;
162 u32 cur_pos = cur_addr - fc_pci->dma[0].dma_addr0; 162 u32 cur_pos = cur_addr - fc_pci->dma[0].dma_addr0;
163 163
164 deb_irq("%u irq: %08x cur_addr: %08x: cur_pos: %08x, last_cur_pos: %08x ", 164 deb_irq("%u irq: %08x cur_addr: %llx: cur_pos: %08x, last_cur_pos: %08x ",
165 jiffies_to_usecs(jiffies - fc_pci->last_irq),v.raw,cur_addr,cur_pos,fc_pci->last_dma1_cur_pos); 165 jiffies_to_usecs(jiffies - fc_pci->last_irq),
166 v.raw, (unsigned long long)cur_addr, cur_pos,
167 fc_pci->last_dma1_cur_pos);
166 fc_pci->last_irq = jiffies; 168 fc_pci->last_irq = jiffies;
167 169
168 /* buffer end was reached, restarted from the beginning 170 /* buffer end was reached, restarted from the beginning
diff --git a/drivers/media/dvb/b2c2/flexcop-reg.h b/drivers/media/dvb/b2c2/flexcop-reg.h
index 3153f9513c63..491f9bd6e195 100644
--- a/drivers/media/dvb/b2c2/flexcop-reg.h
+++ b/drivers/media/dvb/b2c2/flexcop-reg.h
@@ -16,8 +16,6 @@ typedef enum {
16 FLEXCOP_III, 16 FLEXCOP_III,
17} flexcop_revision_t; 17} flexcop_revision_t;
18 18
19extern const char *flexcop_revision_names[];
20
21typedef enum { 19typedef enum {
22 FC_UNK = 0, 20 FC_UNK = 0,
23 FC_AIR_DVB, 21 FC_AIR_DVB,
@@ -34,8 +32,6 @@ typedef enum {
34 FC_PCI, 32 FC_PCI,
35} flexcop_bus_t; 33} flexcop_bus_t;
36 34
37extern const char *flexcop_device_names[];
38
39/* FlexCop IBI Registers */ 35/* FlexCop IBI Registers */
40#if defined(__LITTLE_ENDIAN) 36#if defined(__LITTLE_ENDIAN)
41 #include "flexcop_ibi_value_le.h" 37 #include "flexcop_ibi_value_le.h"
diff --git a/drivers/media/dvb/bt8xx/bt878.c b/drivers/media/dvb/bt8xx/bt878.c
index a04bb61f21f4..34c3189a1a33 100644
--- a/drivers/media/dvb/bt8xx/bt878.c
+++ b/drivers/media/dvb/bt8xx/bt878.c
@@ -381,6 +381,23 @@ bt878_device_control(struct bt878 *bt, unsigned int cmd, union dst_gpio_packet *
381 381
382EXPORT_SYMBOL(bt878_device_control); 382EXPORT_SYMBOL(bt878_device_control);
383 383
384
385struct cards card_list[] __devinitdata = {
386
387 { 0x01010071, BTTV_BOARD_NEBULA_DIGITV, "Nebula Electronics DigiTV" },
388 { 0x07611461, BTTV_BOARD_AVDVBT_761, "AverMedia AverTV DVB-T 761" },
389 { 0x001c11bd, BTTV_BOARD_PINNACLESAT, "Pinnacle PCTV Sat" },
390 { 0x002611bd, BTTV_BOARD_TWINHAN_DST, "Pinnacle PCTV SAT CI" },
391 { 0x00011822, BTTV_BOARD_TWINHAN_DST, "Twinhan VisionPlus DVB" },
392 { 0xfc00270f, BTTV_BOARD_TWINHAN_DST, "ChainTech digitop DST-1000 DVB-S" },
393 { 0x07711461, BTTV_BOARD_AVDVBT_771, "AVermedia AverTV DVB-T 771" },
394 { 0xdb1018ac, BTTV_BOARD_DVICO_DVBT_LITE, "DViCO FusionHDTV DVB-T Lite" },
395 { 0xd50018ac, BTTV_BOARD_DVICO_FUSIONHDTV_5_LITE, "DViCO FusionHDTV 5 Lite" },
396 { 0x20007063, BTTV_BOARD_PC_HDTV, "pcHDTV HD-2000 TV"},
397 { 0, -1, NULL }
398};
399
400
384/***********************/ 401/***********************/
385/* PCI device handling */ 402/* PCI device handling */
386/***********************/ 403/***********************/
@@ -388,18 +405,41 @@ EXPORT_SYMBOL(bt878_device_control);
388static int __devinit bt878_probe(struct pci_dev *dev, 405static int __devinit bt878_probe(struct pci_dev *dev,
389 const struct pci_device_id *pci_id) 406 const struct pci_device_id *pci_id)
390{ 407{
391 int result; 408 int result = 0, has_dvb = 0, i;
392 unsigned char lat; 409 unsigned char lat;
393 struct bt878 *bt; 410 struct bt878 *bt;
394#if defined(__powerpc__) 411#if defined(__powerpc__)
395 unsigned int cmd; 412 unsigned int cmd;
396#endif 413#endif
414 unsigned int cardid;
415 unsigned short id;
416 struct cards *dvb_cards;
397 417
398 printk(KERN_INFO "bt878: Bt878 AUDIO function found (%d).\n", 418 printk(KERN_INFO "bt878: Bt878 AUDIO function found (%d).\n",
399 bt878_num); 419 bt878_num);
400 if (pci_enable_device(dev)) 420 if (pci_enable_device(dev))
401 return -EIO; 421 return -EIO;
402 422
423 pci_read_config_word(dev, PCI_SUBSYSTEM_ID, &id);
424 cardid = id << 16;
425 pci_read_config_word(dev, PCI_SUBSYSTEM_VENDOR_ID, &id);
426 cardid |= id;
427
428 for (i = 0, dvb_cards = card_list; i < ARRAY_SIZE(card_list); i++, dvb_cards++) {
429 if (cardid == dvb_cards->pci_id) {
430 printk("%s: card id=[0x%x],[ %s ] has DVB functions.\n",
431 __func__, cardid, dvb_cards->name);
432 has_dvb = 1;
433 }
434 }
435
436 if (!has_dvb) {
437 printk("%s: card id=[0x%x], Unknown card.\nExiting..\n", __func__, cardid);
438 result = -EINVAL;
439
440 goto fail0;
441 }
442
403 bt = &bt878[bt878_num]; 443 bt = &bt878[bt878_num];
404 bt->dev = dev; 444 bt->dev = dev;
405 bt->nr = bt878_num; 445 bt->nr = bt878_num;
@@ -416,6 +456,8 @@ static int __devinit bt878_probe(struct pci_dev *dev,
416 456
417 pci_read_config_byte(dev, PCI_CLASS_REVISION, &bt->revision); 457 pci_read_config_byte(dev, PCI_CLASS_REVISION, &bt->revision);
418 pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat); 458 pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat);
459
460
419 printk(KERN_INFO "bt878(%d): Bt%x (rev %d) at %02x:%02x.%x, ", 461 printk(KERN_INFO "bt878(%d): Bt%x (rev %d) at %02x:%02x.%x, ",
420 bt878_num, bt->id, bt->revision, dev->bus->number, 462 bt878_num, bt->id, bt->revision, dev->bus->number,
421 PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn)); 463 PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
diff --git a/drivers/media/dvb/bt8xx/bt878.h b/drivers/media/dvb/bt8xx/bt878.h
index a73baf00ca39..9faf93770d08 100644
--- a/drivers/media/dvb/bt8xx/bt878.h
+++ b/drivers/media/dvb/bt8xx/bt878.h
@@ -88,6 +88,23 @@
88 88
89#define BT878_RISC_SYNC_MASK (1 << 15) 89#define BT878_RISC_SYNC_MASK (1 << 15)
90 90
91
92#define BTTV_BOARD_UNKNOWN 0x00
93#define BTTV_BOARD_PINNACLESAT 0x5e
94#define BTTV_BOARD_NEBULA_DIGITV 0x68
95#define BTTV_BOARD_PC_HDTV 0x70
96#define BTTV_BOARD_TWINHAN_DST 0x71
97#define BTTV_BOARD_AVDVBT_771 0x7b
98#define BTTV_BOARD_AVDVBT_761 0x7c
99#define BTTV_BOARD_DVICO_DVBT_LITE 0x80
100#define BTTV_BOARD_DVICO_FUSIONHDTV_5_LITE 0x87
101
102struct cards {
103 __u32 pci_id;
104 __u16 card_id;
105 char *name;
106};
107
91extern int bt878_num; 108extern int bt878_num;
92 109
93struct bt878 { 110struct bt878 {
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig
index 90a69d343b79..d3df12039b06 100644
--- a/drivers/media/dvb/dvb-usb/Kconfig
+++ b/drivers/media/dvb/dvb-usb/Kconfig
@@ -83,12 +83,18 @@ config DVB_USB_UMT_010
83 Say Y here to support the HanfTek UMT-010 USB2.0 stick-sized DVB-T receiver. 83 Say Y here to support the HanfTek UMT-010 USB2.0 stick-sized DVB-T receiver.
84 84
85config DVB_USB_CXUSB 85config DVB_USB_CXUSB
86 tristate "Medion MD95700 hybrid USB2.0 (Conexant) support" 86 tristate "Conexant USB2.0 hybrid reference design support"
87 depends on DVB_USB 87 depends on DVB_USB
88 select DVB_CX22702 88 select DVB_CX22702
89 select DVB_LGDT330X
90 select DVB_MT352
89 help 91 help
90 Say Y here to support the Medion MD95700 hybrid USB2.0 device. Currently 92 Say Y here to support the Conexant USB2.0 hybrid reference design.
91 only the DVB-T part is supported. 93 Currently, only DVB and ATSC modes are supported, analog mode
94 shall be added in the future. Devices that require this module:
95
96 Medion MD95700 hybrid USB2.0 device.
97 DViCO FusionHDTV (Bluebird) USB2.0 devices
92 98
93config DVB_USB_DIGITV 99config DVB_USB_DIGITV
94 tristate "Nebula Electronics uDigiTV DVB-T USB2.0 support" 100 tristate "Nebula Electronics uDigiTV DVB-T USB2.0 support"
diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c
index a7fb06f4cd34..f327fac1688e 100644
--- a/drivers/media/dvb/dvb-usb/cxusb.c
+++ b/drivers/media/dvb/dvb-usb/cxusb.c
@@ -184,7 +184,7 @@ static int cxusb_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
184 return 0; 184 return 0;
185} 185}
186 186
187struct dvb_usb_rc_key dvico_mce_rc_keys[] = { 187static struct dvb_usb_rc_key dvico_mce_rc_keys[] = {
188 { 0xfe, 0x02, KEY_TV }, 188 { 0xfe, 0x02, KEY_TV },
189 { 0xfe, 0x0e, KEY_MP3 }, 189 { 0xfe, 0x0e, KEY_MP3 },
190 { 0xfe, 0x1a, KEY_DVD }, 190 { 0xfe, 0x1a, KEY_DVD },
@@ -234,7 +234,7 @@ struct dvb_usb_rc_key dvico_mce_rc_keys[] = {
234 234
235static int cxusb_dee1601_demod_init(struct dvb_frontend* fe) 235static int cxusb_dee1601_demod_init(struct dvb_frontend* fe)
236{ 236{
237 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x38 }; 237 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x28 };
238 static u8 reset [] = { RESET, 0x80 }; 238 static u8 reset [] = { RESET, 0x80 };
239 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 }; 239 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
240 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 }; 240 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 };
@@ -255,7 +255,7 @@ static int cxusb_dee1601_demod_init(struct dvb_frontend* fe)
255 255
256static int cxusb_mt352_demod_init(struct dvb_frontend* fe) 256static int cxusb_mt352_demod_init(struct dvb_frontend* fe)
257{ /* used in both lgz201 and th7579 */ 257{ /* used in both lgz201 and th7579 */
258 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x39 }; 258 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x29 };
259 static u8 reset [] = { RESET, 0x80 }; 259 static u8 reset [] = { RESET, 0x80 };
260 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 }; 260 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
261 static u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 }; 261 static u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
@@ -273,7 +273,7 @@ static int cxusb_mt352_demod_init(struct dvb_frontend* fe)
273 return 0; 273 return 0;
274} 274}
275 275
276struct cx22702_config cxusb_cx22702_config = { 276static struct cx22702_config cxusb_cx22702_config = {
277 .demod_address = 0x63, 277 .demod_address = 0x63,
278 278
279 .output_mode = CX22702_PARALLEL_OUTPUT, 279 .output_mode = CX22702_PARALLEL_OUTPUT,
@@ -282,13 +282,13 @@ struct cx22702_config cxusb_cx22702_config = {
282 .pll_set = dvb_usb_pll_set_i2c, 282 .pll_set = dvb_usb_pll_set_i2c,
283}; 283};
284 284
285struct lgdt330x_config cxusb_lgdt330x_config = { 285static struct lgdt330x_config cxusb_lgdt330x_config = {
286 .demod_address = 0x0e, 286 .demod_address = 0x0e,
287 .demod_chip = LGDT3303, 287 .demod_chip = LGDT3303,
288 .pll_set = dvb_usb_pll_set_i2c, 288 .pll_set = dvb_usb_pll_set_i2c,
289}; 289};
290 290
291struct mt352_config cxusb_dee1601_config = { 291static struct mt352_config cxusb_dee1601_config = {
292 .demod_address = 0x0f, 292 .demod_address = 0x0f,
293 .demod_init = cxusb_dee1601_demod_init, 293 .demod_init = cxusb_dee1601_demod_init,
294 .pll_set = dvb_usb_pll_set, 294 .pll_set = dvb_usb_pll_set,
diff --git a/drivers/media/dvb/dvb-usb/digitv.c b/drivers/media/dvb/dvb-usb/digitv.c
index e6c55c9c9417..caa1346e3063 100644
--- a/drivers/media/dvb/dvb-usb/digitv.c
+++ b/drivers/media/dvb/dvb-usb/digitv.c
@@ -175,11 +175,13 @@ static int digitv_probe(struct usb_interface *intf,
175 if ((ret = dvb_usb_device_init(intf,&digitv_properties,THIS_MODULE,&d)) == 0) { 175 if ((ret = dvb_usb_device_init(intf,&digitv_properties,THIS_MODULE,&d)) == 0) {
176 u8 b[4] = { 0 }; 176 u8 b[4] = { 0 };
177 177
178 b[0] = 1; 178 if (d != NULL) { /* do that only when the firmware is loaded */
179 digitv_ctrl_msg(d,USB_WRITE_REMOTE_TYPE,0,b,4,NULL,0); 179 b[0] = 1;
180 digitv_ctrl_msg(d,USB_WRITE_REMOTE_TYPE,0,b,4,NULL,0);
180 181
181 b[0] = 0; 182 b[0] = 0;
182 digitv_ctrl_msg(d,USB_WRITE_REMOTE,0,b,4,NULL,0); 183 digitv_ctrl_msg(d,USB_WRITE_REMOTE,0,b,4,NULL,0);
184 }
183 } 185 }
184 return ret; 186 return ret;
185} 187}
@@ -194,7 +196,7 @@ static struct dvb_usb_properties digitv_properties = {
194 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 196 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
195 197
196 .usb_ctrl = CYPRESS_FX2, 198 .usb_ctrl = CYPRESS_FX2,
197 .firmware = "dvb-usb-digitv-01.fw", 199 .firmware = "dvb-usb-digitv-02.fw",
198 200
199 .size_of_priv = 0, 201 .size_of_priv = 0,
200 202
@@ -229,6 +231,7 @@ static struct dvb_usb_properties digitv_properties = {
229 { &digitv_table[0], NULL }, 231 { &digitv_table[0], NULL },
230 { NULL }, 232 { NULL },
231 }, 233 },
234 { NULL },
232 } 235 }
233}; 236};
234 237
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-firmware.c b/drivers/media/dvb/dvb-usb/dvb-usb-firmware.c
index 8535895819fb..9222b0a81f74 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-firmware.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-firmware.c
@@ -24,6 +24,9 @@ static struct usb_cypress_controller cypress[] = {
24 { .id = CYPRESS_FX2, .name = "Cypress FX2", .cpu_cs_register = 0xe600 }, 24 { .id = CYPRESS_FX2, .name = "Cypress FX2", .cpu_cs_register = 0xe600 },
25}; 25};
26 26
27static int dvb_usb_get_hexline(const struct firmware *fw, struct hexline *hx,
28 int *pos);
29
27/* 30/*
28 * load a firmware packet to the device 31 * load a firmware packet to the device
29 */ 32 */
@@ -112,7 +115,8 @@ int dvb_usb_download_firmware(struct usb_device *udev, struct dvb_usb_properties
112 return ret; 115 return ret;
113} 116}
114 117
115int dvb_usb_get_hexline(const struct firmware *fw, struct hexline *hx, int *pos) 118static int dvb_usb_get_hexline(const struct firmware *fw, struct hexline *hx,
119 int *pos)
116{ 120{
117 u8 *b = (u8 *) &fw->data[*pos]; 121 u8 *b = (u8 *) &fw->data[*pos];
118 int data_offs = 4; 122 int data_offs = 4;
@@ -142,5 +146,3 @@ int dvb_usb_get_hexline(const struct firmware *fw, struct hexline *hx, int *pos)
142 146
143 return *pos; 147 return *pos;
144} 148}
145EXPORT_SYMBOL(dvb_usb_get_hexline);
146
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb.h b/drivers/media/dvb/dvb-usb/dvb-usb.h
index dd568396e594..5e5d21ad93c9 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb.h
@@ -341,7 +341,6 @@ struct hexline {
341 u8 data[255]; 341 u8 data[255];
342 u8 chk; 342 u8 chk;
343}; 343};
344extern int dvb_usb_get_hexline(const struct firmware *, struct hexline *, int *);
345extern int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type); 344extern int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type);
346 345
347#endif 346#endif
diff --git a/drivers/media/dvb/dvb-usb/vp702x.c b/drivers/media/dvb/dvb-usb/vp702x.c
index afa00fdb5ec0..4a95eca81c5c 100644
--- a/drivers/media/dvb/dvb-usb/vp702x.c
+++ b/drivers/media/dvb/dvb-usb/vp702x.c
@@ -53,7 +53,8 @@ int vp702x_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8
53 return ret; 53 return ret;
54} 54}
55 55
56int vp702x_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen) 56static int vp702x_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value,
57 u16 index, u8 *b, int blen)
57{ 58{
58 deb_xfer("out: req. %x, val: %x, ind: %x, buffer: ",req,value,index); 59 deb_xfer("out: req. %x, val: %x, ind: %x, buffer: ",req,value,index);
59 debug_dump(b,blen,deb_xfer); 60 debug_dump(b,blen,deb_xfer);
@@ -88,7 +89,8 @@ unlock:
88 return ret; 89 return ret;
89} 90}
90 91
91int vp702x_usb_inout_cmd(struct dvb_usb_device *d, u8 cmd, u8 *o, int olen, u8 *i, int ilen, int msec) 92static int vp702x_usb_inout_cmd(struct dvb_usb_device *d, u8 cmd, u8 *o,
93 int olen, u8 *i, int ilen, int msec)
92{ 94{
93 u8 bout[olen+2]; 95 u8 bout[olen+2];
94 u8 bin[ilen+1]; 96 u8 bin[ilen+1];
diff --git a/drivers/media/dvb/dvb-usb/vp702x.h b/drivers/media/dvb/dvb-usb/vp702x.h
index a808d48e7bf2..c2f97f96c21f 100644
--- a/drivers/media/dvb/dvb-usb/vp702x.h
+++ b/drivers/media/dvb/dvb-usb/vp702x.h
@@ -101,8 +101,6 @@ extern int dvb_usb_vp702x_debug;
101extern struct dvb_frontend * vp702x_fe_attach(struct dvb_usb_device *d); 101extern struct dvb_frontend * vp702x_fe_attach(struct dvb_usb_device *d);
102 102
103extern int vp702x_usb_inout_op(struct dvb_usb_device *d, u8 *o, int olen, u8 *i, int ilen, int msec); 103extern int vp702x_usb_inout_op(struct dvb_usb_device *d, u8 *o, int olen, u8 *i, int ilen, int msec);
104extern int vp702x_usb_inout_cmd(struct dvb_usb_device *d, u8 cmd, u8 *o, int olen, u8 *i, int ilen, int msec);
105extern int vp702x_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen); 104extern int vp702x_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen);
106extern int vp702x_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen);
107 105
108#endif 106#endif
diff --git a/drivers/media/dvb/dvb-usb/vp7045-fe.c b/drivers/media/dvb/dvb-usb/vp7045-fe.c
index 5242cca5db4a..9999336aeeb6 100644
--- a/drivers/media/dvb/dvb-usb/vp7045-fe.c
+++ b/drivers/media/dvb/dvb-usb/vp7045-fe.c
@@ -23,10 +23,11 @@
23 23
24struct vp7045_fe_state { 24struct vp7045_fe_state {
25 struct dvb_frontend fe; 25 struct dvb_frontend fe;
26 struct dvb_frontend_ops ops;
27
26 struct dvb_usb_device *d; 28 struct dvb_usb_device *d;
27}; 29};
28 30
29
30static int vp7045_fe_read_status(struct dvb_frontend* fe, fe_status_t *status) 31static int vp7045_fe_read_status(struct dvb_frontend* fe, fe_status_t *status)
31{ 32{
32 struct vp7045_fe_state *state = fe->demodulator_priv; 33 struct vp7045_fe_state *state = fe->demodulator_priv;
@@ -150,7 +151,8 @@ struct dvb_frontend * vp7045_fe_attach(struct dvb_usb_device *d)
150 goto error; 151 goto error;
151 152
152 s->d = d; 153 s->d = d;
153 s->fe.ops = &vp7045_fe_ops; 154 memcpy(&s->ops, &vp7045_fe_ops, sizeof(struct dvb_frontend_ops));
155 s->fe.ops = &s->ops;
154 s->fe.demodulator_priv = s; 156 s->fe.demodulator_priv = s;
155 157
156 goto success; 158 goto success;
diff --git a/drivers/media/dvb/frontends/Kconfig b/drivers/media/dvb/frontends/Kconfig
index db3a8b40031e..76b6a2aef32f 100644
--- a/drivers/media/dvb/frontends/Kconfig
+++ b/drivers/media/dvb/frontends/Kconfig
@@ -28,12 +28,6 @@ config DVB_TDA8083
28 help 28 help
29 A DVB-S tuner module. Say Y when you want to support this frontend. 29 A DVB-S tuner module. Say Y when you want to support this frontend.
30 30
31config DVB_TDA80XX
32 tristate "Philips TDA8044 or TDA8083 based"
33 depends on DVB_CORE
34 help
35 A DVB-S tuner module. Say Y when you want to support this frontend.
36
37config DVB_MT312 31config DVB_MT312
38 tristate "Zarlink MT312 based" 32 tristate "Zarlink MT312 based"
39 depends on DVB_CORE 33 depends on DVB_CORE
@@ -139,12 +133,6 @@ config DVB_DIB3000MC
139comment "DVB-C (cable) frontends" 133comment "DVB-C (cable) frontends"
140 depends on DVB_CORE 134 depends on DVB_CORE
141 135
142config DVB_ATMEL_AT76C651
143 tristate "Atmel AT76C651 based"
144 depends on DVB_CORE
145 help
146 A DVB-C tuner module. Say Y when you want to support this frontend.
147
148config DVB_VES1820 136config DVB_VES1820
149 tristate "VLSI VES1820 based" 137 tristate "VLSI VES1820 based"
150 depends on DVB_CORE 138 depends on DVB_CORE
@@ -166,18 +154,6 @@ config DVB_STV0297
166comment "ATSC (North American/Korean Terresterial DTV) frontends" 154comment "ATSC (North American/Korean Terresterial DTV) frontends"
167 depends on DVB_CORE 155 depends on DVB_CORE
168 156
169config DVB_NXT2002
170 tristate "Nxt2002 based"
171 depends on DVB_CORE
172 select FW_LOADER
173 help
174 An ATSC 8VSB tuner module. Say Y when you want to support this frontend.
175
176 This driver needs external firmware. Please use the command
177 "<kerneldir>/Documentation/dvb/get_dvb_firmware nxt2002" to
178 download/extract it, and then copy it to /usr/lib/hotplug/firmware
179 or /lib/firmware (depending on configuration of firmware hotplug).
180
181config DVB_NXT200X 157config DVB_NXT200X
182 tristate "Nextwave NXT2002/NXT2004 based" 158 tristate "Nextwave NXT2002/NXT2004 based"
183 depends on DVB_CORE 159 depends on DVB_CORE
diff --git a/drivers/media/dvb/frontends/Makefile b/drivers/media/dvb/frontends/Makefile
index 615ec830e1c9..1af769cd90c0 100644
--- a/drivers/media/dvb/frontends/Makefile
+++ b/drivers/media/dvb/frontends/Makefile
@@ -8,7 +8,6 @@ obj-$(CONFIG_DVB_CORE) += dvb-pll.o
8obj-$(CONFIG_DVB_STV0299) += stv0299.o 8obj-$(CONFIG_DVB_STV0299) += stv0299.o
9obj-$(CONFIG_DVB_SP8870) += sp8870.o 9obj-$(CONFIG_DVB_SP8870) += sp8870.o
10obj-$(CONFIG_DVB_CX22700) += cx22700.o 10obj-$(CONFIG_DVB_CX22700) += cx22700.o
11obj-$(CONFIG_DVB_ATMEL_AT76C651) += at76c651.o
12obj-$(CONFIG_DVB_CX24110) += cx24110.o 11obj-$(CONFIG_DVB_CX24110) += cx24110.o
13obj-$(CONFIG_DVB_TDA8083) += tda8083.o 12obj-$(CONFIG_DVB_TDA8083) += tda8083.o
14obj-$(CONFIG_DVB_L64781) += l64781.o 13obj-$(CONFIG_DVB_L64781) += l64781.o
@@ -22,10 +21,8 @@ obj-$(CONFIG_DVB_SP887X) += sp887x.o
22obj-$(CONFIG_DVB_NXT6000) += nxt6000.o 21obj-$(CONFIG_DVB_NXT6000) += nxt6000.o
23obj-$(CONFIG_DVB_MT352) += mt352.o 22obj-$(CONFIG_DVB_MT352) += mt352.o
24obj-$(CONFIG_DVB_CX22702) += cx22702.o 23obj-$(CONFIG_DVB_CX22702) += cx22702.o
25obj-$(CONFIG_DVB_TDA80XX) += tda80xx.o
26obj-$(CONFIG_DVB_TDA10021) += tda10021.o 24obj-$(CONFIG_DVB_TDA10021) += tda10021.o
27obj-$(CONFIG_DVB_STV0297) += stv0297.o 25obj-$(CONFIG_DVB_STV0297) += stv0297.o
28obj-$(CONFIG_DVB_NXT2002) += nxt2002.o
29obj-$(CONFIG_DVB_NXT200X) += nxt200x.o 26obj-$(CONFIG_DVB_NXT200X) += nxt200x.o
30obj-$(CONFIG_DVB_OR51211) += or51211.o 27obj-$(CONFIG_DVB_OR51211) += or51211.o
31obj-$(CONFIG_DVB_OR51132) += or51132.o 28obj-$(CONFIG_DVB_OR51132) += or51132.o
diff --git a/drivers/media/dvb/frontends/at76c651.c b/drivers/media/dvb/frontends/at76c651.c
deleted file mode 100644
index 8e0f4b3a1417..000000000000
--- a/drivers/media/dvb/frontends/at76c651.c
+++ /dev/null
@@ -1,450 +0,0 @@
1/*
2 * at76c651.c
3 *
4 * Atmel DVB-C Frontend Driver (at76c651/tua6010xs)
5 *
6 * Copyright (C) 2001 fnbrd <fnbrd@gmx.de>
7 * & 2002-2004 Andreas Oberritter <obi@linuxtv.org>
8 * & 2003 Wolfram Joost <dbox2@frokaschwei.de>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 * AT76C651
25 * http://www.nalanda.nitc.ac.in/industry/datasheets/atmel/acrobat/doc1293.pdf
26 * http://www.atmel.com/atmel/acrobat/doc1320.pdf
27 */
28
29#include <linux/init.h>
30#include <linux/module.h>
31#include <linux/moduleparam.h>
32#include <linux/kernel.h>
33#include <linux/string.h>
34#include <linux/slab.h>
35#include <linux/bitops.h>
36#include "dvb_frontend.h"
37#include "at76c651.h"
38
39
40struct at76c651_state {
41
42 struct i2c_adapter* i2c;
43
44 struct dvb_frontend_ops ops;
45
46 const struct at76c651_config* config;
47
48 struct dvb_frontend frontend;
49
50 /* revision of the chip */
51 u8 revision;
52
53 /* last QAM value set */
54 u8 qam;
55};
56
57static int debug;
58#define dprintk(args...) \
59 do { \
60 if (debug) printk(KERN_DEBUG "at76c651: " args); \
61 } while (0)
62
63
64#if ! defined(__powerpc__)
65static __inline__ int __ilog2(unsigned long x)
66{
67 int i;
68
69 if (x == 0)
70 return -1;
71
72 for (i = 0; x != 0; i++)
73 x >>= 1;
74
75 return i - 1;
76}
77#endif
78
79static int at76c651_writereg(struct at76c651_state* state, u8 reg, u8 data)
80{
81 int ret;
82 u8 buf[] = { reg, data };
83 struct i2c_msg msg =
84 { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 };
85
86 ret = i2c_transfer(state->i2c, &msg, 1);
87
88 if (ret != 1)
89 dprintk("%s: writereg error "
90 "(reg == 0x%02x, val == 0x%02x, ret == %i)\n",
91 __FUNCTION__, reg, data, ret);
92
93 msleep(10);
94
95 return (ret != 1) ? -EREMOTEIO : 0;
96}
97
98static u8 at76c651_readreg(struct at76c651_state* state, u8 reg)
99{
100 int ret;
101 u8 val;
102 struct i2c_msg msg[] = {
103 { .addr = state->config->demod_address, .flags = 0, .buf = &reg, .len = 1 },
104 { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = &val, .len = 1 }
105 };
106
107 ret = i2c_transfer(state->i2c, msg, 2);
108
109 if (ret != 2)
110 dprintk("%s: readreg error (ret == %i)\n", __FUNCTION__, ret);
111
112 return val;
113}
114
115static int at76c651_reset(struct at76c651_state* state)
116{
117 return at76c651_writereg(state, 0x07, 0x01);
118}
119
120static void at76c651_disable_interrupts(struct at76c651_state* state)
121{
122 at76c651_writereg(state, 0x0b, 0x00);
123}
124
125static int at76c651_set_auto_config(struct at76c651_state *state)
126{
127 /*
128 * Autoconfig
129 */
130
131 at76c651_writereg(state, 0x06, 0x01);
132
133 /*
134 * Performance optimizations, should be done after autoconfig
135 */
136
137 at76c651_writereg(state, 0x10, 0x06);
138 at76c651_writereg(state, 0x11, ((state->qam == 5) || (state->qam == 7)) ? 0x12 : 0x10);
139 at76c651_writereg(state, 0x15, 0x28);
140 at76c651_writereg(state, 0x20, 0x09);
141 at76c651_writereg(state, 0x24, ((state->qam == 5) || (state->qam == 7)) ? 0xC0 : 0x90);
142 at76c651_writereg(state, 0x30, 0x90);
143 if (state->qam == 5)
144 at76c651_writereg(state, 0x35, 0x2A);
145
146 /*
147 * Initialize A/D-converter
148 */
149
150 if (state->revision == 0x11) {
151 at76c651_writereg(state, 0x2E, 0x38);
152 at76c651_writereg(state, 0x2F, 0x13);
153 }
154
155 at76c651_disable_interrupts(state);
156
157 /*
158 * Restart operation
159 */
160
161 at76c651_reset(state);
162
163 return 0;
164}
165
166static void at76c651_set_bbfreq(struct at76c651_state* state)
167{
168 at76c651_writereg(state, 0x04, 0x3f);
169 at76c651_writereg(state, 0x05, 0xee);
170}
171
172static int at76c651_set_symbol_rate(struct at76c651_state* state, u32 symbol_rate)
173{
174 u8 exponent;
175 u32 mantissa;
176
177 if (symbol_rate > 9360000)
178 return -EINVAL;
179
180 /*
181 * FREF = 57800 kHz
182 * exponent = 10 + floor (log2(symbol_rate / FREF))
183 * mantissa = (symbol_rate / FREF) * (1 << (30 - exponent))
184 */
185
186 exponent = __ilog2((symbol_rate << 4) / 903125);
187 mantissa = ((symbol_rate / 3125) * (1 << (24 - exponent))) / 289;
188
189 at76c651_writereg(state, 0x00, mantissa >> 13);
190 at76c651_writereg(state, 0x01, mantissa >> 5);
191 at76c651_writereg(state, 0x02, (mantissa << 3) | exponent);
192
193 return 0;
194}
195
196static int at76c651_set_qam(struct at76c651_state *state, fe_modulation_t qam)
197{
198 switch (qam) {
199 case QPSK:
200 state->qam = 0x02;
201 break;
202 case QAM_16:
203 state->qam = 0x04;
204 break;
205 case QAM_32:
206 state->qam = 0x05;
207 break;
208 case QAM_64:
209 state->qam = 0x06;
210 break;
211 case QAM_128:
212 state->qam = 0x07;
213 break;
214 case QAM_256:
215 state->qam = 0x08;
216 break;
217#if 0
218 case QAM_512:
219 state->qam = 0x09;
220 break;
221 case QAM_1024:
222 state->qam = 0x0A;
223 break;
224#endif
225 default:
226 return -EINVAL;
227
228 }
229
230 return at76c651_writereg(state, 0x03, state->qam);
231}
232
233static int at76c651_set_inversion(struct at76c651_state* state, fe_spectral_inversion_t inversion)
234{
235 u8 feciqinv = at76c651_readreg(state, 0x60);
236
237 switch (inversion) {
238 case INVERSION_OFF:
239 feciqinv |= 0x02;
240 feciqinv &= 0xFE;
241 break;
242
243 case INVERSION_ON:
244 feciqinv |= 0x03;
245 break;
246
247 case INVERSION_AUTO:
248 feciqinv &= 0xFC;
249 break;
250
251 default:
252 return -EINVAL;
253 }
254
255 return at76c651_writereg(state, 0x60, feciqinv);
256}
257
258static int at76c651_set_parameters(struct dvb_frontend* fe,
259 struct dvb_frontend_parameters *p)
260{
261 int ret;
262 struct at76c651_state* state = fe->demodulator_priv;
263
264 at76c651_writereg(state, 0x0c, 0xc3);
265 state->config->pll_set(fe, p);
266 at76c651_writereg(state, 0x0c, 0xc2);
267
268 if ((ret = at76c651_set_symbol_rate(state, p->u.qam.symbol_rate)))
269 return ret;
270
271 if ((ret = at76c651_set_inversion(state, p->inversion)))
272 return ret;
273
274 return at76c651_set_auto_config(state);
275}
276
277static int at76c651_set_defaults(struct dvb_frontend* fe)
278{
279 struct at76c651_state* state = fe->demodulator_priv;
280
281 at76c651_set_symbol_rate(state, 6900000);
282 at76c651_set_qam(state, QAM_64);
283 at76c651_set_bbfreq(state);
284 at76c651_set_auto_config(state);
285
286 if (state->config->pll_init) {
287 at76c651_writereg(state, 0x0c, 0xc3);
288 state->config->pll_init(fe);
289 at76c651_writereg(state, 0x0c, 0xc2);
290 }
291
292 return 0;
293}
294
295static int at76c651_read_status(struct dvb_frontend* fe, fe_status_t* status)
296{
297 struct at76c651_state* state = fe->demodulator_priv;
298 u8 sync;
299
300 /*
301 * Bits: FEC, CAR, EQU, TIM, AGC2, AGC1, ADC, PLL (PLL=0)
302 */
303 sync = at76c651_readreg(state, 0x80);
304 *status = 0;
305
306 if (sync & (0x04 | 0x10)) /* AGC1 || TIM */
307 *status |= FE_HAS_SIGNAL;
308 if (sync & 0x10) /* TIM */
309 *status |= FE_HAS_CARRIER;
310 if (sync & 0x80) /* FEC */
311 *status |= FE_HAS_VITERBI;
312 if (sync & 0x40) /* CAR */
313 *status |= FE_HAS_SYNC;
314 if ((sync & 0xF0) == 0xF0) /* TIM && EQU && CAR && FEC */
315 *status |= FE_HAS_LOCK;
316
317 return 0;
318}
319
320static int at76c651_read_ber(struct dvb_frontend* fe, u32* ber)
321{
322 struct at76c651_state* state = fe->demodulator_priv;
323
324 *ber = (at76c651_readreg(state, 0x81) & 0x0F) << 16;
325 *ber |= at76c651_readreg(state, 0x82) << 8;
326 *ber |= at76c651_readreg(state, 0x83);
327 *ber *= 10;
328
329 return 0;
330}
331
332static int at76c651_read_signal_strength(struct dvb_frontend* fe, u16* strength)
333{
334 struct at76c651_state* state = fe->demodulator_priv;
335
336 u8 gain = ~at76c651_readreg(state, 0x91);
337 *strength = (gain << 8) | gain;
338
339 return 0;
340}
341
342static int at76c651_read_snr(struct dvb_frontend* fe, u16* snr)
343{
344 struct at76c651_state* state = fe->demodulator_priv;
345
346 *snr = 0xFFFF -
347 ((at76c651_readreg(state, 0x8F) << 8) |
348 at76c651_readreg(state, 0x90));
349
350 return 0;
351}
352
353static int at76c651_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
354{
355 struct at76c651_state* state = fe->demodulator_priv;
356
357 *ucblocks = at76c651_readreg(state, 0x82);
358
359 return 0;
360}
361
362static int at76c651_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *fesettings)
363{
364 fesettings->min_delay_ms = 50;
365 fesettings->step_size = 0;
366 fesettings->max_drift = 0;
367 return 0;
368}
369
370static void at76c651_release(struct dvb_frontend* fe)
371{
372 struct at76c651_state* state = fe->demodulator_priv;
373 kfree(state);
374}
375
376static struct dvb_frontend_ops at76c651_ops;
377
378struct dvb_frontend* at76c651_attach(const struct at76c651_config* config,
379 struct i2c_adapter* i2c)
380{
381 struct at76c651_state* state = NULL;
382
383 /* allocate memory for the internal state */
384 state = kmalloc(sizeof(struct at76c651_state), GFP_KERNEL);
385 if (state == NULL) goto error;
386
387 /* setup the state */
388 state->config = config;
389 state->qam = 0;
390
391 /* check if the demod is there */
392 if (at76c651_readreg(state, 0x0e) != 0x65) goto error;
393
394 /* finalise state setup */
395 state->i2c = i2c;
396 state->revision = at76c651_readreg(state, 0x0f) & 0xfe;
397 memcpy(&state->ops, &at76c651_ops, sizeof(struct dvb_frontend_ops));
398
399 /* create dvb_frontend */
400 state->frontend.ops = &state->ops;
401 state->frontend.demodulator_priv = state;
402 return &state->frontend;
403
404error:
405 kfree(state);
406 return NULL;
407}
408
409static struct dvb_frontend_ops at76c651_ops = {
410
411 .info = {
412 .name = "Atmel AT76C651B DVB-C",
413 .type = FE_QAM,
414 .frequency_min = 48250000,
415 .frequency_max = 863250000,
416 .frequency_stepsize = 62500,
417 /*.frequency_tolerance = */ /* FIXME: 12% of SR */
418 .symbol_rate_min = 0, /* FIXME */
419 .symbol_rate_max = 9360000, /* FIXME */
420 .symbol_rate_tolerance = 4000,
421 .caps = FE_CAN_INVERSION_AUTO |
422 FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
423 FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 |
424 FE_CAN_FEC_7_8 | FE_CAN_FEC_8_9 | FE_CAN_FEC_AUTO |
425 FE_CAN_QAM_16 | FE_CAN_QAM_32 | FE_CAN_QAM_64 | FE_CAN_QAM_128 |
426 FE_CAN_MUTE_TS | FE_CAN_QAM_256 | FE_CAN_RECOVER
427 },
428
429 .release = at76c651_release,
430
431 .init = at76c651_set_defaults,
432
433 .set_frontend = at76c651_set_parameters,
434 .get_tune_settings = at76c651_get_tune_settings,
435
436 .read_status = at76c651_read_status,
437 .read_ber = at76c651_read_ber,
438 .read_signal_strength = at76c651_read_signal_strength,
439 .read_snr = at76c651_read_snr,
440 .read_ucblocks = at76c651_read_ucblocks,
441};
442
443module_param(debug, int, 0644);
444MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
445
446MODULE_DESCRIPTION("Atmel AT76C651 DVB-C Demodulator Driver");
447MODULE_AUTHOR("Andreas Oberritter <obi@linuxtv.org>");
448MODULE_LICENSE("GPL");
449
450EXPORT_SYMBOL(at76c651_attach);
diff --git a/drivers/media/dvb/frontends/at76c651.h b/drivers/media/dvb/frontends/at76c651.h
deleted file mode 100644
index 34054df93608..000000000000
--- a/drivers/media/dvb/frontends/at76c651.h
+++ /dev/null
@@ -1,47 +0,0 @@
1/*
2 * at76c651.c
3 *
4 * Atmel DVB-C Frontend Driver (at76c651)
5 *
6 * Copyright (C) 2001 fnbrd <fnbrd@gmx.de>
7 * & 2002-2004 Andreas Oberritter <obi@linuxtv.org>
8 * & 2003 Wolfram Joost <dbox2@frokaschwei.de>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 * AT76C651
25 * http://www.nalanda.nitc.ac.in/industry/datasheets/atmel/acrobat/doc1293.pdf
26 * http://www.atmel.com/atmel/acrobat/doc1320.pdf
27 */
28
29#ifndef AT76C651_H
30#define AT76C651_H
31
32#include <linux/dvb/frontend.h>
33
34struct at76c651_config
35{
36 /* the demodulator's i2c address */
37 u8 demod_address;
38
39 /* PLL maintenance */
40 int (*pll_init)(struct dvb_frontend* fe);
41 int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
42};
43
44extern struct dvb_frontend* at76c651_attach(const struct at76c651_config* config,
45 struct i2c_adapter* i2c);
46
47#endif // AT76C651_H
diff --git a/drivers/media/dvb/frontends/dvb-pll.c b/drivers/media/dvb/frontends/dvb-pll.c
index 1b9934ea5b06..4dcb6050d4fa 100644
--- a/drivers/media/dvb/frontends/dvb-pll.c
+++ b/drivers/media/dvb/frontends/dvb-pll.c
@@ -326,11 +326,11 @@ struct dvb_pll_desc dvb_pll_tuv1236d = {
326}; 326};
327EXPORT_SYMBOL(dvb_pll_tuv1236d); 327EXPORT_SYMBOL(dvb_pll_tuv1236d);
328 328
329/* Samsung TBMV30111IN 329/* Samsung TBMV30111IN / TBMV30712IN1
330 * used in Air2PC ATSC - 2nd generation (nxt2002) 330 * used in Air2PC ATSC - 2nd generation (nxt2002)
331 */ 331 */
332struct dvb_pll_desc dvb_pll_tbmv30111in = { 332struct dvb_pll_desc dvb_pll_samsung_tbmv = {
333 .name = "Samsung TBMV30111IN", 333 .name = "Samsung TBMV30111IN / TBMV30712IN1",
334 .min = 54000000, 334 .min = 54000000,
335 .max = 860000000, 335 .max = 860000000,
336 .count = 6, 336 .count = 6,
@@ -343,7 +343,7 @@ struct dvb_pll_desc dvb_pll_tbmv30111in = {
343 { 999999999, 44000000, 166666, 0xfc, 0x02 }, 343 { 999999999, 44000000, 166666, 0xfc, 0x02 },
344 } 344 }
345}; 345};
346EXPORT_SYMBOL(dvb_pll_tbmv30111in); 346EXPORT_SYMBOL(dvb_pll_samsung_tbmv);
347 347
348/* 348/*
349 * Philips SD1878 Tuner. 349 * Philips SD1878 Tuner.
diff --git a/drivers/media/dvb/frontends/dvb-pll.h b/drivers/media/dvb/frontends/dvb-pll.h
index f682c09189b3..bb8d4b4eb183 100644
--- a/drivers/media/dvb/frontends/dvb-pll.h
+++ b/drivers/media/dvb/frontends/dvb-pll.h
@@ -38,7 +38,7 @@ extern struct dvb_pll_desc dvb_pll_tded4;
38 38
39extern struct dvb_pll_desc dvb_pll_tuv1236d; 39extern struct dvb_pll_desc dvb_pll_tuv1236d;
40extern struct dvb_pll_desc dvb_pll_tdhu2; 40extern struct dvb_pll_desc dvb_pll_tdhu2;
41extern struct dvb_pll_desc dvb_pll_tbmv30111in; 41extern struct dvb_pll_desc dvb_pll_samsung_tbmv;
42extern struct dvb_pll_desc dvb_pll_philips_sd1878_tda8261; 42extern struct dvb_pll_desc dvb_pll_philips_sd1878_tda8261;
43 43
44int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf, 44int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf,
diff --git a/drivers/media/dvb/frontends/nxt2002.c b/drivers/media/dvb/frontends/nxt2002.c
deleted file mode 100644
index 4f263e65ba14..000000000000
--- a/drivers/media/dvb/frontends/nxt2002.c
+++ /dev/null
@@ -1,706 +0,0 @@
1/*
2 Support for B2C2/BBTI Technisat Air2PC - ATSC
3
4 Copyright (C) 2004 Taylor Jacob <rtjacob@earthlink.net>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
20*/
21
22/*
23 * This driver needs external firmware. Please use the command
24 * "<kerneldir>/Documentation/dvb/get_dvb_firmware nxt2002" to
25 * download/extract it, and then copy it to /usr/lib/hotplug/firmware
26 * or /lib/firmware (depending on configuration of firmware hotplug).
27 */
28#define NXT2002_DEFAULT_FIRMWARE "dvb-fe-nxt2002.fw"
29#define CRC_CCIT_MASK 0x1021
30
31#include <linux/init.h>
32#include <linux/module.h>
33#include <linux/moduleparam.h>
34#include <linux/device.h>
35#include <linux/firmware.h>
36#include <linux/string.h>
37#include <linux/slab.h>
38
39#include "dvb_frontend.h"
40#include "nxt2002.h"
41
42struct nxt2002_state {
43
44 struct i2c_adapter* i2c;
45 struct dvb_frontend_ops ops;
46 const struct nxt2002_config* config;
47 struct dvb_frontend frontend;
48
49 /* demodulator private data */
50 u8 initialised:1;
51};
52
53static int debug;
54#define dprintk(args...) \
55 do { \
56 if (debug) printk(KERN_DEBUG "nxt2002: " args); \
57 } while (0)
58
59static int i2c_writebytes (struct nxt2002_state* state, u8 reg, u8 *buf, u8 len)
60{
61 /* probbably a much better way or doing this */
62 u8 buf2 [256],x;
63 int err;
64 struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf2, .len = len + 1 };
65
66 buf2[0] = reg;
67 for (x = 0 ; x < len ; x++)
68 buf2[x+1] = buf[x];
69
70 if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) {
71 printk ("%s: i2c write error (addr %02x, err == %i)\n",
72 __FUNCTION__, state->config->demod_address, err);
73 return -EREMOTEIO;
74 }
75
76 return 0;
77}
78
79static u8 i2c_readbytes (struct nxt2002_state* state, u8 reg, u8* buf, u8 len)
80{
81 u8 reg2 [] = { reg };
82
83 struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = reg2, .len = 1 },
84 { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = buf, .len = len } };
85
86 int err;
87
88 if ((err = i2c_transfer (state->i2c, msg, 2)) != 2) {
89 printk ("%s: i2c read error (addr %02x, err == %i)\n",
90 __FUNCTION__, state->config->demod_address, err);
91 return -EREMOTEIO;
92 }
93
94 return 0;
95}
96
97static u16 nxt2002_crc(u16 crc, u8 c)
98{
99
100 u8 i;
101 u16 input = (u16) c & 0xFF;
102
103 input<<=8;
104 for(i=0 ;i<8 ;i++) {
105 if((crc ^ input) & 0x8000)
106 crc=(crc<<1)^CRC_CCIT_MASK;
107 else
108 crc<<=1;
109 input<<=1;
110 }
111 return crc;
112}
113
114static int nxt2002_writereg_multibyte (struct nxt2002_state* state, u8 reg, u8* data, u8 len)
115{
116 u8 buf;
117 dprintk("%s\n", __FUNCTION__);
118
119 /* set multi register length */
120 i2c_writebytes(state,0x34,&len,1);
121
122 /* set mutli register register */
123 i2c_writebytes(state,0x35,&reg,1);
124
125 /* send the actual data */
126 i2c_writebytes(state,0x36,data,len);
127
128 /* toggle the multireg write bit*/
129 buf = 0x02;
130 i2c_writebytes(state,0x21,&buf,1);
131
132 i2c_readbytes(state,0x21,&buf,1);
133
134 if ((buf & 0x02) == 0)
135 return 0;
136
137 dprintk("Error writing multireg register %02X\n",reg);
138
139 return 0;
140}
141
142static int nxt2002_readreg_multibyte (struct nxt2002_state* state, u8 reg, u8* data, u8 len)
143{
144 u8 len2;
145 dprintk("%s\n", __FUNCTION__);
146
147 /* set multi register length */
148 len2 = len & 0x80;
149 i2c_writebytes(state,0x34,&len2,1);
150
151 /* set mutli register register */
152 i2c_writebytes(state,0x35,&reg,1);
153
154 /* send the actual data */
155 i2c_readbytes(state,reg,data,len);
156
157 return 0;
158}
159
160static void nxt2002_microcontroller_stop (struct nxt2002_state* state)
161{
162 u8 buf[2],counter = 0;
163 dprintk("%s\n", __FUNCTION__);
164
165 buf[0] = 0x80;
166 i2c_writebytes(state,0x22,buf,1);
167
168 while (counter < 20) {
169 i2c_readbytes(state,0x31,buf,1);
170 if (buf[0] & 0x40)
171 return;
172 msleep(10);
173 counter++;
174 }
175
176 dprintk("Timeout waiting for micro to stop.. This is ok after firmware upload\n");
177 return;
178}
179
180static void nxt2002_microcontroller_start (struct nxt2002_state* state)
181{
182 u8 buf;
183 dprintk("%s\n", __FUNCTION__);
184
185 buf = 0x00;
186 i2c_writebytes(state,0x22,&buf,1);
187}
188
189static int nxt2002_writetuner (struct nxt2002_state* state, u8* data)
190{
191 u8 buf,count = 0;
192
193 dprintk("Tuner Bytes: %02X %02X %02X %02X\n",data[0],data[1],data[2],data[3]);
194
195 dprintk("%s\n", __FUNCTION__);
196 /* stop the micro first */
197 nxt2002_microcontroller_stop(state);
198
199 /* set the i2c transfer speed to the tuner */
200 buf = 0x03;
201 i2c_writebytes(state,0x20,&buf,1);
202
203 /* setup to transfer 4 bytes via i2c */
204 buf = 0x04;
205 i2c_writebytes(state,0x34,&buf,1);
206
207 /* write actual tuner bytes */
208 i2c_writebytes(state,0x36,data,4);
209
210 /* set tuner i2c address */
211 buf = 0xC2;
212 i2c_writebytes(state,0x35,&buf,1);
213
214 /* write UC Opmode to begin transfer */
215 buf = 0x80;
216 i2c_writebytes(state,0x21,&buf,1);
217
218 while (count < 20) {
219 i2c_readbytes(state,0x21,&buf,1);
220 if ((buf & 0x80)== 0x00)
221 return 0;
222 msleep(100);
223 count++;
224 }
225
226 printk("nxt2002: timeout error writing tuner\n");
227 return 0;
228}
229
230static void nxt2002_agc_reset(struct nxt2002_state* state)
231{
232 u8 buf;
233 dprintk("%s\n", __FUNCTION__);
234
235 buf = 0x08;
236 i2c_writebytes(state,0x08,&buf,1);
237
238 buf = 0x00;
239 i2c_writebytes(state,0x08,&buf,1);
240
241 return;
242}
243
244static int nxt2002_load_firmware (struct dvb_frontend* fe, const struct firmware *fw)
245{
246
247 struct nxt2002_state* state = fe->demodulator_priv;
248 u8 buf[256],written = 0,chunkpos = 0;
249 u16 rambase,position,crc = 0;
250
251 dprintk("%s\n", __FUNCTION__);
252 dprintk("Firmware is %zu bytes\n",fw->size);
253
254 /* Get the RAM base for this nxt2002 */
255 i2c_readbytes(state,0x10,buf,1);
256
257 if (buf[0] & 0x10)
258 rambase = 0x1000;
259 else
260 rambase = 0x0000;
261
262 dprintk("rambase on this nxt2002 is %04X\n",rambase);
263
264 /* Hold the micro in reset while loading firmware */
265 buf[0] = 0x80;
266 i2c_writebytes(state,0x2B,buf,1);
267
268 for (position = 0; position < fw->size ; position++) {
269 if (written == 0) {
270 crc = 0;
271 chunkpos = 0x28;
272 buf[0] = ((rambase + position) >> 8);
273 buf[1] = (rambase + position) & 0xFF;
274 buf[2] = 0x81;
275 /* write starting address */
276 i2c_writebytes(state,0x29,buf,3);
277 }
278 written++;
279 chunkpos++;
280
281 if ((written % 4) == 0)
282 i2c_writebytes(state,chunkpos,&fw->data[position-3],4);
283
284 crc = nxt2002_crc(crc,fw->data[position]);
285
286 if ((written == 255) || (position+1 == fw->size)) {
287 /* write remaining bytes of firmware */
288 i2c_writebytes(state, chunkpos+4-(written %4),
289 &fw->data[position-(written %4) + 1],
290 written %4);
291 buf[0] = crc << 8;
292 buf[1] = crc & 0xFF;
293
294 /* write crc */
295 i2c_writebytes(state,0x2C,buf,2);
296
297 /* do a read to stop things */
298 i2c_readbytes(state,0x2A,buf,1);
299
300 /* set transfer mode to complete */
301 buf[0] = 0x80;
302 i2c_writebytes(state,0x2B,buf,1);
303
304 written = 0;
305 }
306 }
307
308 printk ("done.\n");
309 return 0;
310};
311
312static int nxt2002_setup_frontend_parameters (struct dvb_frontend* fe,
313 struct dvb_frontend_parameters *p)
314{
315 struct nxt2002_state* state = fe->demodulator_priv;
316 u32 freq = 0;
317 u16 tunerfreq = 0;
318 u8 buf[4];
319
320 freq = 44000 + ( p->frequency / 1000 );
321
322 dprintk("freq = %d p->frequency = %d\n",freq,p->frequency);
323
324 tunerfreq = freq * 24/4000;
325
326 buf[0] = (tunerfreq >> 8) & 0x7F;
327 buf[1] = (tunerfreq & 0xFF);
328
329 if (p->frequency <= 214000000) {
330 buf[2] = 0x84 + (0x06 << 3);
331 buf[3] = (p->frequency <= 172000000) ? 0x01 : 0x02;
332 } else if (p->frequency <= 721000000) {
333 buf[2] = 0x84 + (0x07 << 3);
334 buf[3] = (p->frequency <= 467000000) ? 0x02 : 0x08;
335 } else if (p->frequency <= 841000000) {
336 buf[2] = 0x84 + (0x0E << 3);
337 buf[3] = 0x08;
338 } else {
339 buf[2] = 0x84 + (0x0F << 3);
340 buf[3] = 0x02;
341 }
342
343 /* write frequency information */
344 nxt2002_writetuner(state,buf);
345
346 /* reset the agc now that tuning has been completed */
347 nxt2002_agc_reset(state);
348
349 /* set target power level */
350 switch (p->u.vsb.modulation) {
351 case QAM_64:
352 case QAM_256:
353 buf[0] = 0x74;
354 break;
355 case VSB_8:
356 buf[0] = 0x70;
357 break;
358 default:
359 return -EINVAL;
360 break;
361 }
362 i2c_writebytes(state,0x42,buf,1);
363
364 /* configure sdm */
365 buf[0] = 0x87;
366 i2c_writebytes(state,0x57,buf,1);
367
368 /* write sdm1 input */
369 buf[0] = 0x10;
370 buf[1] = 0x00;
371 nxt2002_writereg_multibyte(state,0x58,buf,2);
372
373 /* write sdmx input */
374 switch (p->u.vsb.modulation) {
375 case QAM_64:
376 buf[0] = 0x68;
377 break;
378 case QAM_256:
379 buf[0] = 0x64;
380 break;
381 case VSB_8:
382 buf[0] = 0x60;
383 break;
384 default:
385 return -EINVAL;
386 break;
387 }
388 buf[1] = 0x00;
389 nxt2002_writereg_multibyte(state,0x5C,buf,2);
390
391 /* write adc power lpf fc */
392 buf[0] = 0x05;
393 i2c_writebytes(state,0x43,buf,1);
394
395 /* write adc power lpf fc */
396 buf[0] = 0x05;
397 i2c_writebytes(state,0x43,buf,1);
398
399 /* write accumulator2 input */
400 buf[0] = 0x80;
401 buf[1] = 0x00;
402 nxt2002_writereg_multibyte(state,0x4B,buf,2);
403
404 /* write kg1 */
405 buf[0] = 0x00;
406 i2c_writebytes(state,0x4D,buf,1);
407
408 /* write sdm12 lpf fc */
409 buf[0] = 0x44;
410 i2c_writebytes(state,0x55,buf,1);
411
412 /* write agc control reg */
413 buf[0] = 0x04;
414 i2c_writebytes(state,0x41,buf,1);
415
416 /* write agc ucgp0 */
417 switch (p->u.vsb.modulation) {
418 case QAM_64:
419 buf[0] = 0x02;
420 break;
421 case QAM_256:
422 buf[0] = 0x03;
423 break;
424 case VSB_8:
425 buf[0] = 0x00;
426 break;
427 default:
428 return -EINVAL;
429 break;
430 }
431 i2c_writebytes(state,0x30,buf,1);
432
433 /* write agc control reg */
434 buf[0] = 0x00;
435 i2c_writebytes(state,0x41,buf,1);
436
437 /* write accumulator2 input */
438 buf[0] = 0x80;
439 buf[1] = 0x00;
440 nxt2002_writereg_multibyte(state,0x49,buf,2);
441 nxt2002_writereg_multibyte(state,0x4B,buf,2);
442
443 /* write agc control reg */
444 buf[0] = 0x04;
445 i2c_writebytes(state,0x41,buf,1);
446
447 nxt2002_microcontroller_start(state);
448
449 /* adjacent channel detection should be done here, but I don't
450 have any stations with this need so I cannot test it */
451
452 return 0;
453}
454
455static int nxt2002_read_status(struct dvb_frontend* fe, fe_status_t* status)
456{
457 struct nxt2002_state* state = fe->demodulator_priv;
458 u8 lock;
459 i2c_readbytes(state,0x31,&lock,1);
460
461 *status = 0;
462 if (lock & 0x20) {
463 *status |= FE_HAS_SIGNAL;
464 *status |= FE_HAS_CARRIER;
465 *status |= FE_HAS_VITERBI;
466 *status |= FE_HAS_SYNC;
467 *status |= FE_HAS_LOCK;
468 }
469 return 0;
470}
471
472static int nxt2002_read_ber(struct dvb_frontend* fe, u32* ber)
473{
474 struct nxt2002_state* state = fe->demodulator_priv;
475 u8 b[3];
476
477 nxt2002_readreg_multibyte(state,0xE6,b,3);
478
479 *ber = ((b[0] << 8) + b[1]) * 8;
480
481 return 0;
482}
483
484static int nxt2002_read_signal_strength(struct dvb_frontend* fe, u16* strength)
485{
486 struct nxt2002_state* state = fe->demodulator_priv;
487 u8 b[2];
488 u16 temp = 0;
489
490 /* setup to read cluster variance */
491 b[0] = 0x00;
492 i2c_writebytes(state,0xA1,b,1);
493
494 /* get multreg val */
495 nxt2002_readreg_multibyte(state,0xA6,b,2);
496
497 temp = (b[0] << 8) | b[1];
498 *strength = ((0x7FFF - temp) & 0x0FFF) * 16;
499
500 return 0;
501}
502
503static int nxt2002_read_snr(struct dvb_frontend* fe, u16* snr)
504{
505
506 struct nxt2002_state* state = fe->demodulator_priv;
507 u8 b[2];
508 u16 temp = 0, temp2;
509 u32 snrdb = 0;
510
511 /* setup to read cluster variance */
512 b[0] = 0x00;
513 i2c_writebytes(state,0xA1,b,1);
514
515 /* get multreg val from 0xA6 */
516 nxt2002_readreg_multibyte(state,0xA6,b,2);
517
518 temp = (b[0] << 8) | b[1];
519 temp2 = 0x7FFF - temp;
520
521 /* snr will be in db */
522 if (temp2 > 0x7F00)
523 snrdb = 1000*24 + ( 1000*(30-24) * ( temp2 - 0x7F00 ) / ( 0x7FFF - 0x7F00 ) );
524 else if (temp2 > 0x7EC0)
525 snrdb = 1000*18 + ( 1000*(24-18) * ( temp2 - 0x7EC0 ) / ( 0x7F00 - 0x7EC0 ) );
526 else if (temp2 > 0x7C00)
527 snrdb = 1000*12 + ( 1000*(18-12) * ( temp2 - 0x7C00 ) / ( 0x7EC0 - 0x7C00 ) );
528 else
529 snrdb = 1000*0 + ( 1000*(12-0) * ( temp2 - 0 ) / ( 0x7C00 - 0 ) );
530
531 /* the value reported back from the frontend will be FFFF=32db 0000=0db */
532
533 *snr = snrdb * (0xFFFF/32000);
534
535 return 0;
536}
537
538static int nxt2002_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
539{
540 struct nxt2002_state* state = fe->demodulator_priv;
541 u8 b[3];
542
543 nxt2002_readreg_multibyte(state,0xE6,b,3);
544 *ucblocks = b[2];
545
546 return 0;
547}
548
549static int nxt2002_sleep(struct dvb_frontend* fe)
550{
551 return 0;
552}
553
554static int nxt2002_init(struct dvb_frontend* fe)
555{
556 struct nxt2002_state* state = fe->demodulator_priv;
557 const struct firmware *fw;
558 int ret;
559 u8 buf[2];
560
561 if (!state->initialised) {
562 /* request the firmware, this will block until someone uploads it */
563 printk("nxt2002: Waiting for firmware upload (%s)...\n", NXT2002_DEFAULT_FIRMWARE);
564 ret = state->config->request_firmware(fe, &fw, NXT2002_DEFAULT_FIRMWARE);
565 printk("nxt2002: Waiting for firmware upload(2)...\n");
566 if (ret) {
567 printk("nxt2002: no firmware upload (timeout or file not found?)\n");
568 return ret;
569 }
570
571 ret = nxt2002_load_firmware(fe, fw);
572 if (ret) {
573 printk("nxt2002: writing firmware to device failed\n");
574 release_firmware(fw);
575 return ret;
576 }
577 printk("nxt2002: firmware upload complete\n");
578
579 /* Put the micro into reset */
580 nxt2002_microcontroller_stop(state);
581
582 /* ensure transfer is complete */
583 buf[0]=0;
584 i2c_writebytes(state,0x2B,buf,1);
585
586 /* Put the micro into reset for real this time */
587 nxt2002_microcontroller_stop(state);
588
589 /* soft reset everything (agc,frontend,eq,fec)*/
590 buf[0] = 0x0F;
591 i2c_writebytes(state,0x08,buf,1);
592 buf[0] = 0x00;
593 i2c_writebytes(state,0x08,buf,1);
594
595 /* write agc sdm configure */
596 buf[0] = 0xF1;
597 i2c_writebytes(state,0x57,buf,1);
598
599 /* write mod output format */
600 buf[0] = 0x20;
601 i2c_writebytes(state,0x09,buf,1);
602
603 /* write fec mpeg mode */
604 buf[0] = 0x7E;
605 buf[1] = 0x00;
606 i2c_writebytes(state,0xE9,buf,2);
607
608 /* write mux selection */
609 buf[0] = 0x00;
610 i2c_writebytes(state,0xCC,buf,1);
611
612 state->initialised = 1;
613 }
614
615 return 0;
616}
617
618static int nxt2002_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings)
619{
620 fesettings->min_delay_ms = 500;
621 fesettings->step_size = 0;
622 fesettings->max_drift = 0;
623 return 0;
624}
625
626static void nxt2002_release(struct dvb_frontend* fe)
627{
628 struct nxt2002_state* state = fe->demodulator_priv;
629 kfree(state);
630}
631
632static struct dvb_frontend_ops nxt2002_ops;
633
634struct dvb_frontend* nxt2002_attach(const struct nxt2002_config* config,
635 struct i2c_adapter* i2c)
636{
637 struct nxt2002_state* state = NULL;
638 u8 buf [] = {0,0,0,0,0};
639
640 /* allocate memory for the internal state */
641 state = kmalloc(sizeof(struct nxt2002_state), GFP_KERNEL);
642 if (state == NULL) goto error;
643
644 /* setup the state */
645 state->config = config;
646 state->i2c = i2c;
647 memcpy(&state->ops, &nxt2002_ops, sizeof(struct dvb_frontend_ops));
648 state->initialised = 0;
649
650 /* Check the first 5 registers to ensure this a revision we can handle */
651
652 i2c_readbytes(state, 0x00, buf, 5);
653 if (buf[0] != 0x04) goto error; /* device id */
654 if (buf[1] != 0x02) goto error; /* fab id */
655 if (buf[2] != 0x11) goto error; /* month */
656 if (buf[3] != 0x20) goto error; /* year msb */
657 if (buf[4] != 0x00) goto error; /* year lsb */
658
659 /* create dvb_frontend */
660 state->frontend.ops = &state->ops;
661 state->frontend.demodulator_priv = state;
662 return &state->frontend;
663
664error:
665 kfree(state);
666 return NULL;
667}
668
669static struct dvb_frontend_ops nxt2002_ops = {
670
671 .info = {
672 .name = "Nextwave nxt2002 VSB/QAM frontend",
673 .type = FE_ATSC,
674 .frequency_min = 54000000,
675 .frequency_max = 860000000,
676 /* stepsize is just a guess */
677 .frequency_stepsize = 166666,
678 .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
679 FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
680 FE_CAN_8VSB | FE_CAN_QAM_64 | FE_CAN_QAM_256
681 },
682
683 .release = nxt2002_release,
684
685 .init = nxt2002_init,
686 .sleep = nxt2002_sleep,
687
688 .set_frontend = nxt2002_setup_frontend_parameters,
689 .get_tune_settings = nxt2002_get_tune_settings,
690
691 .read_status = nxt2002_read_status,
692 .read_ber = nxt2002_read_ber,
693 .read_signal_strength = nxt2002_read_signal_strength,
694 .read_snr = nxt2002_read_snr,
695 .read_ucblocks = nxt2002_read_ucblocks,
696
697};
698
699module_param(debug, int, 0644);
700MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
701
702MODULE_DESCRIPTION("NXT2002 ATSC (8VSB & ITU J83 AnnexB FEC QAM64/256) demodulator driver");
703MODULE_AUTHOR("Taylor Jacob");
704MODULE_LICENSE("GPL");
705
706EXPORT_SYMBOL(nxt2002_attach);
diff --git a/drivers/media/dvb/frontends/nxt2002.h b/drivers/media/dvb/frontends/nxt2002.h
deleted file mode 100644
index 462301f577ee..000000000000
--- a/drivers/media/dvb/frontends/nxt2002.h
+++ /dev/null
@@ -1,23 +0,0 @@
1/*
2 Driver for the Nxt2002 demodulator
3*/
4
5#ifndef NXT2002_H
6#define NXT2002_H
7
8#include <linux/dvb/frontend.h>
9#include <linux/firmware.h>
10
11struct nxt2002_config
12{
13 /* the demodulator's i2c address */
14 u8 demod_address;
15
16 /* request firmware for device */
17 int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name);
18};
19
20extern struct dvb_frontend* nxt2002_attach(const struct nxt2002_config* config,
21 struct i2c_adapter* i2c);
22
23#endif // NXT2002_H
diff --git a/drivers/media/dvb/frontends/nxt200x.c b/drivers/media/dvb/frontends/nxt200x.c
index 78d2b93d35b9..9e3535394509 100644
--- a/drivers/media/dvb/frontends/nxt200x.c
+++ b/drivers/media/dvb/frontends/nxt200x.c
@@ -1,9 +1,10 @@
1/* 1/*
2 * Support for NXT2002 and NXT2004 - VSB/QAM 2 * Support for NXT2002 and NXT2004 - VSB/QAM
3 * 3 *
4 * Copyright (C) 2005 Kirk Lapray (kirk.lapray@gmail.com) 4 * Copyright (C) 2005 Kirk Lapray <kirk.lapray@gmail.com>
5 * Copyright (C) 2006 Michael Krufky <mkrufky@m1k.net>
5 * based on nxt2002 by Taylor Jacob <rtjacob@earthlink.net> 6 * based on nxt2002 by Taylor Jacob <rtjacob@earthlink.net>
6 * and nxt2004 by Jean-Francois Thibert (jeanfrancois@sagetv.com) 7 * and nxt2004 by Jean-Francois Thibert <jeanfrancois@sagetv.com>
7 * 8 *
8 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 10 * it under the terms of the GNU General Public License as published by
@@ -614,7 +615,17 @@ static int nxt200x_setup_frontend_parameters (struct dvb_frontend* fe,
614 /* write sdm1 input */ 615 /* write sdm1 input */
615 buf[0] = 0x10; 616 buf[0] = 0x10;
616 buf[1] = 0x00; 617 buf[1] = 0x00;
617 nxt200x_writebytes(state, 0x58, buf, 2); 618 switch (state->demod_chip) {
619 case NXT2002:
620 nxt200x_writereg_multibyte(state, 0x58, buf, 2);
621 break;
622 case NXT2004:
623 nxt200x_writebytes(state, 0x58, buf, 2);
624 break;
625 default:
626 return -EINVAL;
627 break;
628 }
618 629
619 /* write sdmx input */ 630 /* write sdmx input */
620 switch (p->u.vsb.modulation) { 631 switch (p->u.vsb.modulation) {
@@ -632,7 +643,17 @@ static int nxt200x_setup_frontend_parameters (struct dvb_frontend* fe,
632 break; 643 break;
633 } 644 }
634 buf[1] = 0x00; 645 buf[1] = 0x00;
635 nxt200x_writebytes(state, 0x5C, buf, 2); 646 switch (state->demod_chip) {
647 case NXT2002:
648 nxt200x_writereg_multibyte(state, 0x5C, buf, 2);
649 break;
650 case NXT2004:
651 nxt200x_writebytes(state, 0x5C, buf, 2);
652 break;
653 default:
654 return -EINVAL;
655 break;
656 }
636 657
637 /* write adc power lpf fc */ 658 /* write adc power lpf fc */
638 buf[0] = 0x05; 659 buf[0] = 0x05;
@@ -648,7 +669,17 @@ static int nxt200x_setup_frontend_parameters (struct dvb_frontend* fe,
648 /* write accumulator2 input */ 669 /* write accumulator2 input */
649 buf[0] = 0x80; 670 buf[0] = 0x80;
650 buf[1] = 0x00; 671 buf[1] = 0x00;
651 nxt200x_writebytes(state, 0x4B, buf, 2); 672 switch (state->demod_chip) {
673 case NXT2002:
674 nxt200x_writereg_multibyte(state, 0x4B, buf, 2);
675 break;
676 case NXT2004:
677 nxt200x_writebytes(state, 0x4B, buf, 2);
678 break;
679 default:
680 return -EINVAL;
681 break;
682 }
652 683
653 /* write kg1 */ 684 /* write kg1 */
654 buf[0] = 0x00; 685 buf[0] = 0x00;
@@ -714,8 +745,19 @@ static int nxt200x_setup_frontend_parameters (struct dvb_frontend* fe,
714 /* write accumulator2 input */ 745 /* write accumulator2 input */
715 buf[0] = 0x80; 746 buf[0] = 0x80;
716 buf[1] = 0x00; 747 buf[1] = 0x00;
717 nxt200x_writebytes(state, 0x49, buf,2); 748 switch (state->demod_chip) {
718 nxt200x_writebytes(state, 0x4B, buf,2); 749 case NXT2002:
750 nxt200x_writereg_multibyte(state, 0x49, buf, 2);
751 nxt200x_writereg_multibyte(state, 0x4B, buf, 2);
752 break;
753 case NXT2004:
754 nxt200x_writebytes(state, 0x49, buf, 2);
755 nxt200x_writebytes(state, 0x4B, buf, 2);
756 break;
757 default:
758 return -EINVAL;
759 break;
760 }
719 761
720 /* write agc control reg */ 762 /* write agc control reg */
721 buf[0] = 0x04; 763 buf[0] = 0x04;
@@ -1199,7 +1241,7 @@ module_param(debug, int, 0644);
1199MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off)."); 1241MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
1200 1242
1201MODULE_DESCRIPTION("NXT200X (ATSC 8VSB & ITU-T J.83 AnnexB 64/256 QAM) Demodulator Driver"); 1243MODULE_DESCRIPTION("NXT200X (ATSC 8VSB & ITU-T J.83 AnnexB 64/256 QAM) Demodulator Driver");
1202MODULE_AUTHOR("Kirk Lapray, Jean-Francois Thibert, and Taylor Jacob"); 1244MODULE_AUTHOR("Kirk Lapray, Michael Krufky, Jean-Francois Thibert, and Taylor Jacob");
1203MODULE_LICENSE("GPL"); 1245MODULE_LICENSE("GPL");
1204 1246
1205EXPORT_SYMBOL(nxt200x_attach); 1247EXPORT_SYMBOL(nxt200x_attach);
diff --git a/drivers/media/dvb/frontends/tda80xx.c b/drivers/media/dvb/frontends/tda80xx.c
deleted file mode 100644
index d1cabb6a0a13..000000000000
--- a/drivers/media/dvb/frontends/tda80xx.c
+++ /dev/null
@@ -1,734 +0,0 @@
1/*
2 * tda80xx.c
3 *
4 * Philips TDA8044 / TDA8083 QPSK demodulator driver
5 *
6 * Copyright (C) 2001 Felix Domke <tmbinc@elitedvb.net>
7 * Copyright (C) 2002-2004 Andreas Oberritter <obi@linuxtv.org>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24#include <linux/config.h>
25#include <linux/delay.h>
26#include <linux/init.h>
27#include <linux/spinlock.h>
28#include <linux/threads.h>
29#include <linux/interrupt.h>
30#include <linux/kernel.h>
31#include <linux/module.h>
32#include <linux/slab.h>
33#include <asm/irq.h>
34#include <asm/div64.h>
35
36#include "dvb_frontend.h"
37#include "tda80xx.h"
38
39enum {
40 ID_TDA8044 = 0x04,
41 ID_TDA8083 = 0x05,
42};
43
44
45struct tda80xx_state {
46
47 struct i2c_adapter* i2c;
48
49 struct dvb_frontend_ops ops;
50
51 /* configuration settings */
52 const struct tda80xx_config* config;
53
54 struct dvb_frontend frontend;
55
56 u32 clk;
57 int afc_loop;
58 struct work_struct worklet;
59 fe_code_rate_t code_rate;
60 fe_spectral_inversion_t spectral_inversion;
61 fe_status_t status;
62 u8 id;
63};
64
65static int debug = 1;
66#define dprintk if (debug) printk
67
68static u8 tda8044_inittab_pre[] = {
69 0x02, 0x00, 0x6f, 0xb5, 0x86, 0x22, 0x00, 0xea,
70 0x30, 0x42, 0x98, 0x68, 0x70, 0x42, 0x99, 0x58,
71 0x95, 0x10, 0xf5, 0xe7, 0x93, 0x0b, 0x15, 0x68,
72 0x9a, 0x90, 0x61, 0x80, 0x00, 0xe0, 0x40, 0x00,
73 0x0f, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
74 0x00, 0x00
75};
76
77static u8 tda8044_inittab_post[] = {
78 0x04, 0x00, 0x6f, 0xb5, 0x86, 0x22, 0x00, 0xea,
79 0x30, 0x42, 0x98, 0x68, 0x70, 0x42, 0x99, 0x50,
80 0x95, 0x10, 0xf5, 0xe7, 0x93, 0x0b, 0x15, 0x68,
81 0x9a, 0x90, 0x61, 0x80, 0x00, 0xe0, 0x40, 0x6c,
82 0x0f, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
83 0x00, 0x00
84};
85
86static u8 tda8083_inittab[] = {
87 0x04, 0x00, 0x4a, 0x79, 0x04, 0x00, 0xff, 0xea,
88 0x48, 0x42, 0x79, 0x60, 0x70, 0x52, 0x9a, 0x10,
89 0x0e, 0x10, 0xf2, 0xa7, 0x93, 0x0b, 0x05, 0xc8,
90 0x9d, 0x00, 0x42, 0x80, 0x00, 0x60, 0x40, 0x00,
91 0x00, 0x75, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00,
92 0x00, 0x00, 0x00, 0x00
93};
94
95static __inline__ u32 tda80xx_div(u32 a, u32 b)
96{
97 return (a + (b / 2)) / b;
98}
99
100static __inline__ u32 tda80xx_gcd(u32 a, u32 b)
101{
102 u32 r;
103
104 while ((r = a % b)) {
105 a = b;
106 b = r;
107 }
108
109 return b;
110}
111
112static int tda80xx_read(struct tda80xx_state* state, u8 reg, u8 *buf, u8 len)
113{
114 int ret;
115 struct i2c_msg msg[] = { { .addr = state->config->demod_address, .flags = 0, .buf = &reg, .len = 1 },
116 { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = buf, .len = len } };
117
118 ret = i2c_transfer(state->i2c, msg, 2);
119
120 if (ret != 2)
121 dprintk("%s: readreg error (reg %02x, ret == %i)\n",
122 __FUNCTION__, reg, ret);
123
124 mdelay(10);
125
126 return (ret == 2) ? 0 : -EREMOTEIO;
127}
128
129static int tda80xx_write(struct tda80xx_state* state, u8 reg, const u8 *buf, u8 len)
130{
131 int ret;
132 u8 wbuf[len + 1];
133 struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = wbuf, .len = len + 1 };
134
135 wbuf[0] = reg;
136 memcpy(&wbuf[1], buf, len);
137
138 ret = i2c_transfer(state->i2c, &msg, 1);
139
140 if (ret != 1)
141 dprintk("%s: i2c xfer error (ret == %i)\n", __FUNCTION__, ret);
142
143 mdelay(10);
144
145 return (ret == 1) ? 0 : -EREMOTEIO;
146}
147
148static __inline__ u8 tda80xx_readreg(struct tda80xx_state* state, u8 reg)
149{
150 u8 val;
151
152 tda80xx_read(state, reg, &val, 1);
153
154 return val;
155}
156
157static __inline__ int tda80xx_writereg(struct tda80xx_state* state, u8 reg, u8 data)
158{
159 return tda80xx_write(state, reg, &data, 1);
160}
161
162static int tda80xx_set_parameters(struct tda80xx_state* state,
163 fe_spectral_inversion_t inversion,
164 u32 symbol_rate,
165 fe_code_rate_t fec_inner)
166{
167 u8 buf[15];
168 u64 ratio;
169 u32 clk;
170 u32 k;
171 u32 sr = symbol_rate;
172 u32 gcd;
173 u8 scd;
174
175 if (symbol_rate > (state->clk * 3) / 16)
176 scd = 0;
177 else if (symbol_rate > (state->clk * 3) / 32)
178 scd = 1;
179 else if (symbol_rate > (state->clk * 3) / 64)
180 scd = 2;
181 else
182 scd = 3;
183
184 clk = scd ? (state->clk / (scd * 2)) : state->clk;
185
186 /*
187 * Viterbi decoder:
188 * Differential decoding off
189 * Spectral inversion unknown
190 * QPSK modulation
191 */
192 if (inversion == INVERSION_ON)
193 buf[0] = 0x60;
194 else if (inversion == INVERSION_OFF)
195 buf[0] = 0x20;
196 else
197 buf[0] = 0x00;
198
199 /*
200 * CLK ratio:
201 * system clock frequency is up to 64 or 96 MHz
202 *
203 * formula:
204 * r = k * clk / symbol_rate
205 *
206 * k: 2^21 for caa 0..3,
207 * 2^20 for caa 4..5,
208 * 2^19 for caa 6..7
209 */
210 if (symbol_rate <= (clk * 3) / 32)
211 k = (1 << 19);
212 else if (symbol_rate <= (clk * 3) / 16)
213 k = (1 << 20);
214 else
215 k = (1 << 21);
216
217 gcd = tda80xx_gcd(clk, sr);
218 clk /= gcd;
219 sr /= gcd;
220
221 gcd = tda80xx_gcd(k, sr);
222 k /= gcd;
223 sr /= gcd;
224
225 ratio = (u64)k * (u64)clk;
226 do_div(ratio, sr);
227
228 buf[1] = ratio >> 16;
229 buf[2] = ratio >> 8;
230 buf[3] = ratio;
231
232 /* nyquist filter roll-off factor 35% */
233 buf[4] = 0x20;
234
235 clk = scd ? (state->clk / (scd * 2)) : state->clk;
236
237 /* Anti Alias Filter */
238 if (symbol_rate < (clk * 3) / 64)
239 printk("tda80xx: unsupported symbol rate: %u\n", symbol_rate);
240 else if (symbol_rate <= clk / 16)
241 buf[4] |= 0x07;
242 else if (symbol_rate <= (clk * 3) / 32)
243 buf[4] |= 0x06;
244 else if (symbol_rate <= clk / 8)
245 buf[4] |= 0x05;
246 else if (symbol_rate <= (clk * 3) / 16)
247 buf[4] |= 0x04;
248 else if (symbol_rate <= clk / 4)
249 buf[4] |= 0x03;
250 else if (symbol_rate <= (clk * 3) / 8)
251 buf[4] |= 0x02;
252 else if (symbol_rate <= clk / 2)
253 buf[4] |= 0x01;
254 else
255 buf[4] |= 0x00;
256
257 /* Sigma Delta converter */
258 buf[5] = 0x00;
259
260 /* FEC: Possible puncturing rates */
261 if (fec_inner == FEC_NONE)
262 buf[6] = 0x00;
263 else if ((fec_inner >= FEC_1_2) && (fec_inner <= FEC_8_9))
264 buf[6] = (1 << (8 - fec_inner));
265 else if (fec_inner == FEC_AUTO)
266 buf[6] = 0xff;
267 else
268 return -EINVAL;
269
270 /* carrier lock detector threshold value */
271 buf[7] = 0x30;
272 /* AFC1: proportional part settings */
273 buf[8] = 0x42;
274 /* AFC1: integral part settings */
275 buf[9] = 0x98;
276 /* PD: Leaky integrator SCPC mode */
277 buf[10] = 0x28;
278 /* AFC2, AFC1 controls */
279 buf[11] = 0x30;
280 /* PD: proportional part settings */
281 buf[12] = 0x42;
282 /* PD: integral part settings */
283 buf[13] = 0x99;
284 /* AGC */
285 buf[14] = 0x50 | scd;
286
287 printk("symbol_rate=%u clk=%u\n", symbol_rate, clk);
288
289 return tda80xx_write(state, 0x01, buf, sizeof(buf));
290}
291
292static int tda80xx_set_clk(struct tda80xx_state* state)
293{
294 u8 buf[2];
295
296 /* CLK proportional part */
297 buf[0] = (0x06 << 5) | 0x08; /* CMP[2:0], CSP[4:0] */
298 /* CLK integral part */
299 buf[1] = (0x04 << 5) | 0x1a; /* CMI[2:0], CSI[4:0] */
300
301 return tda80xx_write(state, 0x17, buf, sizeof(buf));
302}
303
304#if 0
305static int tda80xx_set_scpc_freq_offset(struct tda80xx_state* state)
306{
307 /* a constant value is nonsense here imho */
308 return tda80xx_writereg(state, 0x22, 0xf9);
309}
310#endif
311
312static int tda80xx_close_loop(struct tda80xx_state* state)
313{
314 u8 buf[2];
315
316 /* PD: Loop closed, LD: lock detect enable, SCPC: Sweep mode - AFC1 loop closed */
317 buf[0] = 0x68;
318 /* AFC1: Loop closed, CAR Feedback: 8192 */
319 buf[1] = 0x70;
320
321 return tda80xx_write(state, 0x0b, buf, sizeof(buf));
322}
323
324static irqreturn_t tda80xx_irq(int irq, void *priv, struct pt_regs *pt)
325{
326 schedule_work(priv);
327
328 return IRQ_HANDLED;
329}
330
331static void tda80xx_read_status_int(struct tda80xx_state* state)
332{
333 u8 val;
334
335 static const fe_spectral_inversion_t inv_tab[] = {
336 INVERSION_OFF, INVERSION_ON
337 };
338
339 static const fe_code_rate_t fec_tab[] = {
340 FEC_8_9, FEC_1_2, FEC_2_3, FEC_3_4,
341 FEC_4_5, FEC_5_6, FEC_6_7, FEC_7_8,
342 };
343
344 val = tda80xx_readreg(state, 0x02);
345
346 state->status = 0;
347
348 if (val & 0x01) /* demodulator lock */
349 state->status |= FE_HAS_SIGNAL;
350 if (val & 0x02) /* clock recovery lock */
351 state->status |= FE_HAS_CARRIER;
352 if (val & 0x04) /* viterbi lock */
353 state->status |= FE_HAS_VITERBI;
354 if (val & 0x08) /* deinterleaver lock (packet sync) */
355 state->status |= FE_HAS_SYNC;
356 if (val & 0x10) /* derandomizer lock (frame sync) */
357 state->status |= FE_HAS_LOCK;
358 if (val & 0x20) /* frontend can not lock */
359 state->status |= FE_TIMEDOUT;
360
361 if ((state->status & (FE_HAS_CARRIER)) && (state->afc_loop)) {
362 printk("tda80xx: closing loop\n");
363 tda80xx_close_loop(state);
364 state->afc_loop = 0;
365 }
366
367 if (state->status & (FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK)) {
368 val = tda80xx_readreg(state, 0x0e);
369 state->code_rate = fec_tab[val & 0x07];
370 if (state->status & (FE_HAS_SYNC | FE_HAS_LOCK))
371 state->spectral_inversion = inv_tab[(val >> 7) & 0x01];
372 else
373 state->spectral_inversion = INVERSION_AUTO;
374 }
375 else {
376 state->code_rate = FEC_AUTO;
377 }
378}
379
380static void tda80xx_worklet(void *priv)
381{
382 struct tda80xx_state *state = priv;
383
384 tda80xx_writereg(state, 0x00, 0x04);
385 enable_irq(state->config->irq);
386
387 tda80xx_read_status_int(state);
388}
389
390static void tda80xx_wait_diseqc_fifo(struct tda80xx_state* state)
391{
392 size_t i;
393
394 for (i = 0; i < 100; i++) {
395 if (tda80xx_readreg(state, 0x02) & 0x80)
396 break;
397 msleep(10);
398 }
399}
400
401static int tda8044_init(struct dvb_frontend* fe)
402{
403 struct tda80xx_state* state = fe->demodulator_priv;
404 int ret;
405
406 /*
407 * this function is a mess...
408 */
409
410 if ((ret = tda80xx_write(state, 0x00, tda8044_inittab_pre, sizeof(tda8044_inittab_pre))))
411 return ret;
412
413 tda80xx_writereg(state, 0x0f, 0x50);
414#if 1
415 tda80xx_writereg(state, 0x20, 0x8F); /* FIXME */
416 tda80xx_writereg(state, 0x20, state->config->volt18setting); /* FIXME */
417 //tda80xx_writereg(state, 0x00, 0x04);
418 tda80xx_writereg(state, 0x00, 0x0C);
419#endif
420 //tda80xx_writereg(state, 0x00, 0x08); /* Reset AFC1 loop filter */
421
422 tda80xx_write(state, 0x00, tda8044_inittab_post, sizeof(tda8044_inittab_post));
423
424 if (state->config->pll_init) {
425 tda80xx_writereg(state, 0x1c, 0x80);
426 state->config->pll_init(fe);
427 tda80xx_writereg(state, 0x1c, 0x00);
428 }
429
430 return 0;
431}
432
433static int tda8083_init(struct dvb_frontend* fe)
434{
435 struct tda80xx_state* state = fe->demodulator_priv;
436
437 tda80xx_write(state, 0x00, tda8083_inittab, sizeof(tda8083_inittab));
438
439 if (state->config->pll_init) {
440 tda80xx_writereg(state, 0x1c, 0x80);
441 state->config->pll_init(fe);
442 tda80xx_writereg(state, 0x1c, 0x00);
443 }
444
445 return 0;
446}
447
448static int tda80xx_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
449{
450 struct tda80xx_state* state = fe->demodulator_priv;
451
452 switch (voltage) {
453 case SEC_VOLTAGE_13:
454 return tda80xx_writereg(state, 0x20, state->config->volt13setting);
455 case SEC_VOLTAGE_18:
456 return tda80xx_writereg(state, 0x20, state->config->volt18setting);
457 case SEC_VOLTAGE_OFF:
458 return tda80xx_writereg(state, 0x20, 0);
459 default:
460 return -EINVAL;
461 }
462}
463
464static int tda80xx_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
465{
466 struct tda80xx_state* state = fe->demodulator_priv;
467
468 switch (tone) {
469 case SEC_TONE_OFF:
470 return tda80xx_writereg(state, 0x29, 0x00);
471 case SEC_TONE_ON:
472 return tda80xx_writereg(state, 0x29, 0x80);
473 default:
474 return -EINVAL;
475 }
476}
477
478static int tda80xx_send_diseqc_msg(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd *cmd)
479{
480 struct tda80xx_state* state = fe->demodulator_priv;
481
482 if (cmd->msg_len > 6)
483 return -EINVAL;
484
485 tda80xx_writereg(state, 0x29, 0x08 | (cmd->msg_len - 3));
486 tda80xx_write(state, 0x23, cmd->msg, cmd->msg_len);
487 tda80xx_writereg(state, 0x29, 0x0c | (cmd->msg_len - 3));
488 tda80xx_wait_diseqc_fifo(state);
489
490 return 0;
491}
492
493static int tda80xx_send_diseqc_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t cmd)
494{
495 struct tda80xx_state* state = fe->demodulator_priv;
496
497 switch (cmd) {
498 case SEC_MINI_A:
499 tda80xx_writereg(state, 0x29, 0x14);
500 break;
501 case SEC_MINI_B:
502 tda80xx_writereg(state, 0x29, 0x1c);
503 break;
504 default:
505 return -EINVAL;
506 }
507
508 tda80xx_wait_diseqc_fifo(state);
509
510 return 0;
511}
512
513static int tda80xx_sleep(struct dvb_frontend* fe)
514{
515 struct tda80xx_state* state = fe->demodulator_priv;
516
517 tda80xx_writereg(state, 0x00, 0x02); /* enter standby */
518
519 return 0;
520}
521
522static int tda80xx_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
523{
524 struct tda80xx_state* state = fe->demodulator_priv;
525
526 tda80xx_writereg(state, 0x1c, 0x80);
527 state->config->pll_set(fe, p);
528 tda80xx_writereg(state, 0x1c, 0x00);
529
530 tda80xx_set_parameters(state, p->inversion, p->u.qpsk.symbol_rate, p->u.qpsk.fec_inner);
531 tda80xx_set_clk(state);
532 //tda80xx_set_scpc_freq_offset(state);
533 state->afc_loop = 1;
534
535 return 0;
536}
537
538static int tda80xx_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
539{
540 struct tda80xx_state* state = fe->demodulator_priv;
541
542 if (!state->config->irq)
543 tda80xx_read_status_int(state);
544
545 p->inversion = state->spectral_inversion;
546 p->u.qpsk.fec_inner = state->code_rate;
547
548 return 0;
549}
550
551static int tda80xx_read_status(struct dvb_frontend* fe, fe_status_t* status)
552{
553 struct tda80xx_state* state = fe->demodulator_priv;
554
555 if (!state->config->irq)
556 tda80xx_read_status_int(state);
557 *status = state->status;
558
559 return 0;
560}
561
562static int tda80xx_read_ber(struct dvb_frontend* fe, u32* ber)
563{
564 struct tda80xx_state* state = fe->demodulator_priv;
565 int ret;
566 u8 buf[3];
567
568 if ((ret = tda80xx_read(state, 0x0b, buf, sizeof(buf))))
569 return ret;
570
571 *ber = ((buf[0] & 0x1f) << 16) | (buf[1] << 8) | buf[2];
572
573 return 0;
574}
575
576static int tda80xx_read_signal_strength(struct dvb_frontend* fe, u16* strength)
577{
578 struct tda80xx_state* state = fe->demodulator_priv;
579
580 u8 gain = ~tda80xx_readreg(state, 0x01);
581 *strength = (gain << 8) | gain;
582
583 return 0;
584}
585
586static int tda80xx_read_snr(struct dvb_frontend* fe, u16* snr)
587{
588 struct tda80xx_state* state = fe->demodulator_priv;
589
590 u8 quality = tda80xx_readreg(state, 0x08);
591 *snr = (quality << 8) | quality;
592
593 return 0;
594}
595
596static int tda80xx_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
597{
598 struct tda80xx_state* state = fe->demodulator_priv;
599
600 *ucblocks = tda80xx_readreg(state, 0x0f);
601 if (*ucblocks == 0xff)
602 *ucblocks = 0xffffffff;
603
604 return 0;
605}
606
607static int tda80xx_init(struct dvb_frontend* fe)
608{
609 struct tda80xx_state* state = fe->demodulator_priv;
610
611 switch(state->id) {
612 case ID_TDA8044:
613 return tda8044_init(fe);
614
615 case ID_TDA8083:
616 return tda8083_init(fe);
617 }
618 return 0;
619}
620
621static void tda80xx_release(struct dvb_frontend* fe)
622{
623 struct tda80xx_state* state = fe->demodulator_priv;
624
625 if (state->config->irq)
626 free_irq(state->config->irq, &state->worklet);
627
628 kfree(state);
629}
630
631static struct dvb_frontend_ops tda80xx_ops;
632
633struct dvb_frontend* tda80xx_attach(const struct tda80xx_config* config,
634 struct i2c_adapter* i2c)
635{
636 struct tda80xx_state* state = NULL;
637 int ret;
638
639 /* allocate memory for the internal state */
640 state = kmalloc(sizeof(struct tda80xx_state), GFP_KERNEL);
641 if (state == NULL) goto error;
642
643 /* setup the state */
644 state->config = config;
645 state->i2c = i2c;
646 memcpy(&state->ops, &tda80xx_ops, sizeof(struct dvb_frontend_ops));
647 state->spectral_inversion = INVERSION_AUTO;
648 state->code_rate = FEC_AUTO;
649 state->status = 0;
650 state->afc_loop = 0;
651
652 /* check if the demod is there */
653 if (tda80xx_writereg(state, 0x89, 0x00) < 0) goto error;
654 state->id = tda80xx_readreg(state, 0x00);
655
656 switch (state->id) {
657 case ID_TDA8044:
658 state->clk = 96000000;
659 printk("tda80xx: Detected tda8044\n");
660 break;
661
662 case ID_TDA8083:
663 state->clk = 64000000;
664 printk("tda80xx: Detected tda8083\n");
665 break;
666
667 default:
668 goto error;
669 }
670
671 /* setup IRQ */
672 if (state->config->irq) {
673 INIT_WORK(&state->worklet, tda80xx_worklet, state);
674 if ((ret = request_irq(state->config->irq, tda80xx_irq, SA_ONESHOT, "tda80xx", &state->worklet)) < 0) {
675 printk(KERN_ERR "tda80xx: request_irq failed (%d)\n", ret);
676 goto error;
677 }
678 }
679
680 /* create dvb_frontend */
681 state->frontend.ops = &state->ops;
682 state->frontend.demodulator_priv = state;
683 return &state->frontend;
684
685error:
686 kfree(state);
687 return NULL;
688}
689
690static struct dvb_frontend_ops tda80xx_ops = {
691
692 .info = {
693 .name = "Philips TDA80xx DVB-S",
694 .type = FE_QPSK,
695 .frequency_min = 500000,
696 .frequency_max = 2700000,
697 .frequency_stepsize = 125,
698 .symbol_rate_min = 4500000,
699 .symbol_rate_max = 45000000,
700 .caps = FE_CAN_INVERSION_AUTO |
701 FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
702 FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 |
703 FE_CAN_FEC_7_8 | FE_CAN_FEC_8_9 | FE_CAN_FEC_AUTO |
704 FE_CAN_QPSK |
705 FE_CAN_MUTE_TS
706 },
707
708 .release = tda80xx_release,
709
710 .init = tda80xx_init,
711 .sleep = tda80xx_sleep,
712
713 .set_frontend = tda80xx_set_frontend,
714 .get_frontend = tda80xx_get_frontend,
715
716 .read_status = tda80xx_read_status,
717 .read_ber = tda80xx_read_ber,
718 .read_signal_strength = tda80xx_read_signal_strength,
719 .read_snr = tda80xx_read_snr,
720 .read_ucblocks = tda80xx_read_ucblocks,
721
722 .diseqc_send_master_cmd = tda80xx_send_diseqc_msg,
723 .diseqc_send_burst = tda80xx_send_diseqc_burst,
724 .set_tone = tda80xx_set_tone,
725 .set_voltage = tda80xx_set_voltage,
726};
727
728module_param(debug, int, 0644);
729
730MODULE_DESCRIPTION("Philips TDA8044 / TDA8083 DVB-S Demodulator driver");
731MODULE_AUTHOR("Felix Domke, Andreas Oberritter");
732MODULE_LICENSE("GPL");
733
734EXPORT_SYMBOL(tda80xx_attach);
diff --git a/drivers/media/dvb/frontends/tda80xx.h b/drivers/media/dvb/frontends/tda80xx.h
deleted file mode 100644
index cd639a0aad55..000000000000
--- a/drivers/media/dvb/frontends/tda80xx.h
+++ /dev/null
@@ -1,51 +0,0 @@
1/*
2 * tda80xx.c
3 *
4 * Philips TDA8044 / TDA8083 QPSK demodulator driver
5 *
6 * Copyright (C) 2001 Felix Domke <tmbinc@elitedvb.net>
7 * Copyright (C) 2002-2004 Andreas Oberritter <obi@linuxtv.org>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24#ifndef TDA80XX_H
25#define TDA80XX_H
26
27#include <linux/dvb/frontend.h>
28
29struct tda80xx_config
30{
31 /* the demodulator's i2c address */
32 u8 demod_address;
33
34 /* IRQ to use (0=>no IRQ used) */
35 u32 irq;
36
37 /* Register setting to use for 13v */
38 u8 volt13setting;
39
40 /* Register setting to use for 18v */
41 u8 volt18setting;
42
43 /* PLL maintenance */
44 int (*pll_init)(struct dvb_frontend* fe);
45 int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
46};
47
48extern struct dvb_frontend* tda80xx_attach(const struct tda80xx_config* config,
49 struct i2c_adapter* i2c);
50
51#endif // TDA80XX_H
diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c
index 27494901975f..d36369e9e88f 100644
--- a/drivers/media/dvb/ttpci/av7110.c
+++ b/drivers/media/dvb/ttpci/av7110.c
@@ -2329,6 +2329,17 @@ static int frontend_init(struct av7110 *av7110)
2329 av7110->fe = ves1820_attach(&alps_tdbe2_config, &av7110->i2c_adap, read_pwm(av7110)); 2329 av7110->fe = ves1820_attach(&alps_tdbe2_config, &av7110->i2c_adap, read_pwm(av7110));
2330 break; 2330 break;
2331 2331
2332 case 0x0004: // Galaxis DVB-S rev1.3
2333 /* ALPS BSRV2 */
2334 av7110->fe = ves1x93_attach(&alps_bsrv2_config, &av7110->i2c_adap);
2335 if (av7110->fe) {
2336 av7110->fe->ops->diseqc_send_master_cmd = av7110_diseqc_send_master_cmd;
2337 av7110->fe->ops->diseqc_send_burst = av7110_diseqc_send_burst;
2338 av7110->fe->ops->set_tone = av7110_set_tone;
2339 av7110->recover = dvb_s_recover;
2340 }
2341 break;
2342
2332 case 0x0006: /* Fujitsu-Siemens DVB-S rev 1.6 */ 2343 case 0x0006: /* Fujitsu-Siemens DVB-S rev 1.6 */
2333 /* Grundig 29504-451 */ 2344 /* Grundig 29504-451 */
2334 av7110->fe = tda8083_attach(&grundig_29504_451_config, &av7110->i2c_adap); 2345 av7110->fe = tda8083_attach(&grundig_29504_451_config, &av7110->i2c_adap);
@@ -2930,6 +2941,7 @@ MAKE_AV7110_INFO(tts_1_3se, "Technotrend/Hauppauge WinTV DVB-S rev1.3 SE");
2930MAKE_AV7110_INFO(ttt, "Technotrend/Hauppauge DVB-T"); 2941MAKE_AV7110_INFO(ttt, "Technotrend/Hauppauge DVB-T");
2931MAKE_AV7110_INFO(fsc, "Fujitsu Siemens DVB-C"); 2942MAKE_AV7110_INFO(fsc, "Fujitsu Siemens DVB-C");
2932MAKE_AV7110_INFO(fss, "Fujitsu Siemens DVB-S rev1.6"); 2943MAKE_AV7110_INFO(fss, "Fujitsu Siemens DVB-S rev1.6");
2944MAKE_AV7110_INFO(gxs_1_3, "Galaxis DVB-S rev1.3");
2933 2945
2934static struct pci_device_id pci_tbl[] = { 2946static struct pci_device_id pci_tbl[] = {
2935 MAKE_EXTENSION_PCI(fsc, 0x110a, 0x0000), 2947 MAKE_EXTENSION_PCI(fsc, 0x110a, 0x0000),
@@ -2937,13 +2949,13 @@ static struct pci_device_id pci_tbl[] = {
2937 MAKE_EXTENSION_PCI(ttt_1_X, 0x13c2, 0x0001), 2949 MAKE_EXTENSION_PCI(ttt_1_X, 0x13c2, 0x0001),
2938 MAKE_EXTENSION_PCI(ttc_2_X, 0x13c2, 0x0002), 2950 MAKE_EXTENSION_PCI(ttc_2_X, 0x13c2, 0x0002),
2939 MAKE_EXTENSION_PCI(tts_2_X, 0x13c2, 0x0003), 2951 MAKE_EXTENSION_PCI(tts_2_X, 0x13c2, 0x0003),
2952 MAKE_EXTENSION_PCI(gxs_1_3, 0x13c2, 0x0004),
2940 MAKE_EXTENSION_PCI(fss, 0x13c2, 0x0006), 2953 MAKE_EXTENSION_PCI(fss, 0x13c2, 0x0006),
2941 MAKE_EXTENSION_PCI(ttt, 0x13c2, 0x0008), 2954 MAKE_EXTENSION_PCI(ttt, 0x13c2, 0x0008),
2942 MAKE_EXTENSION_PCI(ttc_1_X, 0x13c2, 0x000a), 2955 MAKE_EXTENSION_PCI(ttc_1_X, 0x13c2, 0x000a),
2943 MAKE_EXTENSION_PCI(tts_2_3, 0x13c2, 0x000e), 2956 MAKE_EXTENSION_PCI(tts_2_3, 0x13c2, 0x000e),
2944 MAKE_EXTENSION_PCI(tts_1_3se, 0x13c2, 0x1002), 2957 MAKE_EXTENSION_PCI(tts_1_3se, 0x13c2, 0x1002),
2945 2958
2946/* MAKE_EXTENSION_PCI(???, 0x13c2, 0x0004), UNDEFINED CARD */ // Galaxis DVB PC-Sat-Carte
2947/* MAKE_EXTENSION_PCI(???, 0x13c2, 0x0005), UNDEFINED CARD */ // Technisat SkyStar1 2959/* MAKE_EXTENSION_PCI(???, 0x13c2, 0x0005), UNDEFINED CARD */ // Technisat SkyStar1
2948/* MAKE_EXTENSION_PCI(???, 0x13c2, 0x0009), UNDEFINED CARD */ // TT/Hauppauge WinTV Nexus-CA v???? 2960/* MAKE_EXTENSION_PCI(???, 0x13c2, 0x0009), UNDEFINED CARD */ // TT/Hauppauge WinTV Nexus-CA v????
2949 2961
diff --git a/drivers/media/dvb/ttpci/av7110.h b/drivers/media/dvb/ttpci/av7110.h
index 6ea30df2e823..fafd25fab835 100644
--- a/drivers/media/dvb/ttpci/av7110.h
+++ b/drivers/media/dvb/ttpci/av7110.h
@@ -273,8 +273,6 @@ struct av7110 {
273extern int ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid, 273extern int ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid,
274 u16 subpid, u16 pcrpid); 274 u16 subpid, u16 pcrpid);
275 275
276extern int av7110_setup_irc_config (struct av7110 *av7110, u32 ir_config);
277
278extern int av7110_ir_init(struct av7110 *av7110); 276extern int av7110_ir_init(struct av7110 *av7110);
279extern void av7110_ir_exit(struct av7110 *av7110); 277extern void av7110_ir_exit(struct av7110 *av7110);
280 278
diff --git a/drivers/media/dvb/ttpci/av7110_ir.c b/drivers/media/dvb/ttpci/av7110_ir.c
index 9138132ad25f..617e4f6c0ed7 100644
--- a/drivers/media/dvb/ttpci/av7110_ir.c
+++ b/drivers/media/dvb/ttpci/av7110_ir.c
@@ -155,6 +155,19 @@ static void input_repeat_key(unsigned long data)
155} 155}
156 156
157 157
158static int av7110_setup_irc_config(struct av7110 *av7110, u32 ir_config)
159{
160 int ret = 0;
161
162 dprintk(4, "%p\n", av7110);
163 if (av7110) {
164 ret = av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, SetIR, 1, ir_config);
165 av7110->ir_config = ir_config;
166 }
167 return ret;
168}
169
170
158static int av7110_ir_write_proc(struct file *file, const char __user *buffer, 171static int av7110_ir_write_proc(struct file *file, const char __user *buffer,
159 unsigned long count, void *data) 172 unsigned long count, void *data)
160{ 173{
@@ -187,19 +200,6 @@ static int av7110_ir_write_proc(struct file *file, const char __user *buffer,
187} 200}
188 201
189 202
190int av7110_setup_irc_config(struct av7110 *av7110, u32 ir_config)
191{
192 int ret = 0;
193
194 dprintk(4, "%p\n", av7110);
195 if (av7110) {
196 ret = av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, SetIR, 1, ir_config);
197 av7110->ir_config = ir_config;
198 }
199 return ret;
200}
201
202
203static void ir_handler(struct av7110 *av7110, u32 ircom) 203static void ir_handler(struct av7110 *av7110, u32 ircom)
204{ 204{
205 dprintk(4, "ircommand = %08x\n", ircom); 205 dprintk(4, "ircommand = %08x\n", ircom);
diff --git a/drivers/media/video/bttv-driver.c b/drivers/media/video/bttv-driver.c
index aa4c4c521880..578b20085082 100644
--- a/drivers/media/video/bttv-driver.c
+++ b/drivers/media/video/bttv-driver.c
@@ -214,7 +214,7 @@ const struct bttv_tvnorm bttv_tvnorms[] = {
214 we can capture, of the first and second field. */ 214 we can capture, of the first and second field. */
215 .vbistart = { 7,320 }, 215 .vbistart = { 7,320 },
216 },{ 216 },{
217 .v4l2_id = V4L2_STD_NTSC_M, 217 .v4l2_id = V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_KR,
218 .name = "NTSC", 218 .name = "NTSC",
219 .Fsc = 28636363, 219 .Fsc = 28636363,
220 .swidth = 768, 220 .swidth = 768,
diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c
index c66c2c1f4809..08ffd1f325fc 100644
--- a/drivers/media/video/cx25840/cx25840-core.c
+++ b/drivers/media/video/cx25840/cx25840-core.c
@@ -220,33 +220,23 @@ static void input_change(struct i2c_client *client)
220 cx25840_write(client, 0x808, 0xff); 220 cx25840_write(client, 0x808, 0xff);
221 cx25840_write(client, 0x80b, 0x10); 221 cx25840_write(client, 0x80b, 0x10);
222 } else if (std & V4L2_STD_NTSC) { 222 } else if (std & V4L2_STD_NTSC) {
223 /* NTSC */ 223 /* Certain Hauppauge PVR150 models have a hardware bug
224 if (state->pvr150_workaround) { 224 that causes audio to drop out. For these models the
225 /* Certain Hauppauge PVR150 models have a hardware bug 225 audio standard must be set explicitly.
226 that causes audio to drop out. For these models the 226 To be precise: it affects cards with tuner models
227 audio standard must be set explicitly. 227 85, 99 and 112 (model numbers from tveeprom). */
228 To be precise: it affects cards with tuner models 228 int hw_fix = state->pvr150_workaround;
229 85, 99 and 112 (model numbers from tveeprom). */ 229
230 if (std == V4L2_STD_NTSC_M_JP) { 230 if (std == V4L2_STD_NTSC_M_JP) {
231 /* Japan uses EIAJ audio standard */
232 cx25840_write(client, 0x808, 0x2f);
233 } else {
234 /* Others use the BTSC audio standard */
235 cx25840_write(client, 0x808, 0x1f);
236 }
237 /* South Korea uses the A2-M (aka Zweiton M) audio
238 standard, and should set 0x808 to 0x3f, but I don't
239 know how to detect this. */
240 } else if (std == V4L2_STD_NTSC_M_JP) {
241 /* Japan uses EIAJ audio standard */ 231 /* Japan uses EIAJ audio standard */
242 cx25840_write(client, 0x808, 0xf7); 232 cx25840_write(client, 0x808, hw_fix ? 0x2f : 0xf7);
233 } else if (std == V4L2_STD_NTSC_M_KR) {
234 /* South Korea uses A2 audio standard */
235 cx25840_write(client, 0x808, hw_fix ? 0x3f : 0xf8);
243 } else { 236 } else {
244 /* Others use the BTSC audio standard */ 237 /* Others use the BTSC audio standard */
245 cx25840_write(client, 0x808, 0xf6); 238 cx25840_write(client, 0x808, hw_fix ? 0x1f : 0xf6);
246 } 239 }
247 /* South Korea uses the A2-M (aka Zweiton M) audio standard,
248 and should set 0x808 to 0xf8, but I don't know how to
249 detect this. */
250 cx25840_write(client, 0x80b, 0x00); 240 cx25840_write(client, 0x80b, 0x00);
251 } 241 }
252 242
@@ -330,17 +320,17 @@ static int set_v4lstd(struct i2c_client *client, v4l2_std_id std)
330 u8 fmt=0; /* zero is autodetect */ 320 u8 fmt=0; /* zero is autodetect */
331 321
332 /* First tests should be against specific std */ 322 /* First tests should be against specific std */
333 if (std & V4L2_STD_NTSC_M_JP) { 323 if (std == V4L2_STD_NTSC_M_JP) {
334 fmt=0x2; 324 fmt=0x2;
335 } else if (std & V4L2_STD_NTSC_443) { 325 } else if (std == V4L2_STD_NTSC_443) {
336 fmt=0x3; 326 fmt=0x3;
337 } else if (std & V4L2_STD_PAL_M) { 327 } else if (std == V4L2_STD_PAL_M) {
338 fmt=0x5; 328 fmt=0x5;
339 } else if (std & V4L2_STD_PAL_N) { 329 } else if (std == V4L2_STD_PAL_N) {
340 fmt=0x6; 330 fmt=0x6;
341 } else if (std & V4L2_STD_PAL_Nc) { 331 } else if (std == V4L2_STD_PAL_Nc) {
342 fmt=0x7; 332 fmt=0x7;
343 } else if (std & V4L2_STD_PAL_60) { 333 } else if (std == V4L2_STD_PAL_60) {
344 fmt=0x8; 334 fmt=0x8;
345 } else { 335 } else {
346 /* Then, test against generic ones */ 336 /* Then, test against generic ones */
@@ -369,7 +359,7 @@ v4l2_std_id cx25840_get_v4lstd(struct i2c_client * client)
369 } 359 }
370 360
371 switch (fmt) { 361 switch (fmt) {
372 case 0x1: return V4L2_STD_NTSC_M; 362 case 0x1: return V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_KR;
373 case 0x2: return V4L2_STD_NTSC_M_JP; 363 case 0x2: return V4L2_STD_NTSC_M_JP;
374 case 0x3: return V4L2_STD_NTSC_443; 364 case 0x3: return V4L2_STD_NTSC_443;
375 case 0x4: return V4L2_STD_PAL; 365 case 0x4: return V4L2_STD_PAL;
diff --git a/drivers/media/video/cx88/Kconfig b/drivers/media/video/cx88/Kconfig
index 53308911ae6e..e99dfbbf3e95 100644
--- a/drivers/media/video/cx88/Kconfig
+++ b/drivers/media/video/cx88/Kconfig
@@ -32,6 +32,7 @@ config VIDEO_CX88_DVB
32config VIDEO_CX88_ALSA 32config VIDEO_CX88_ALSA
33 tristate "ALSA DMA audio support" 33 tristate "ALSA DMA audio support"
34 depends on VIDEO_CX88 && SND && EXPERIMENTAL 34 depends on VIDEO_CX88 && SND && EXPERIMENTAL
35 select SND_PCM
35 ---help--- 36 ---help---
36 This is a video4linux driver for direct (DMA) audio on 37 This is a video4linux driver for direct (DMA) audio on
37 Conexant 2388x based TV cards. 38 Conexant 2388x based TV cards.
@@ -48,6 +49,7 @@ config VIDEO_CX88_DVB_ALL_FRONTENDS
48 default y 49 default y
49 depends on VIDEO_CX88_DVB 50 depends on VIDEO_CX88_DVB
50 select DVB_MT352 51 select DVB_MT352
52 select VIDEO_CX88_VP3054
51 select DVB_OR51132 53 select DVB_OR51132
52 select DVB_CX22702 54 select DVB_CX22702
53 select DVB_LGDT330X 55 select DVB_LGDT330X
@@ -69,6 +71,16 @@ config VIDEO_CX88_DVB_MT352
69 This adds DVB-T support for cards based on the 71 This adds DVB-T support for cards based on the
70 Connexant 2388x chip and the MT352 demodulator. 72 Connexant 2388x chip and the MT352 demodulator.
71 73
74config VIDEO_CX88_VP3054
75 tristate "VP-3054 Secondary I2C Bus Support"
76 default m
77 depends on DVB_MT352
78 ---help---
79 This adds DVB-T support for cards based on the
80 Connexant 2388x chip and the MT352 demodulator,
81 which also require support for the VP-3054
82 Secondary I2C bus, such at DNTV Live! DVB-T Pro.
83
72config VIDEO_CX88_DVB_OR51132 84config VIDEO_CX88_DVB_OR51132
73 bool "OR51132 ATSC Support" 85 bool "OR51132 ATSC Support"
74 default y 86 default y
diff --git a/drivers/media/video/cx88/Makefile b/drivers/media/video/cx88/Makefile
index 6e5eaa22619e..2b902784facc 100644
--- a/drivers/media/video/cx88/Makefile
+++ b/drivers/media/video/cx88/Makefile
@@ -4,8 +4,9 @@ cx8800-objs := cx88-video.o cx88-vbi.o
4cx8802-objs := cx88-mpeg.o 4cx8802-objs := cx88-mpeg.o
5 5
6obj-$(CONFIG_VIDEO_CX88) += cx88xx.o cx8800.o cx8802.o cx88-blackbird.o 6obj-$(CONFIG_VIDEO_CX88) += cx88xx.o cx8800.o cx8802.o cx88-blackbird.o
7obj-$(CONFIG_VIDEO_CX88_DVB) += cx88-dvb.o cx88-vp3054-i2c.o 7obj-$(CONFIG_VIDEO_CX88_DVB) += cx88-dvb.o
8obj-$(CONFIG_VIDEO_CX88_ALSA) += cx88-alsa.o 8obj-$(CONFIG_VIDEO_CX88_ALSA) += cx88-alsa.o
9obj-$(CONFIG_VIDEO_CX88_VP3054) += cx88-vp3054-i2c.o
9 10
10EXTRA_CFLAGS += -I$(src)/.. 11EXTRA_CFLAGS += -I$(src)/..
11EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/dvb-core 12EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/dvb-core
@@ -18,6 +19,6 @@ extra-cflags-$(CONFIG_DVB_LGDT330X) += -DHAVE_LGDT330X=1
18extra-cflags-$(CONFIG_DVB_MT352) += -DHAVE_MT352=1 19extra-cflags-$(CONFIG_DVB_MT352) += -DHAVE_MT352=1
19extra-cflags-$(CONFIG_DVB_NXT200X) += -DHAVE_NXT200X=1 20extra-cflags-$(CONFIG_DVB_NXT200X) += -DHAVE_NXT200X=1
20extra-cflags-$(CONFIG_DVB_CX24123) += -DHAVE_CX24123=1 21extra-cflags-$(CONFIG_DVB_CX24123) += -DHAVE_CX24123=1
21extra-cflags-$(CONFIG_VIDEO_CX88_DVB)+= -DHAVE_VP3054_I2C=1 22extra-cflags-$(CONFIG_VIDEO_CX88_VP3054)+= -DHAVE_VP3054_I2C=1
22 23
23EXTRA_CFLAGS += $(extra-cflags-y) $(extra-cflags-m) 24EXTRA_CFLAGS += $(extra-cflags-y) $(extra-cflags-m)
diff --git a/drivers/media/video/cx88/cx88-alsa.c b/drivers/media/video/cx88/cx88-alsa.c
index a2e36a1e5f59..2acccd6d49bc 100644
--- a/drivers/media/video/cx88/cx88-alsa.c
+++ b/drivers/media/video/cx88/cx88-alsa.c
@@ -128,7 +128,7 @@ MODULE_PARM_DESC(debug,"enable debug messages");
128 * BOARD Specific: Sets audio DMA 128 * BOARD Specific: Sets audio DMA
129 */ 129 */
130 130
131int _cx88_start_audio_dma(snd_cx88_card_t *chip) 131static int _cx88_start_audio_dma(snd_cx88_card_t *chip)
132{ 132{
133 struct cx88_buffer *buf = chip->buf; 133 struct cx88_buffer *buf = chip->buf;
134 struct cx88_core *core=chip->core; 134 struct cx88_core *core=chip->core;
@@ -173,7 +173,7 @@ int _cx88_start_audio_dma(snd_cx88_card_t *chip)
173/* 173/*
174 * BOARD Specific: Resets audio DMA 174 * BOARD Specific: Resets audio DMA
175 */ 175 */
176int _cx88_stop_audio_dma(snd_cx88_card_t *chip) 176static int _cx88_stop_audio_dma(snd_cx88_card_t *chip)
177{ 177{
178 struct cx88_core *core=chip->core; 178 struct cx88_core *core=chip->core;
179 dprintk(1, "Stopping audio DMA\n"); 179 dprintk(1, "Stopping audio DMA\n");
@@ -613,7 +613,7 @@ static snd_kcontrol_new_t snd_cx88_capture_volume = {
613 * Only boards with eeprom and byte 1 at eeprom=1 have it 613 * Only boards with eeprom and byte 1 at eeprom=1 have it
614 */ 614 */
615 615
616struct pci_device_id cx88_audio_pci_tbl[] = { 616static struct pci_device_id cx88_audio_pci_tbl[] = {
617 {0x14f1,0x8801,PCI_ANY_ID,PCI_ANY_ID,0,0,0}, 617 {0x14f1,0x8801,PCI_ANY_ID,PCI_ANY_ID,0,0,0},
618 {0x14f1,0x8811,PCI_ANY_ID,PCI_ANY_ID,0,0,0}, 618 {0x14f1,0x8811,PCI_ANY_ID,PCI_ANY_ID,0,0,0},
619 {0, } 619 {0, }
diff --git a/drivers/media/video/cx88/cx88-cards.c b/drivers/media/video/cx88/cx88-cards.c
index ad2f565f522c..1bc999247fdc 100644
--- a/drivers/media/video/cx88/cx88-cards.c
+++ b/drivers/media/video/cx88/cx88-cards.c
@@ -1246,6 +1246,11 @@ struct cx88_subid cx88_subids[] = {
1246 .card = CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL, 1246 .card = CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL,
1247 },{ 1247 },{
1248 .subvendor = 0x18ac, 1248 .subvendor = 0x18ac,
1249 .subdevice = 0xdb54,
1250 .card = CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL,
1251 /* Re-branded DViCO: DigitalNow DVB-T Dual */
1252 },{
1253 .subvendor = 0x18ac,
1249 .subdevice = 0xdb11, 1254 .subdevice = 0xdb11,
1250 .card = CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS, 1255 .card = CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS,
1251 /* Re-branded DViCO: UltraView DVB-T Plus */ 1256 /* Re-branded DViCO: UltraView DVB-T Plus */
@@ -1293,6 +1298,7 @@ static void hauppauge_eeprom(struct cx88_core *core, u8 *eeprom_data)
1293 switch (tv.model) 1298 switch (tv.model)
1294 { 1299 {
1295 case 28552: /* WinTV-PVR 'Roslyn' (No IR) */ 1300 case 28552: /* WinTV-PVR 'Roslyn' (No IR) */
1301 case 34519: /* WinTV-PCI-FM */
1296 case 90002: /* Nova-T-PCI (9002) */ 1302 case 90002: /* Nova-T-PCI (9002) */
1297 case 92001: /* Nova-S-Plus (Video and IR) */ 1303 case 92001: /* Nova-S-Plus (Video and IR) */
1298 case 92002: /* Nova-S-Plus (Video and IR) */ 1304 case 92002: /* Nova-S-Plus (Video and IR) */
diff --git a/drivers/media/video/cx88/cx88-core.c b/drivers/media/video/cx88/cx88-core.c
index 8d6d6a6cf785..3720f24a25cf 100644
--- a/drivers/media/video/cx88/cx88-core.c
+++ b/drivers/media/video/cx88/cx88-core.c
@@ -787,12 +787,14 @@ static int set_pll(struct cx88_core *core, int prescale, u32 ofreq)
787 787
788int cx88_start_audio_dma(struct cx88_core *core) 788int cx88_start_audio_dma(struct cx88_core *core)
789{ 789{
790 /* constant 128 made buzz in analog Nicam-stereo for bigger fifo_size */
791 int bpl = cx88_sram_channels[SRAM_CH25].fifo_size/4;
790 /* setup fifo + format */ 792 /* setup fifo + format */
791 cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH25], 128, 0); 793 cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH25], bpl, 0);
792 cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH26], 128, 0); 794 cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH26], bpl, 0);
793 795
794 cx_write(MO_AUDD_LNGTH, 128); /* fifo bpl size */ 796 cx_write(MO_AUDD_LNGTH, bpl); /* fifo bpl size */
795 cx_write(MO_AUDR_LNGTH, 128); /* fifo bpl size */ 797 cx_write(MO_AUDR_LNGTH, bpl); /* fifo bpl size */
796 798
797 /* start dma */ 799 /* start dma */
798 cx_write(MO_AUD_DMACNTRL, 0x0003); /* Up and Down fifo enable */ 800 cx_write(MO_AUD_DMACNTRL, 0x0003); /* Up and Down fifo enable */
diff --git a/drivers/media/video/cx88/cx88-input.c b/drivers/media/video/cx88/cx88-input.c
index da2ad5c4b553..165d948624a3 100644
--- a/drivers/media/video/cx88/cx88-input.c
+++ b/drivers/media/video/cx88/cx88-input.c
@@ -482,6 +482,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
482 switch (core->board) { 482 switch (core->board) {
483 case CX88_BOARD_DNTV_LIVE_DVB_T: 483 case CX88_BOARD_DNTV_LIVE_DVB_T:
484 case CX88_BOARD_KWORLD_DVB_T: 484 case CX88_BOARD_KWORLD_DVB_T:
485 case CX88_BOARD_KWORLD_DVB_T_CX22702:
485 ir_codes = ir_codes_dntv_live_dvb_t; 486 ir_codes = ir_codes_dntv_live_dvb_t;
486 ir->gpio_addr = MO_GP1_IO; 487 ir->gpio_addr = MO_GP1_IO;
487 ir->mask_keycode = 0x1f; 488 ir->mask_keycode = 0x1f;
diff --git a/drivers/media/video/em28xx/em28xx-core.c b/drivers/media/video/em28xx/em28xx-core.c
index dff3893f32fd..e5ee8bceb210 100644
--- a/drivers/media/video/em28xx/em28xx-core.c
+++ b/drivers/media/video/em28xx/em28xx-core.c
@@ -139,6 +139,9 @@ int em28xx_read_reg_req_len(struct em28xx *dev, u8 req, u16 reg,
139{ 139{
140 int ret, byte; 140 int ret, byte;
141 141
142 if (dev->state & DEV_DISCONNECTED)
143 return(-ENODEV);
144
142 em28xx_regdbg("req=%02x, reg=%02x ", req, reg); 145 em28xx_regdbg("req=%02x, reg=%02x ", req, reg);
143 146
144 ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), req, 147 ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), req,
@@ -165,6 +168,9 @@ int em28xx_read_reg_req(struct em28xx *dev, u8 req, u16 reg)
165 u8 val; 168 u8 val;
166 int ret; 169 int ret;
167 170
171 if (dev->state & DEV_DISCONNECTED)
172 return(-ENODEV);
173
168 em28xx_regdbg("req=%02x, reg=%02x:", req, reg); 174 em28xx_regdbg("req=%02x, reg=%02x:", req, reg);
169 175
170 ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), req, 176 ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), req,
@@ -195,7 +201,12 @@ int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf,
195 int ret; 201 int ret;
196 202
197 /*usb_control_msg seems to expect a kmalloced buffer */ 203 /*usb_control_msg seems to expect a kmalloced buffer */
198 unsigned char *bufs = kmalloc(len, GFP_KERNEL); 204 unsigned char *bufs;
205
206 if (dev->state & DEV_DISCONNECTED)
207 return(-ENODEV);
208
209 bufs = kmalloc(len, GFP_KERNEL);
199 210
200 em28xx_regdbg("req=%02x reg=%02x:", req, reg); 211 em28xx_regdbg("req=%02x reg=%02x:", req, reg);
201 212
@@ -212,7 +223,7 @@ int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf,
212 ret = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), req, 223 ret = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), req,
213 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 224 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
214 0x0000, reg, bufs, len, HZ); 225 0x0000, reg, bufs, len, HZ);
215 mdelay(5); /* FIXME: magic number */ 226 msleep(5); /* FIXME: magic number */
216 kfree(bufs); 227 kfree(bufs);
217 return ret; 228 return ret;
218} 229}
@@ -253,7 +264,7 @@ int em28xx_write_ac97(struct em28xx *dev, u8 reg, u8 * val)
253 if ((ret = em28xx_read_reg(dev, AC97BUSY_REG)) < 0) 264 if ((ret = em28xx_read_reg(dev, AC97BUSY_REG)) < 0)
254 return ret; 265 return ret;
255 else if (((u8) ret) & 0x01) { 266 else if (((u8) ret) & 0x01) {
256 em28xx_warn ("AC97 command still being exectuted: not handled properly!\n"); 267 em28xx_warn ("AC97 command still being executed: not handled properly!\n");
257 } 268 }
258 return 0; 269 return 0;
259} 270}
diff --git a/drivers/media/video/em28xx/em28xx-i2c.c b/drivers/media/video/em28xx/em28xx-i2c.c
index 0591a705b7a1..6ca8631bc36d 100644
--- a/drivers/media/video/em28xx/em28xx-i2c.c
+++ b/drivers/media/video/em28xx/em28xx-i2c.c
@@ -78,7 +78,7 @@ static int em2800_i2c_send_max4(struct em28xx *dev, unsigned char addr,
78 ret = dev->em28xx_read_reg(dev, 0x05); 78 ret = dev->em28xx_read_reg(dev, 0x05);
79 if (ret == 0x80 + len - 1) 79 if (ret == 0x80 + len - 1)
80 return len; 80 return len;
81 mdelay(5); 81 msleep(5);
82 } 82 }
83 em28xx_warn("i2c write timed out\n"); 83 em28xx_warn("i2c write timed out\n");
84 return -EIO; 84 return -EIO;
@@ -138,7 +138,7 @@ static int em2800_i2c_check_for_device(struct em28xx *dev, unsigned char addr)
138 return -ENODEV; 138 return -ENODEV;
139 else if (msg == 0x84) 139 else if (msg == 0x84)
140 return 0; 140 return 0;
141 mdelay(5); 141 msleep(5);
142 } 142 }
143 return -ENODEV; 143 return -ENODEV;
144} 144}
@@ -278,9 +278,9 @@ static int em28xx_i2c_xfer(struct i2c_adapter *i2c_adap,
278 msgs[i].buf, 278 msgs[i].buf,
279 msgs[i].len, 279 msgs[i].len,
280 i == num - 1); 280 i == num - 1);
281 if (rc < 0)
282 goto err;
283 } 281 }
282 if (rc < 0)
283 goto err;
284 if (i2c_debug>=2) 284 if (i2c_debug>=2)
285 printk("\n"); 285 printk("\n");
286 } 286 }
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index eea304f75176..94a14a2bb6d6 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -6,6 +6,9 @@
6 Mauro Carvalho Chehab <mchehab@brturbo.com.br> 6 Mauro Carvalho Chehab <mchehab@brturbo.com.br>
7 Sascha Sommer <saschasommer@freenet.de> 7 Sascha Sommer <saschasommer@freenet.de>
8 8
9 Some parts based on SN9C10x PC Camera Controllers GPL driver made
10 by Luca Risolia <luca.risolia@studio.unibo.it>
11
9 This program is free software; you can redistribute it and/or modify 12 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by 13 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or 14 the Free Software Foundation; either version 2 of the License, or
diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c
index c64718aec9cb..5a35d3b6550d 100644
--- a/drivers/media/video/saa7134/saa7134-cards.c
+++ b/drivers/media/video/saa7134/saa7134-cards.c
@@ -136,7 +136,7 @@ struct saa7134_board saa7134_boards[] = {
136 }, 136 },
137 [SAA7134_BOARD_FLYVIDEO2000] = { 137 [SAA7134_BOARD_FLYVIDEO2000] = {
138 /* "TC Wan" <tcwan@cs.usm.my> */ 138 /* "TC Wan" <tcwan@cs.usm.my> */
139 .name = "LifeView FlyVIDEO2000", 139 .name = "LifeView/Typhoon FlyVIDEO2000",
140 .audio_clock = 0x00200000, 140 .audio_clock = 0x00200000,
141 .tuner_type = TUNER_LG_PAL_NEW_TAPC, 141 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
142 .radio_type = UNSET, 142 .radio_type = UNSET,
@@ -1884,44 +1884,38 @@ struct saa7134_board saa7134_boards[] = {
1884 .gpio = 0x000, 1884 .gpio = 0x000,
1885 }, 1885 },
1886 }, 1886 },
1887 [SAA7134_BOARD_THYPHOON_DVBT_DUO_CARDBUS] = { 1887 [SAA7134_BOARD_FLYDVBT_DUO_CARDBUS] = {
1888 .name = "Typhoon DVB-T Duo Digital/Analog Cardbus", 1888 .name = "LifeView/Typhoon FlyDVB-T Duo Cardbus",
1889 .audio_clock = 0x00200000, 1889 .audio_clock = 0x00200000,
1890 .tuner_type = TUNER_PHILIPS_TDA8290, 1890 .tuner_type = TUNER_PHILIPS_TDA8290,
1891 .radio_type = UNSET, 1891 .radio_type = UNSET,
1892 .tuner_addr = ADDR_UNSET, 1892 .tuner_addr = ADDR_UNSET,
1893 .radio_addr = ADDR_UNSET, 1893 .radio_addr = ADDR_UNSET,
1894 .mpeg = SAA7134_MPEG_DVB, 1894 .mpeg = SAA7134_MPEG_DVB,
1895 /* .gpiomask = 0xe000, */ 1895 .gpiomask = 0x00200000,
1896 .inputs = {{ 1896 .inputs = {{
1897 .name = name_tv, 1897 .name = name_tv,
1898 .vmux = 1, 1898 .vmux = 1,
1899 .amux = TV, 1899 .amux = TV,
1900 /* .gpio = 0x0000, */ 1900 .gpio = 0x200000, /* GPIO21=High for TV input */
1901 .tv = 1, 1901 .tv = 1,
1902 },{ 1902 },{
1903 .name = name_svideo, /* S-Video signal on S-Video input */
1904 .vmux = 8,
1905 .amux = LINE2,
1906 },{
1903 .name = name_comp1, /* Composite signal on S-Video input */ 1907 .name = name_comp1, /* Composite signal on S-Video input */
1904 .vmux = 0, 1908 .vmux = 0,
1905 .amux = LINE2, 1909 .amux = LINE2,
1906 /* .gpio = 0x4000, */
1907 },{ 1910 },{
1908 .name = name_comp2, /* Composite input */ 1911 .name = name_comp2, /* Composite input */
1909 .vmux = 3, 1912 .vmux = 3,
1910 .amux = LINE2, 1913 .amux = LINE2,
1911 /* .gpio = 0x4000, */
1912 },{
1913 .name = name_svideo, /* S-Video signal on S-Video input */
1914 .vmux = 8,
1915 .amux = LINE2,
1916 /* .gpio = 0x4000, */
1917 }}, 1914 }},
1918 .radio = { 1915 .radio = {
1919 .name = name_radio, 1916 .name = name_radio,
1920 .amux = LINE2, 1917 .amux = TV,
1921 }, 1918 .gpio = 0x000000, /* GPIO21=Low for FM radio antenna */
1922 .mute = {
1923 .name = name_mute,
1924 .amux = LINE1,
1925 }, 1919 },
1926 }, 1920 },
1927 [SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUSII] = { 1921 [SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUSII] = {
@@ -2701,6 +2695,12 @@ struct pci_device_id saa7134_pci_tbl[] = {
2701 .driver_data = SAA7134_BOARD_FLYVIDEO2000, 2695 .driver_data = SAA7134_BOARD_FLYVIDEO2000,
2702 },{ 2696 },{
2703 .vendor = PCI_VENDOR_ID_PHILIPS, 2697 .vendor = PCI_VENDOR_ID_PHILIPS,
2698 .device = PCI_DEVICE_ID_PHILIPS_SAA7130,
2699 .subvendor = 0x4e42, /* Typhoon */
2700 .subdevice = 0x0138, /* LifeView FlyTV Prime30 OEM */
2701 .driver_data = SAA7134_BOARD_FLYVIDEO2000,
2702 },{
2703 .vendor = PCI_VENDOR_ID_PHILIPS,
2704 .device = PCI_DEVICE_ID_PHILIPS_SAA7133, 2704 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
2705 .subvendor = 0x5168, 2705 .subvendor = 0x5168,
2706 .subdevice = 0x0212, /* minipci, LR212 */ 2706 .subdevice = 0x0212, /* minipci, LR212 */
@@ -2935,7 +2935,7 @@ struct pci_device_id saa7134_pci_tbl[] = {
2935 .device = PCI_DEVICE_ID_PHILIPS_SAA7133, 2935 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
2936 .subvendor = 0x5168, 2936 .subvendor = 0x5168,
2937 .subdevice = 0x0502, /* Cardbus version */ 2937 .subdevice = 0x0502, /* Cardbus version */
2938 .driver_data = SAA7134_BOARD_FLYDVBTDUO, 2938 .driver_data = SAA7134_BOARD_FLYDVBT_DUO_CARDBUS,
2939 },{ 2939 },{
2940 .vendor = PCI_VENDOR_ID_PHILIPS, 2940 .vendor = PCI_VENDOR_ID_PHILIPS,
2941 .device = PCI_DEVICE_ID_PHILIPS_SAA7133, 2941 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
@@ -2980,12 +2980,12 @@ struct pci_device_id saa7134_pci_tbl[] = {
2980 .subdevice = 0x1370, /* cardbus version */ 2980 .subdevice = 0x1370, /* cardbus version */
2981 .driver_data = SAA7134_BOARD_ADS_INSTANT_TV, 2981 .driver_data = SAA7134_BOARD_ADS_INSTANT_TV,
2982 2982
2983 },{ /* Typhoon DVB-T Duo Digital/Analog Cardbus */ 2983 },{
2984 .vendor = PCI_VENDOR_ID_PHILIPS, 2984 .vendor = PCI_VENDOR_ID_PHILIPS,
2985 .device = PCI_DEVICE_ID_PHILIPS_SAA7133, 2985 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
2986 .subvendor = 0x4e42, 2986 .subvendor = 0x4e42, /* Typhoon */
2987 .subdevice = 0x0502, 2987 .subdevice = 0x0502, /* LifeView LR502 OEM */
2988 .driver_data = SAA7134_BOARD_THYPHOON_DVBT_DUO_CARDBUS, 2988 .driver_data = SAA7134_BOARD_FLYDVBT_DUO_CARDBUS,
2989 },{ 2989 },{
2990 .vendor = PCI_VENDOR_ID_PHILIPS, 2990 .vendor = PCI_VENDOR_ID_PHILIPS,
2991 .device = PCI_DEVICE_ID_PHILIPS_SAA7133, 2991 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
@@ -3206,8 +3206,7 @@ int saa7134_board_init1(struct saa7134_dev *dev)
3206 saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0x00040000, 0x00040000); 3206 saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0x00040000, 0x00040000);
3207 saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x00040000, 0x00000004); 3207 saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x00040000, 0x00000004);
3208 break; 3208 break;
3209 case SAA7134_BOARD_FLYDVBTDUO: 3209 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
3210 case SAA7134_BOARD_THYPHOON_DVBT_DUO_CARDBUS:
3211 /* turn the fan on */ 3210 /* turn the fan on */
3212 saa_writeb(SAA7134_GPIO_GPMODE3, 0x08); 3211 saa_writeb(SAA7134_GPIO_GPMODE3, 0x08);
3213 saa_writeb(SAA7134_GPIO_GPSTATUS3, 0x06); 3212 saa_writeb(SAA7134_GPIO_GPSTATUS3, 0x06);
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c
index 399f9952596c..1a536e865277 100644
--- a/drivers/media/video/saa7134/saa7134-dvb.c
+++ b/drivers/media/video/saa7134/saa7134-dvb.c
@@ -861,7 +861,7 @@ static int dvb_init(struct saa7134_dev *dev)
861 dev->dvb.frontend = tda10046_attach(&tda827x_lifeview_config, 861 dev->dvb.frontend = tda10046_attach(&tda827x_lifeview_config,
862 &dev->i2c_adap); 862 &dev->i2c_adap);
863 break; 863 break;
864 case SAA7134_BOARD_THYPHOON_DVBT_DUO_CARDBUS: 864 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
865 dev->dvb.frontend = tda10046_attach(&tda827x_lifeview_config, 865 dev->dvb.frontend = tda10046_attach(&tda827x_lifeview_config,
866 &dev->i2c_adap); 866 &dev->i2c_adap);
867 break; 867 break;
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h
index e70eae8d29bb..3261d8bebdd1 100644
--- a/drivers/media/video/saa7134/saa7134.h
+++ b/drivers/media/video/saa7134/saa7134.h
@@ -185,7 +185,7 @@ struct saa7134_format {
185#define SAA7134_BOARD_AVERMEDIA_GO_007_FM 57 185#define SAA7134_BOARD_AVERMEDIA_GO_007_FM 57
186#define SAA7134_BOARD_ADS_INSTANT_TV 58 186#define SAA7134_BOARD_ADS_INSTANT_TV 58
187#define SAA7134_BOARD_KWORLD_VSTREAM_XPERT 59 187#define SAA7134_BOARD_KWORLD_VSTREAM_XPERT 59
188#define SAA7134_BOARD_THYPHOON_DVBT_DUO_CARDBUS 60 188#define SAA7134_BOARD_FLYDVBT_DUO_CARDBUS 60
189#define SAA7134_BOARD_PHILIPS_TOUGH 61 189#define SAA7134_BOARD_PHILIPS_TOUGH 61
190#define SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUSII 62 190#define SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUSII 62
191#define SAA7134_BOARD_KWORLD_XPERT 63 191#define SAA7134_BOARD_KWORLD_XPERT 63
diff --git a/drivers/media/video/stradis.c b/drivers/media/video/stradis.c
index 54fc33011ffb..9d769264a329 100644
--- a/drivers/media/video/stradis.c
+++ b/drivers/media/video/stradis.c
@@ -2012,7 +2012,6 @@ static int __devinit init_saa7146(struct pci_dev *pdev)
2012{ 2012{
2013 struct saa7146 *saa = pci_get_drvdata(pdev); 2013 struct saa7146 *saa = pci_get_drvdata(pdev);
2014 2014
2015 memset(saa, 0, sizeof(*saa));
2016 saa->user = 0; 2015 saa->user = 0;
2017 /* reset the saa7146 */ 2016 /* reset the saa7146 */
2018 saawrite(0xffff0000, SAA7146_MC1); 2017 saawrite(0xffff0000, SAA7146_MC1);
@@ -2062,16 +2061,16 @@ static int __devinit init_saa7146(struct pci_dev *pdev)
2062 } 2061 }
2063 if (saa->audbuf == NULL && (saa->audbuf = vmalloc(65536)) == NULL) { 2062 if (saa->audbuf == NULL && (saa->audbuf = vmalloc(65536)) == NULL) {
2064 dev_err(&pdev->dev, "%d: malloc failed\n", saa->nr); 2063 dev_err(&pdev->dev, "%d: malloc failed\n", saa->nr);
2065 goto errvid; 2064 goto errfree;
2066 } 2065 }
2067 if (saa->osdbuf == NULL && (saa->osdbuf = vmalloc(131072)) == NULL) { 2066 if (saa->osdbuf == NULL && (saa->osdbuf = vmalloc(131072)) == NULL) {
2068 dev_err(&pdev->dev, "%d: malloc failed\n", saa->nr); 2067 dev_err(&pdev->dev, "%d: malloc failed\n", saa->nr);
2069 goto erraud; 2068 goto errfree;
2070 } 2069 }
2071 /* allocate 81920 byte buffer for clipping */ 2070 /* allocate 81920 byte buffer for clipping */
2072 if ((saa->dmavid2 = kzalloc(VIDEO_CLIPMAP_SIZE, GFP_KERNEL)) == NULL) { 2071 if ((saa->dmavid2 = kzalloc(VIDEO_CLIPMAP_SIZE, GFP_KERNEL)) == NULL) {
2073 dev_err(&pdev->dev, "%d: clip kmalloc failed\n", saa->nr); 2072 dev_err(&pdev->dev, "%d: clip kmalloc failed\n", saa->nr);
2074 goto errosd; 2073 goto errfree;
2075 } 2074 }
2076 /* setup clipping registers */ 2075 /* setup clipping registers */
2077 saawrite(virt_to_bus(saa->dmavid2), SAA7146_BASE_EVEN2); 2076 saawrite(virt_to_bus(saa->dmavid2), SAA7146_BASE_EVEN2);
@@ -2085,15 +2084,11 @@ static int __devinit init_saa7146(struct pci_dev *pdev)
2085 I2CBusScan(saa); 2084 I2CBusScan(saa);
2086 2085
2087 return 0; 2086 return 0;
2088errosd: 2087errfree:
2089 vfree(saa->osdbuf); 2088 vfree(saa->osdbuf);
2090 saa->osdbuf = NULL;
2091erraud:
2092 vfree(saa->audbuf); 2089 vfree(saa->audbuf);
2093 saa->audbuf = NULL;
2094errvid:
2095 vfree(saa->vidbuf); 2090 vfree(saa->vidbuf);
2096 saa->vidbuf = NULL; 2091 saa->audbuf = saa->osdbuf = saa->vidbuf = NULL;
2097err: 2092err:
2098 return -ENOMEM; 2093 return -ENOMEM;
2099} 2094}
diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c
index 5815649bdc78..0d54f6c1982b 100644
--- a/drivers/media/video/tda9887.c
+++ b/drivers/media/video/tda9887.c
@@ -231,7 +231,7 @@ static struct tvnorm tvnorms[] = {
231 cAudioIF_6_5 | 231 cAudioIF_6_5 |
232 cVideoIF_38_90 ), 232 cVideoIF_38_90 ),
233 },{ 233 },{
234 .std = V4L2_STD_NTSC_M, 234 .std = V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_KR,
235 .name = "NTSC-M", 235 .name = "NTSC-M",
236 .b = ( cNegativeFmTV | 236 .b = ( cNegativeFmTV |
237 cQSS ), 237 cQSS ),
@@ -619,6 +619,11 @@ static int tda9887_fixup_std(struct tda9887 *t)
619 tda9887_dbg("insmod fixup: NTSC => NTSC_M_JP\n"); 619 tda9887_dbg("insmod fixup: NTSC => NTSC_M_JP\n");
620 t->std = V4L2_STD_NTSC_M_JP; 620 t->std = V4L2_STD_NTSC_M_JP;
621 break; 621 break;
622 case 'k':
623 case 'K':
624 tda9887_dbg("insmod fixup: NTSC => NTSC_M_KR\n");
625 t->std = V4L2_STD_NTSC_M_KR;
626 break;
622 case '-': 627 case '-':
623 /* default parameter, do nothing */ 628 /* default parameter, do nothing */
624 break; 629 break;
@@ -876,7 +881,7 @@ static int tda9887_resume(struct device * dev)
876/* ----------------------------------------------------------------------- */ 881/* ----------------------------------------------------------------------- */
877 882
878static struct i2c_driver driver = { 883static struct i2c_driver driver = {
879 .id = -1, /* FIXME */ 884 .id = I2C_DRIVERID_TDA9887,
880 .attach_adapter = tda9887_probe, 885 .attach_adapter = tda9887_probe,
881 .detach_client = tda9887_detach, 886 .detach_client = tda9887_detach,
882 .command = tda9887_command, 887 .command = tda9887_command,
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index 2995b22acb43..e7ee619d62c5 100644
--- a/drivers/media/video/tuner-core.c
+++ b/drivers/media/video/tuner-core.c
@@ -216,6 +216,7 @@ static void set_type(struct i2c_client *c, unsigned int type,
216 buffer[3] = 0xa4; 216 buffer[3] = 0xa4;
217 i2c_master_send(c,buffer,4); 217 i2c_master_send(c,buffer,4);
218 default_tuner_init(c); 218 default_tuner_init(c);
219 break;
219 default: 220 default:
220 default_tuner_init(c); 221 default_tuner_init(c);
221 break; 222 break;
@@ -365,6 +366,11 @@ static int tuner_fixup_std(struct tuner *t)
365 tuner_dbg("insmod fixup: NTSC => NTSC_M_JP\n"); 366 tuner_dbg("insmod fixup: NTSC => NTSC_M_JP\n");
366 t->std = V4L2_STD_NTSC_M_JP; 367 t->std = V4L2_STD_NTSC_M_JP;
367 break; 368 break;
369 case 'k':
370 case 'K':
371 tuner_dbg("insmod fixup: NTSC => NTSC_M_KR\n");
372 t->std = V4L2_STD_NTSC_M_KR;
373 break;
368 case '-': 374 case '-':
369 /* default parameter, do nothing */ 375 /* default parameter, do nothing */
370 break; 376 break;
@@ -448,7 +454,7 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
448 printk("%02x ",buffer[i]); 454 printk("%02x ",buffer[i]);
449 printk("\n"); 455 printk("\n");
450 } 456 }
451 /* TEA5767 autodetection code - only for addr = 0xc0 */ 457 /* autodetection code based on the i2c addr */
452 if (!no_autodetect) { 458 if (!no_autodetect) {
453 switch (addr) { 459 switch (addr) {
454 case 0x42: 460 case 0x42:
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c
index 6d03b9b05c6e..c8e5ad0e8185 100644
--- a/drivers/media/video/tvaudio.c
+++ b/drivers/media/video/tvaudio.c
@@ -390,6 +390,14 @@ static void tda9840_setmode(struct CHIPSTATE *chip, int mode)
390 chip_write(chip, TDA9840_SW, t); 390 chip_write(chip, TDA9840_SW, t);
391} 391}
392 392
393static int tda9840_checkit(struct CHIPSTATE *chip)
394{
395 int rc;
396 rc = chip_read(chip);
397 /* lower 5 bits should be 0 */
398 return ((rc & 0x1f) == 0) ? 1 : 0;
399}
400
393/* ---------------------------------------------------------------------- */ 401/* ---------------------------------------------------------------------- */
394/* audio chip descriptions - defines+functions for tda985x */ 402/* audio chip descriptions - defines+functions for tda985x */
395 403
@@ -1264,6 +1272,7 @@ static struct CHIPDESC chiplist[] = {
1264 .addr_hi = I2C_TDA9840 >> 1, 1272 .addr_hi = I2C_TDA9840 >> 1,
1265 .registers = 5, 1273 .registers = 5,
1266 1274
1275 .checkit = tda9840_checkit,
1267 .getmode = tda9840_getmode, 1276 .getmode = tda9840_getmode,
1268 .setmode = tda9840_setmode, 1277 .setmode = tda9840_setmode,
1269 .checkmode = generic_checkmode, 1278 .checkmode = generic_checkmode,
diff --git a/drivers/media/video/tvp5150.c b/drivers/media/video/tvp5150.c
index fad9ea0ae4f2..1864423b3046 100644
--- a/drivers/media/video/tvp5150.c
+++ b/drivers/media/video/tvp5150.c
@@ -746,24 +746,27 @@ static int tvp5150_set_std(struct i2c_client *c, v4l2_std_id std)
746 746
747static inline void tvp5150_reset(struct i2c_client *c) 747static inline void tvp5150_reset(struct i2c_client *c)
748{ 748{
749 u8 type, ver_656, msb_id, lsb_id, msb_rom, lsb_rom; 749 u8 msb_id, lsb_id, msb_rom, lsb_rom;
750 struct tvp5150 *decoder = i2c_get_clientdata(c); 750 struct tvp5150 *decoder = i2c_get_clientdata(c);
751 751
752 type=tvp5150_read(c,TVP5150_AUTOSW_MSK);
753 msb_id=tvp5150_read(c,TVP5150_MSB_DEV_ID); 752 msb_id=tvp5150_read(c,TVP5150_MSB_DEV_ID);
754 lsb_id=tvp5150_read(c,TVP5150_LSB_DEV_ID); 753 lsb_id=tvp5150_read(c,TVP5150_LSB_DEV_ID);
755 msb_rom=tvp5150_read(c,TVP5150_ROM_MAJOR_VER); 754 msb_rom=tvp5150_read(c,TVP5150_ROM_MAJOR_VER);
756 lsb_rom=tvp5150_read(c,TVP5150_ROM_MINOR_VER); 755 lsb_rom=tvp5150_read(c,TVP5150_ROM_MINOR_VER);
757 756
758 if (type==0xdc) { 757 if ((msb_rom==4)&&(lsb_rom==0)) { /* Is TVP5150AM1 */
759 ver_656=tvp5150_read(c,TVP5150_REV_SELECT); 758 tvp5150_info("tvp%02x%02xam1 detected.\n",msb_id, lsb_id);
760 tvp5150_info("tvp%02x%02xam1 detected 656 version is %d.\n",msb_id, lsb_id,ver_656); 759
761 } else if (type==0xfc) { 760 /* ITU-T BT.656.4 timing */
762 tvp5150_info("tvp%02x%02xa detected.\n",msb_id, lsb_id); 761 tvp5150_write(c,TVP5150_REV_SELECT,0);
763 } else { 762 } else {
764 tvp5150_info("unknown tvp%02x%02x chip detected(%d).\n",msb_id,lsb_id,type); 763 if ((msb_rom==3)||(lsb_rom==0x21)) { /* Is TVP5150A */
764 tvp5150_info("tvp%02x%02xa detected.\n",msb_id, lsb_id);
765 } else {
766 tvp5150_info("*** unknown tvp%02x%02x chip detected.\n",msb_id,lsb_id);
767 tvp5150_info("*** Rom ver is %d.%d\n",msb_rom,lsb_rom);
768 }
765 } 769 }
766 tvp5150_info("Rom ver is %d.%d\n",msb_rom,lsb_rom);
767 770
768 /* Initializes TVP5150 to its default values */ 771 /* Initializes TVP5150 to its default values */
769 tvp5150_write_inittab(c, tvp5150_init_default); 772 tvp5150_write_inittab(c, tvp5150_init_default);
@@ -893,6 +896,17 @@ static int tvp5150_command(struct i2c_client *c,
893 } 896 }
894 case DECODER_GET_STATUS: 897 case DECODER_GET_STATUS:
895 { 898 {
899 int *iarg = arg;
900 int status;
901 int res=0;
902 status = tvp5150_read(c, 0x88);
903 if(status&0x08){
904 res |= DECODER_STATUS_COLOR;
905 }
906 if(status&0x04 && status&0x02){
907 res |= DECODER_STATUS_GOOD;
908 }
909 *iarg=res;
896 break; 910 break;
897 } 911 }
898 912
diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c
index adfba44dac5a..2beac55b57d6 100644
--- a/drivers/net/8139too.c
+++ b/drivers/net/8139too.c
@@ -586,6 +586,7 @@ struct rtl8139_private {
586 dma_addr_t tx_bufs_dma; 586 dma_addr_t tx_bufs_dma;
587 signed char phys[4]; /* MII device addresses. */ 587 signed char phys[4]; /* MII device addresses. */
588 char twistie, twist_row, twist_col; /* Twister tune state. */ 588 char twistie, twist_row, twist_col; /* Twister tune state. */
589 unsigned int watchdog_fired : 1;
589 unsigned int default_port : 4; /* Last dev->if_port value. */ 590 unsigned int default_port : 4; /* Last dev->if_port value. */
590 unsigned int have_thread : 1; 591 unsigned int have_thread : 1;
591 spinlock_t lock; 592 spinlock_t lock;
@@ -638,6 +639,7 @@ static void rtl8139_set_rx_mode (struct net_device *dev);
638static void __set_rx_mode (struct net_device *dev); 639static void __set_rx_mode (struct net_device *dev);
639static void rtl8139_hw_start (struct net_device *dev); 640static void rtl8139_hw_start (struct net_device *dev);
640static void rtl8139_thread (void *_data); 641static void rtl8139_thread (void *_data);
642static void rtl8139_tx_timeout_task(void *_data);
641static struct ethtool_ops rtl8139_ethtool_ops; 643static struct ethtool_ops rtl8139_ethtool_ops;
642 644
643/* write MMIO register, with flush */ 645/* write MMIO register, with flush */
@@ -1598,13 +1600,14 @@ static void rtl8139_thread (void *_data)
1598{ 1600{
1599 struct net_device *dev = _data; 1601 struct net_device *dev = _data;
1600 struct rtl8139_private *tp = netdev_priv(dev); 1602 struct rtl8139_private *tp = netdev_priv(dev);
1601 unsigned long thr_delay; 1603 unsigned long thr_delay = next_tick;
1602 1604
1603 if (rtnl_shlock_nowait() == 0) { 1605 if (tp->watchdog_fired) {
1606 tp->watchdog_fired = 0;
1607 rtl8139_tx_timeout_task(_data);
1608 } else if (rtnl_shlock_nowait() == 0) {
1604 rtl8139_thread_iter (dev, tp, tp->mmio_addr); 1609 rtl8139_thread_iter (dev, tp, tp->mmio_addr);
1605 rtnl_unlock (); 1610 rtnl_unlock ();
1606
1607 thr_delay = next_tick;
1608 } else { 1611 } else {
1609 /* unlikely race. mitigate with fast poll. */ 1612 /* unlikely race. mitigate with fast poll. */
1610 thr_delay = HZ / 2; 1613 thr_delay = HZ / 2;
@@ -1631,7 +1634,8 @@ static void rtl8139_stop_thread(struct rtl8139_private *tp)
1631 if (tp->have_thread) { 1634 if (tp->have_thread) {
1632 cancel_rearming_delayed_work(&tp->thread); 1635 cancel_rearming_delayed_work(&tp->thread);
1633 tp->have_thread = 0; 1636 tp->have_thread = 0;
1634 } 1637 } else
1638 flush_scheduled_work();
1635} 1639}
1636 1640
1637static inline void rtl8139_tx_clear (struct rtl8139_private *tp) 1641static inline void rtl8139_tx_clear (struct rtl8139_private *tp)
@@ -1642,14 +1646,13 @@ static inline void rtl8139_tx_clear (struct rtl8139_private *tp)
1642 /* XXX account for unsent Tx packets in tp->stats.tx_dropped */ 1646 /* XXX account for unsent Tx packets in tp->stats.tx_dropped */
1643} 1647}
1644 1648
1645 1649static void rtl8139_tx_timeout_task (void *_data)
1646static void rtl8139_tx_timeout (struct net_device *dev)
1647{ 1650{
1651 struct net_device *dev = _data;
1648 struct rtl8139_private *tp = netdev_priv(dev); 1652 struct rtl8139_private *tp = netdev_priv(dev);
1649 void __iomem *ioaddr = tp->mmio_addr; 1653 void __iomem *ioaddr = tp->mmio_addr;
1650 int i; 1654 int i;
1651 u8 tmp8; 1655 u8 tmp8;
1652 unsigned long flags;
1653 1656
1654 printk (KERN_DEBUG "%s: Transmit timeout, status %2.2x %4.4x %4.4x " 1657 printk (KERN_DEBUG "%s: Transmit timeout, status %2.2x %4.4x %4.4x "
1655 "media %2.2x.\n", dev->name, RTL_R8 (ChipCmd), 1658 "media %2.2x.\n", dev->name, RTL_R8 (ChipCmd),
@@ -1670,23 +1673,34 @@ static void rtl8139_tx_timeout (struct net_device *dev)
1670 if (tmp8 & CmdTxEnb) 1673 if (tmp8 & CmdTxEnb)
1671 RTL_W8 (ChipCmd, CmdRxEnb); 1674 RTL_W8 (ChipCmd, CmdRxEnb);
1672 1675
1673 spin_lock(&tp->rx_lock); 1676 spin_lock_bh(&tp->rx_lock);
1674 /* Disable interrupts by clearing the interrupt mask. */ 1677 /* Disable interrupts by clearing the interrupt mask. */
1675 RTL_W16 (IntrMask, 0x0000); 1678 RTL_W16 (IntrMask, 0x0000);
1676 1679
1677 /* Stop a shared interrupt from scavenging while we are. */ 1680 /* Stop a shared interrupt from scavenging while we are. */
1678 spin_lock_irqsave (&tp->lock, flags); 1681 spin_lock_irq(&tp->lock);
1679 rtl8139_tx_clear (tp); 1682 rtl8139_tx_clear (tp);
1680 spin_unlock_irqrestore (&tp->lock, flags); 1683 spin_unlock_irq(&tp->lock);
1681 1684
1682 /* ...and finally, reset everything */ 1685 /* ...and finally, reset everything */
1683 if (netif_running(dev)) { 1686 if (netif_running(dev)) {
1684 rtl8139_hw_start (dev); 1687 rtl8139_hw_start (dev);
1685 netif_wake_queue (dev); 1688 netif_wake_queue (dev);
1686 } 1689 }
1687 spin_unlock(&tp->rx_lock); 1690 spin_unlock_bh(&tp->rx_lock);
1688} 1691}
1689 1692
1693static void rtl8139_tx_timeout (struct net_device *dev)
1694{
1695 struct rtl8139_private *tp = netdev_priv(dev);
1696
1697 if (!tp->have_thread) {
1698 INIT_WORK(&tp->thread, rtl8139_tx_timeout_task, dev);
1699 schedule_delayed_work(&tp->thread, next_tick);
1700 } else
1701 tp->watchdog_fired = 1;
1702
1703}
1690 1704
1691static int rtl8139_start_xmit (struct sk_buff *skb, struct net_device *dev) 1705static int rtl8139_start_xmit (struct sk_buff *skb, struct net_device *dev)
1692{ 1706{
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 6a6a08441804..47c72a63dfe1 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -4,9 +4,9 @@
4# 4#
5 5
6menu "Network device support" 6menu "Network device support"
7 depends on NET
7 8
8config NETDEVICES 9config NETDEVICES
9 depends on NET
10 default y if UML 10 default y if UML
11 bool "Network device support" 11 bool "Network device support"
12 ---help--- 12 ---help---
@@ -24,9 +24,6 @@ config NETDEVICES
24 24
25 If unsure, say Y. 25 If unsure, say Y.
26 26
27# All the following symbols are dependent on NETDEVICES - do not repeat
28# that for each of the symbols.
29if NETDEVICES
30 27
31config IFB 28config IFB
32 tristate "Intermediate Functional Block support" 29 tristate "Intermediate Functional Block support"
@@ -2718,8 +2715,6 @@ config NETCONSOLE
2718 If you want to log kernel messages over the network, enable this. 2715 If you want to log kernel messages over the network, enable this.
2719 See <file:Documentation/networking/netconsole.txt> for details. 2716 See <file:Documentation/networking/netconsole.txt> for details.
2720 2717
2721endif #NETDEVICES
2722
2723config NETPOLL 2718config NETPOLL
2724 def_bool NETCONSOLE 2719 def_bool NETCONSOLE
2725 2720
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 4ff006c37626..e0f51afec778 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1145,7 +1145,8 @@ int bond_sethwaddr(struct net_device *bond_dev, struct net_device *slave_dev)
1145} 1145}
1146 1146
1147#define BOND_INTERSECT_FEATURES \ 1147#define BOND_INTERSECT_FEATURES \
1148 (NETIF_F_SG|NETIF_F_IP_CSUM|NETIF_F_NO_CSUM|NETIF_F_HW_CSUM) 1148 (NETIF_F_SG|NETIF_F_IP_CSUM|NETIF_F_NO_CSUM|NETIF_F_HW_CSUM|\
1149 NETIF_F_TSO|NETIF_F_UFO)
1149 1150
1150/* 1151/*
1151 * Compute the common dev->feature set available to all slaves. Some 1152 * Compute the common dev->feature set available to all slaves. Some
@@ -1168,6 +1169,16 @@ static int bond_compute_features(struct bonding *bond)
1168 NETIF_F_HW_CSUM))) 1169 NETIF_F_HW_CSUM)))
1169 features &= ~NETIF_F_SG; 1170 features &= ~NETIF_F_SG;
1170 1171
1172 /*
1173 * features will include NETIF_F_TSO (NETIF_F_UFO) iff all
1174 * slave devices support NETIF_F_TSO (NETIF_F_UFO), which
1175 * implies that all slaves also support scatter-gather
1176 * (NETIF_F_SG), which implies that features also includes
1177 * NETIF_F_SG. So no need to check whether we have an
1178 * illegal combination of NETIF_F_{TSO,UFO} and
1179 * !NETIF_F_SG
1180 */
1181
1171 features |= (bond_dev->features & ~BOND_INTERSECT_FEATURES); 1182 features |= (bond_dev->features & ~BOND_INTERSECT_FEATURES);
1172 bond_dev->features = features; 1183 bond_dev->features = features;
1173 1184
@@ -4080,6 +4091,8 @@ static void bond_ethtool_get_drvinfo(struct net_device *bond_dev,
4080 4091
4081static struct ethtool_ops bond_ethtool_ops = { 4092static struct ethtool_ops bond_ethtool_ops = {
4082 .get_tx_csum = ethtool_op_get_tx_csum, 4093 .get_tx_csum = ethtool_op_get_tx_csum,
4094 .get_tso = ethtool_op_get_tso,
4095 .get_ufo = ethtool_op_get_ufo,
4083 .get_sg = ethtool_op_get_sg, 4096 .get_sg = ethtool_op_get_sg,
4084 .get_drvinfo = bond_ethtool_get_drvinfo, 4097 .get_drvinfo = bond_ethtool_get_drvinfo,
4085}; 4098};
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 32d13da43a0b..041bcc583557 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -260,7 +260,7 @@ static ssize_t bonding_store_slaves(struct class_device *cd, const char *buffer,
260 char *ifname; 260 char *ifname;
261 int i, res, found, ret = count; 261 int i, res, found, ret = count;
262 struct slave *slave; 262 struct slave *slave;
263 struct net_device *dev = 0; 263 struct net_device *dev = NULL;
264 struct bonding *bond = to_bond(cd); 264 struct bonding *bond = to_bond(cd);
265 265
266 /* Quick sanity check -- is the bond interface up? */ 266 /* Quick sanity check -- is the bond interface up? */
@@ -995,7 +995,7 @@ static ssize_t bonding_store_primary(struct class_device *cd, const char *buf, s
995 printk(KERN_INFO DRV_NAME 995 printk(KERN_INFO DRV_NAME
996 ": %s: Setting primary slave to None.\n", 996 ": %s: Setting primary slave to None.\n",
997 bond->dev->name); 997 bond->dev->name);
998 bond->primary_slave = 0; 998 bond->primary_slave = NULL;
999 bond_select_active_slave(bond); 999 bond_select_active_slave(bond);
1000 } else { 1000 } else {
1001 printk(KERN_INFO DRV_NAME 1001 printk(KERN_INFO DRV_NAME
@@ -1123,7 +1123,7 @@ static ssize_t bonding_store_active_slave(struct class_device *cd, const char *b
1123 printk(KERN_INFO DRV_NAME 1123 printk(KERN_INFO DRV_NAME
1124 ": %s: Setting active slave to None.\n", 1124 ": %s: Setting active slave to None.\n",
1125 bond->dev->name); 1125 bond->dev->name);
1126 bond->primary_slave = 0; 1126 bond->primary_slave = NULL;
1127 bond_select_active_slave(bond); 1127 bond_select_active_slave(bond);
1128 } else { 1128 } else {
1129 printk(KERN_INFO DRV_NAME 1129 printk(KERN_INFO DRV_NAME
diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index bf1fd2b98bf8..24253c807e55 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -2752,8 +2752,6 @@ static int e100_resume(struct pci_dev *pdev)
2752 retval = pci_enable_wake(pdev, 0, 0); 2752 retval = pci_enable_wake(pdev, 0, 0);
2753 if (retval) 2753 if (retval)
2754 DPRINTK(PROBE,ERR, "Error clearing wake events\n"); 2754 DPRINTK(PROBE,ERR, "Error clearing wake events\n");
2755 if(e100_hw_init(nic))
2756 DPRINTK(HW, ERR, "e100_hw_init failed\n");
2757 2755
2758 netif_device_attach(netdev); 2756 netif_device_attach(netdev);
2759 if(netif_running(netdev)) 2757 if(netif_running(netdev))
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index 0c18dbd67d3b..0e8e3fcde9ff 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -199,8 +199,7 @@ static int gfar_probe(struct platform_device *pdev)
199 199
200 /* get a pointer to the register memory */ 200 /* get a pointer to the register memory */
201 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 201 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
202 priv->regs = (struct gfar *) 202 priv->regs = ioremap(r->start, sizeof (struct gfar));
203 ioremap(r->start, sizeof (struct gfar));
204 203
205 if (NULL == priv->regs) { 204 if (NULL == priv->regs) {
206 err = -ENOMEM; 205 err = -ENOMEM;
@@ -369,7 +368,7 @@ static int gfar_probe(struct platform_device *pdev)
369 return 0; 368 return 0;
370 369
371register_fail: 370register_fail:
372 iounmap((void *) priv->regs); 371 iounmap(priv->regs);
373regs_fail: 372regs_fail:
374 free_netdev(dev); 373 free_netdev(dev);
375 return err; 374 return err;
@@ -382,7 +381,7 @@ static int gfar_remove(struct platform_device *pdev)
382 381
383 platform_set_drvdata(pdev, NULL); 382 platform_set_drvdata(pdev, NULL);
384 383
385 iounmap((void *) priv->regs); 384 iounmap(priv->regs);
386 free_netdev(dev); 385 free_netdev(dev);
387 386
388 return 0; 387 return 0;
@@ -454,8 +453,7 @@ static void init_registers(struct net_device *dev)
454 453
455 /* Zero out the rmon mib registers if it has them */ 454 /* Zero out the rmon mib registers if it has them */
456 if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_RMON) { 455 if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_RMON) {
457 memset((void *) &(priv->regs->rmon), 0, 456 memset_io(&(priv->regs->rmon), 0, sizeof (struct rmon_mib));
458 sizeof (struct rmon_mib));
459 457
460 /* Mask off the CAM interrupts */ 458 /* Mask off the CAM interrupts */
461 gfar_write(&priv->regs->rmon.cam1, 0xffffffff); 459 gfar_write(&priv->regs->rmon.cam1, 0xffffffff);
@@ -477,7 +475,7 @@ static void init_registers(struct net_device *dev)
477void gfar_halt(struct net_device *dev) 475void gfar_halt(struct net_device *dev)
478{ 476{
479 struct gfar_private *priv = netdev_priv(dev); 477 struct gfar_private *priv = netdev_priv(dev);
480 struct gfar *regs = priv->regs; 478 struct gfar __iomem *regs = priv->regs;
481 u32 tempval; 479 u32 tempval;
482 480
483 /* Mask all interrupts */ 481 /* Mask all interrupts */
@@ -507,7 +505,7 @@ void gfar_halt(struct net_device *dev)
507void stop_gfar(struct net_device *dev) 505void stop_gfar(struct net_device *dev)
508{ 506{
509 struct gfar_private *priv = netdev_priv(dev); 507 struct gfar_private *priv = netdev_priv(dev);
510 struct gfar *regs = priv->regs; 508 struct gfar __iomem *regs = priv->regs;
511 unsigned long flags; 509 unsigned long flags;
512 510
513 phy_stop(priv->phydev); 511 phy_stop(priv->phydev);
@@ -590,7 +588,7 @@ static void free_skb_resources(struct gfar_private *priv)
590void gfar_start(struct net_device *dev) 588void gfar_start(struct net_device *dev)
591{ 589{
592 struct gfar_private *priv = netdev_priv(dev); 590 struct gfar_private *priv = netdev_priv(dev);
593 struct gfar *regs = priv->regs; 591 struct gfar __iomem *regs = priv->regs;
594 u32 tempval; 592 u32 tempval;
595 593
596 /* Enable Rx and Tx in MACCFG1 */ 594 /* Enable Rx and Tx in MACCFG1 */
@@ -624,7 +622,7 @@ int startup_gfar(struct net_device *dev)
624 unsigned long vaddr; 622 unsigned long vaddr;
625 int i; 623 int i;
626 struct gfar_private *priv = netdev_priv(dev); 624 struct gfar_private *priv = netdev_priv(dev);
627 struct gfar *regs = priv->regs; 625 struct gfar __iomem *regs = priv->regs;
628 int err = 0; 626 int err = 0;
629 u32 rctrl = 0; 627 u32 rctrl = 0;
630 u32 attrs = 0; 628 u32 attrs = 0;
@@ -1622,7 +1620,7 @@ static irqreturn_t gfar_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1622static void adjust_link(struct net_device *dev) 1620static void adjust_link(struct net_device *dev)
1623{ 1621{
1624 struct gfar_private *priv = netdev_priv(dev); 1622 struct gfar_private *priv = netdev_priv(dev);
1625 struct gfar *regs = priv->regs; 1623 struct gfar __iomem *regs = priv->regs;
1626 unsigned long flags; 1624 unsigned long flags;
1627 struct phy_device *phydev = priv->phydev; 1625 struct phy_device *phydev = priv->phydev;
1628 int new_state = 0; 1626 int new_state = 0;
@@ -1703,7 +1701,7 @@ static void gfar_set_multi(struct net_device *dev)
1703{ 1701{
1704 struct dev_mc_list *mc_ptr; 1702 struct dev_mc_list *mc_ptr;
1705 struct gfar_private *priv = netdev_priv(dev); 1703 struct gfar_private *priv = netdev_priv(dev);
1706 struct gfar *regs = priv->regs; 1704 struct gfar __iomem *regs = priv->regs;
1707 u32 tempval; 1705 u32 tempval;
1708 1706
1709 if(dev->flags & IFF_PROMISC) { 1707 if(dev->flags & IFF_PROMISC) {
@@ -1842,7 +1840,7 @@ static void gfar_set_mac_for_addr(struct net_device *dev, int num, u8 *addr)
1842 int idx; 1840 int idx;
1843 char tmpbuf[MAC_ADDR_LEN]; 1841 char tmpbuf[MAC_ADDR_LEN];
1844 u32 tempval; 1842 u32 tempval;
1845 u32 *macptr = &priv->regs->macstnaddr1; 1843 u32 __iomem *macptr = &priv->regs->macstnaddr1;
1846 1844
1847 macptr += num*2; 1845 macptr += num*2;
1848 1846
diff --git a/drivers/net/gianfar.h b/drivers/net/gianfar.h
index cb9d66ac3ab9..d37d5401be6e 100644
--- a/drivers/net/gianfar.h
+++ b/drivers/net/gianfar.h
@@ -682,8 +682,8 @@ struct gfar_private {
682 struct rxbd8 *cur_rx; /* Next free rx ring entry */ 682 struct rxbd8 *cur_rx; /* Next free rx ring entry */
683 struct txbd8 *cur_tx; /* Next free ring entry */ 683 struct txbd8 *cur_tx; /* Next free ring entry */
684 struct txbd8 *dirty_tx; /* The Ring entry to be freed. */ 684 struct txbd8 *dirty_tx; /* The Ring entry to be freed. */
685 struct gfar *regs; /* Pointer to the GFAR memory mapped Registers */ 685 struct gfar __iomem *regs; /* Pointer to the GFAR memory mapped Registers */
686 u32 *hash_regs[16]; 686 u32 __iomem *hash_regs[16];
687 int hash_width; 687 int hash_width;
688 struct net_device_stats stats; /* linux network statistics */ 688 struct net_device_stats stats; /* linux network statistics */
689 struct gfar_extra_stats extra_stats; 689 struct gfar_extra_stats extra_stats;
@@ -718,14 +718,14 @@ struct gfar_private {
718 uint32_t msg_enable; 718 uint32_t msg_enable;
719}; 719};
720 720
721static inline u32 gfar_read(volatile unsigned *addr) 721static inline u32 gfar_read(volatile unsigned __iomem *addr)
722{ 722{
723 u32 val; 723 u32 val;
724 val = in_be32(addr); 724 val = in_be32(addr);
725 return val; 725 return val;
726} 726}
727 727
728static inline void gfar_write(volatile unsigned *addr, u32 val) 728static inline void gfar_write(volatile unsigned __iomem *addr, u32 val)
729{ 729{
730 out_be32(addr, val); 730 out_be32(addr, val);
731} 731}
diff --git a/drivers/net/gianfar_ethtool.c b/drivers/net/gianfar_ethtool.c
index 765e810620fe..5de7b2e259dc 100644
--- a/drivers/net/gianfar_ethtool.c
+++ b/drivers/net/gianfar_ethtool.c
@@ -144,11 +144,11 @@ static void gfar_fill_stats(struct net_device *dev, struct ethtool_stats *dummy,
144 u64 *extra = (u64 *) & priv->extra_stats; 144 u64 *extra = (u64 *) & priv->extra_stats;
145 145
146 if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_RMON) { 146 if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_RMON) {
147 u32 *rmon = (u32 *) & priv->regs->rmon; 147 u32 __iomem *rmon = (u32 __iomem *) & priv->regs->rmon;
148 struct gfar_stats *stats = (struct gfar_stats *) buf; 148 struct gfar_stats *stats = (struct gfar_stats *) buf;
149 149
150 for (i = 0; i < GFAR_RMON_LEN; i++) 150 for (i = 0; i < GFAR_RMON_LEN; i++)
151 stats->rmon[i] = (u64) (rmon[i]); 151 stats->rmon[i] = (u64) gfar_read(&rmon[i]);
152 152
153 for (i = 0; i < GFAR_EXTRA_STATS_LEN; i++) 153 for (i = 0; i < GFAR_EXTRA_STATS_LEN; i++)
154 stats->extra[i] = extra[i]; 154 stats->extra[i] = extra[i];
@@ -221,11 +221,11 @@ static void gfar_get_regs(struct net_device *dev, struct ethtool_regs *regs, voi
221{ 221{
222 int i; 222 int i;
223 struct gfar_private *priv = netdev_priv(dev); 223 struct gfar_private *priv = netdev_priv(dev);
224 u32 *theregs = (u32 *) priv->regs; 224 u32 __iomem *theregs = (u32 __iomem *) priv->regs;
225 u32 *buf = (u32 *) regbuf; 225 u32 *buf = (u32 *) regbuf;
226 226
227 for (i = 0; i < sizeof (struct gfar) / sizeof (u32); i++) 227 for (i = 0; i < sizeof (struct gfar) / sizeof (u32); i++)
228 buf[i] = theregs[i]; 228 buf[i] = gfar_read(&theregs[i]);
229} 229}
230 230
231/* Convert microseconds to ethernet clock ticks, which changes 231/* Convert microseconds to ethernet clock ticks, which changes
diff --git a/drivers/net/gianfar_mii.c b/drivers/net/gianfar_mii.c
index 74e52fcbf806..c6b725529af5 100644
--- a/drivers/net/gianfar_mii.c
+++ b/drivers/net/gianfar_mii.c
@@ -50,7 +50,7 @@
50 * All PHY configuration is done through the TSEC1 MIIM regs */ 50 * All PHY configuration is done through the TSEC1 MIIM regs */
51int gfar_mdio_write(struct mii_bus *bus, int mii_id, int regnum, u16 value) 51int gfar_mdio_write(struct mii_bus *bus, int mii_id, int regnum, u16 value)
52{ 52{
53 struct gfar_mii *regs = bus->priv; 53 struct gfar_mii __iomem *regs = (void __iomem *)bus->priv;
54 54
55 /* Set the PHY address and the register address we want to write */ 55 /* Set the PHY address and the register address we want to write */
56 gfar_write(&regs->miimadd, (mii_id << 8) | regnum); 56 gfar_write(&regs->miimadd, (mii_id << 8) | regnum);
@@ -70,7 +70,7 @@ int gfar_mdio_write(struct mii_bus *bus, int mii_id, int regnum, u16 value)
70 * configuration has to be done through the TSEC1 MIIM regs */ 70 * configuration has to be done through the TSEC1 MIIM regs */
71int gfar_mdio_read(struct mii_bus *bus, int mii_id, int regnum) 71int gfar_mdio_read(struct mii_bus *bus, int mii_id, int regnum)
72{ 72{
73 struct gfar_mii *regs = bus->priv; 73 struct gfar_mii __iomem *regs = (void __iomem *)bus->priv;
74 u16 value; 74 u16 value;
75 75
76 /* Set the PHY address and the register address we want to read */ 76 /* Set the PHY address and the register address we want to read */
@@ -94,7 +94,7 @@ int gfar_mdio_read(struct mii_bus *bus, int mii_id, int regnum)
94/* Reset the MIIM registers, and wait for the bus to free */ 94/* Reset the MIIM registers, and wait for the bus to free */
95int gfar_mdio_reset(struct mii_bus *bus) 95int gfar_mdio_reset(struct mii_bus *bus)
96{ 96{
97 struct gfar_mii *regs = bus->priv; 97 struct gfar_mii __iomem *regs = (void __iomem *)bus->priv;
98 unsigned int timeout = PHY_INIT_TIMEOUT; 98 unsigned int timeout = PHY_INIT_TIMEOUT;
99 99
100 spin_lock_bh(&bus->mdio_lock); 100 spin_lock_bh(&bus->mdio_lock);
@@ -126,7 +126,7 @@ int gfar_mdio_probe(struct device *dev)
126{ 126{
127 struct platform_device *pdev = to_platform_device(dev); 127 struct platform_device *pdev = to_platform_device(dev);
128 struct gianfar_mdio_data *pdata; 128 struct gianfar_mdio_data *pdata;
129 struct gfar_mii *regs; 129 struct gfar_mii __iomem *regs;
130 struct mii_bus *new_bus; 130 struct mii_bus *new_bus;
131 struct resource *r; 131 struct resource *r;
132 int err = 0; 132 int err = 0;
@@ -155,15 +155,14 @@ int gfar_mdio_probe(struct device *dev)
155 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 155 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
156 156
157 /* Set the PHY base address */ 157 /* Set the PHY base address */
158 regs = (struct gfar_mii *) ioremap(r->start, 158 regs = ioremap(r->start, sizeof (struct gfar_mii));
159 sizeof (struct gfar_mii));
160 159
161 if (NULL == regs) { 160 if (NULL == regs) {
162 err = -ENOMEM; 161 err = -ENOMEM;
163 goto reg_map_fail; 162 goto reg_map_fail;
164 } 163 }
165 164
166 new_bus->priv = regs; 165 new_bus->priv = (void __force *)regs;
167 166
168 new_bus->irq = pdata->irq; 167 new_bus->irq = pdata->irq;
169 168
@@ -181,7 +180,7 @@ int gfar_mdio_probe(struct device *dev)
181 return 0; 180 return 0;
182 181
183bus_register_fail: 182bus_register_fail:
184 iounmap((void *) regs); 183 iounmap(regs);
185reg_map_fail: 184reg_map_fail:
186 kfree(new_bus); 185 kfree(new_bus);
187 186
@@ -197,7 +196,7 @@ int gfar_mdio_remove(struct device *dev)
197 196
198 dev_set_drvdata(dev, NULL); 197 dev_set_drvdata(dev, NULL);
199 198
200 iounmap((void *) (&bus->priv)); 199 iounmap((void __iomem *)bus->priv);
201 bus->priv = NULL; 200 bus->priv = NULL;
202 kfree(bus); 201 kfree(bus);
203 202
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 2e1bed153c39..6e1018448eea 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -484,13 +484,12 @@ static void mdio_write(void __iomem *ioaddr, int RegAddr, int value)
484 int i; 484 int i;
485 485
486 RTL_W32(PHYAR, 0x80000000 | (RegAddr & 0xFF) << 16 | value); 486 RTL_W32(PHYAR, 0x80000000 | (RegAddr & 0xFF) << 16 | value);
487 udelay(1000);
488 487
489 for (i = 2000; i > 0; i--) { 488 for (i = 20; i > 0; i--) {
490 /* Check if the RTL8169 has completed writing to the specified MII register */ 489 /* Check if the RTL8169 has completed writing to the specified MII register */
491 if (!(RTL_R32(PHYAR) & 0x80000000)) 490 if (!(RTL_R32(PHYAR) & 0x80000000))
492 break; 491 break;
493 udelay(100); 492 udelay(25);
494 } 493 }
495} 494}
496 495
@@ -499,15 +498,14 @@ static int mdio_read(void __iomem *ioaddr, int RegAddr)
499 int i, value = -1; 498 int i, value = -1;
500 499
501 RTL_W32(PHYAR, 0x0 | (RegAddr & 0xFF) << 16); 500 RTL_W32(PHYAR, 0x0 | (RegAddr & 0xFF) << 16);
502 udelay(1000);
503 501
504 for (i = 2000; i > 0; i--) { 502 for (i = 20; i > 0; i--) {
505 /* Check if the RTL8169 has completed retrieving data from the specified MII register */ 503 /* Check if the RTL8169 has completed retrieving data from the specified MII register */
506 if (RTL_R32(PHYAR) & 0x80000000) { 504 if (RTL_R32(PHYAR) & 0x80000000) {
507 value = (int) (RTL_R32(PHYAR) & 0xFFFF); 505 value = (int) (RTL_R32(PHYAR) & 0xFFFF);
508 break; 506 break;
509 } 507 }
510 udelay(100); 508 udelay(25);
511 } 509 }
512 return value; 510 return value;
513} 511}
@@ -677,6 +675,9 @@ static int rtl8169_set_speed_xmii(struct net_device *dev,
677 675
678 if (duplex == DUPLEX_HALF) 676 if (duplex == DUPLEX_HALF)
679 auto_nego &= ~(PHY_Cap_10_Full | PHY_Cap_100_Full); 677 auto_nego &= ~(PHY_Cap_10_Full | PHY_Cap_100_Full);
678
679 if (duplex == DUPLEX_FULL)
680 auto_nego &= ~(PHY_Cap_10_Half | PHY_Cap_100_Half);
680 } 681 }
681 682
682 tp->phy_auto_nego_reg = auto_nego; 683 tp->phy_auto_nego_reg = auto_nego;
diff --git a/drivers/net/sis900.h b/drivers/net/sis900.h
index 4233ea55670f..50323941e3c0 100644
--- a/drivers/net/sis900.h
+++ b/drivers/net/sis900.h
@@ -33,7 +33,6 @@ enum sis900_registers {
33 rxcfg=0x34, //Receive Configuration Register 33 rxcfg=0x34, //Receive Configuration Register
34 flctrl=0x38, //Flow Control Register 34 flctrl=0x38, //Flow Control Register
35 rxlen=0x3c, //Receive Packet Length Register 35 rxlen=0x3c, //Receive Packet Length Register
36 cfgpmcsr=0x44, //Configuration Power Management Control/Status Register
37 rfcr=0x48, //Receive Filter Control Register 36 rfcr=0x48, //Receive Filter Control Register
38 rfdr=0x4C, //Receive Filter Data Register 37 rfdr=0x4C, //Receive Filter Data Register
39 pmctrl=0xB0, //Power Management Control Register 38 pmctrl=0xB0, //Power Management Control Register
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index f8b973a04b65..cae2edf23004 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -23,12 +23,6 @@
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */ 24 */
25 25
26/*
27 * TOTEST
28 * - speed setting
29 * - suspend/resume
30 */
31
32#include <linux/config.h> 26#include <linux/config.h>
33#include <linux/crc32.h> 27#include <linux/crc32.h>
34#include <linux/kernel.h> 28#include <linux/kernel.h>
@@ -57,7 +51,7 @@
57#include "sky2.h" 51#include "sky2.h"
58 52
59#define DRV_NAME "sky2" 53#define DRV_NAME "sky2"
60#define DRV_VERSION "0.13" 54#define DRV_VERSION "0.15"
61#define PFX DRV_NAME " " 55#define PFX DRV_NAME " "
62 56
63/* 57/*
@@ -102,6 +96,10 @@ static int copybreak __read_mostly = 256;
102module_param(copybreak, int, 0); 96module_param(copybreak, int, 0);
103MODULE_PARM_DESC(copybreak, "Receive copy threshold"); 97MODULE_PARM_DESC(copybreak, "Receive copy threshold");
104 98
99static int disable_msi = 0;
100module_param(disable_msi, int, 0);
101MODULE_PARM_DESC(disable_msi, "Disable Message Signaled Interrupt (MSI)");
102
105static const struct pci_device_id sky2_id_table[] = { 103static const struct pci_device_id sky2_id_table[] = {
106 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9000) }, 104 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9000) },
107 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9E00) }, 105 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9E00) },
@@ -198,7 +196,7 @@ static int sky2_set_power_state(struct sky2_hw *hw, pci_power_t state)
198 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON); 196 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
199 197
200 pci_read_config_word(hw->pdev, hw->pm_cap + PCI_PM_PMC, &power_control); 198 pci_read_config_word(hw->pdev, hw->pm_cap + PCI_PM_PMC, &power_control);
201 vaux = (sky2_read8(hw, B0_CTST) & Y2_VAUX_AVAIL) && 199 vaux = (sky2_read16(hw, B0_CTST) & Y2_VAUX_AVAIL) &&
202 (power_control & PCI_PM_CAP_PME_D3cold); 200 (power_control & PCI_PM_CAP_PME_D3cold);
203 201
204 pci_read_config_word(hw->pdev, hw->pm_cap + PCI_PM_CTRL, &power_control); 202 pci_read_config_word(hw->pdev, hw->pm_cap + PCI_PM_CTRL, &power_control);
@@ -1834,6 +1832,8 @@ static int sky2_poll(struct net_device *dev0, int *budget)
1834 u16 hwidx; 1832 u16 hwidx;
1835 u16 tx_done[2] = { TX_NO_STATUS, TX_NO_STATUS }; 1833 u16 tx_done[2] = { TX_NO_STATUS, TX_NO_STATUS };
1836 1834
1835 sky2_write32(hw, STAT_CTRL, SC_STAT_CLR_IRQ);
1836
1837 hwidx = sky2_read16(hw, STAT_PUT_IDX); 1837 hwidx = sky2_read16(hw, STAT_PUT_IDX);
1838 BUG_ON(hwidx >= STATUS_RING_SIZE); 1838 BUG_ON(hwidx >= STATUS_RING_SIZE);
1839 rmb(); 1839 rmb();
@@ -1913,12 +1913,10 @@ static int sky2_poll(struct net_device *dev0, int *budget)
1913 } 1913 }
1914 1914
1915exit_loop: 1915exit_loop:
1916 sky2_write32(hw, STAT_CTRL, SC_STAT_CLR_IRQ);
1917
1918 sky2_tx_check(hw, 0, tx_done[0]); 1916 sky2_tx_check(hw, 0, tx_done[0]);
1919 sky2_tx_check(hw, 1, tx_done[1]); 1917 sky2_tx_check(hw, 1, tx_done[1]);
1920 1918
1921 if (sky2_read16(hw, STAT_PUT_IDX) == hw->st_idx) { 1919 if (likely(work_done < to_do)) {
1922 /* need to restart TX timer */ 1920 /* need to restart TX timer */
1923 if (is_ec_a1(hw)) { 1921 if (is_ec_a1(hw)) {
1924 sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_STOP); 1922 sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_STOP);
@@ -2141,14 +2139,12 @@ static inline u32 sky2_clk2us(const struct sky2_hw *hw, u32 clk)
2141 2139
2142static int sky2_reset(struct sky2_hw *hw) 2140static int sky2_reset(struct sky2_hw *hw)
2143{ 2141{
2144 u32 ctst;
2145 u16 status; 2142 u16 status;
2146 u8 t8, pmd_type; 2143 u8 t8, pmd_type;
2147 int i; 2144 int i, err;
2148
2149 ctst = sky2_read32(hw, B0_CTST);
2150 2145
2151 sky2_write8(hw, B0_CTST, CS_RST_CLR); 2146 sky2_write8(hw, B0_CTST, CS_RST_CLR);
2147
2152 hw->chip_id = sky2_read8(hw, B2_CHIP_ID); 2148 hw->chip_id = sky2_read8(hw, B2_CHIP_ID);
2153 if (hw->chip_id < CHIP_ID_YUKON_XL || hw->chip_id > CHIP_ID_YUKON_FE) { 2149 if (hw->chip_id < CHIP_ID_YUKON_XL || hw->chip_id > CHIP_ID_YUKON_FE) {
2154 printk(KERN_ERR PFX "%s: unsupported chip type 0x%x\n", 2150 printk(KERN_ERR PFX "%s: unsupported chip type 0x%x\n",
@@ -2156,12 +2152,6 @@ static int sky2_reset(struct sky2_hw *hw)
2156 return -EOPNOTSUPP; 2152 return -EOPNOTSUPP;
2157 } 2153 }
2158 2154
2159 /* ring for status responses */
2160 hw->st_le = pci_alloc_consistent(hw->pdev, STATUS_LE_BYTES,
2161 &hw->st_dma);
2162 if (!hw->st_le)
2163 return -ENOMEM;
2164
2165 /* disable ASF */ 2155 /* disable ASF */
2166 if (hw->chip_id <= CHIP_ID_YUKON_EC) { 2156 if (hw->chip_id <= CHIP_ID_YUKON_EC) {
2167 sky2_write8(hw, B28_Y2_ASF_STAT_CMD, Y2_ASF_RESET); 2157 sky2_write8(hw, B28_Y2_ASF_STAT_CMD, Y2_ASF_RESET);
@@ -2173,19 +2163,24 @@ static int sky2_reset(struct sky2_hw *hw)
2173 sky2_write8(hw, B0_CTST, CS_RST_CLR); 2163 sky2_write8(hw, B0_CTST, CS_RST_CLR);
2174 2164
2175 /* clear PCI errors, if any */ 2165 /* clear PCI errors, if any */
2176 pci_read_config_word(hw->pdev, PCI_STATUS, &status); 2166 err = pci_read_config_word(hw->pdev, PCI_STATUS, &status);
2167 if (err)
2168 goto pci_err;
2169
2177 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON); 2170 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
2178 pci_write_config_word(hw->pdev, PCI_STATUS, 2171 err = pci_write_config_word(hw->pdev, PCI_STATUS,
2179 status | PCI_STATUS_ERROR_BITS); 2172 status | PCI_STATUS_ERROR_BITS);
2173 if (err)
2174 goto pci_err;
2180 2175
2181 sky2_write8(hw, B0_CTST, CS_MRST_CLR); 2176 sky2_write8(hw, B0_CTST, CS_MRST_CLR);
2182 2177
2183 /* clear any PEX errors */ 2178 /* clear any PEX errors */
2184 if (is_pciex(hw)) { 2179 if (pci_find_capability(hw->pdev, PCI_CAP_ID_EXP)) {
2185 u16 lstat; 2180 err = pci_write_config_dword(hw->pdev, PEX_UNC_ERR_STAT,
2186 pci_write_config_dword(hw->pdev, PEX_UNC_ERR_STAT, 2181 0xffffffffUL);
2187 0xffffffffUL); 2182 if (err)
2188 pci_read_config_word(hw->pdev, PEX_LNK_STAT, &lstat); 2183 goto pci_err;
2189 } 2184 }
2190 2185
2191 pmd_type = sky2_read8(hw, B2_PMD_TYP); 2186 pmd_type = sky2_read8(hw, B2_PMD_TYP);
@@ -2297,6 +2292,14 @@ static int sky2_reset(struct sky2_hw *hw)
2297 sky2_write8(hw, STAT_ISR_TIMER_CTRL, TIM_START); 2292 sky2_write8(hw, STAT_ISR_TIMER_CTRL, TIM_START);
2298 2293
2299 return 0; 2294 return 0;
2295
2296pci_err:
2297 /* This is to catch a BIOS bug workaround where
2298 * mmconfig table doesn't have other buses.
2299 */
2300 printk(KERN_ERR PFX "%s: can't access PCI config space\n",
2301 pci_name(hw->pdev));
2302 return err;
2300} 2303}
2301 2304
2302static u32 sky2_supported_modes(const struct sky2_hw *hw) 2305static u32 sky2_supported_modes(const struct sky2_hw *hw)
@@ -2551,19 +2554,24 @@ static struct net_device_stats *sky2_get_stats(struct net_device *dev)
2551static int sky2_set_mac_address(struct net_device *dev, void *p) 2554static int sky2_set_mac_address(struct net_device *dev, void *p)
2552{ 2555{
2553 struct sky2_port *sky2 = netdev_priv(dev); 2556 struct sky2_port *sky2 = netdev_priv(dev);
2554 struct sockaddr *addr = p; 2557 struct sky2_hw *hw = sky2->hw;
2558 unsigned port = sky2->port;
2559 const struct sockaddr *addr = p;
2555 2560
2556 if (!is_valid_ether_addr(addr->sa_data)) 2561 if (!is_valid_ether_addr(addr->sa_data))
2557 return -EADDRNOTAVAIL; 2562 return -EADDRNOTAVAIL;
2558 2563
2559 memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); 2564 memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
2560 memcpy_toio(sky2->hw->regs + B2_MAC_1 + sky2->port * 8, 2565 memcpy_toio(hw->regs + B2_MAC_1 + port * 8,
2561 dev->dev_addr, ETH_ALEN); 2566 dev->dev_addr, ETH_ALEN);
2562 memcpy_toio(sky2->hw->regs + B2_MAC_2 + sky2->port * 8, 2567 memcpy_toio(hw->regs + B2_MAC_2 + port * 8,
2563 dev->dev_addr, ETH_ALEN); 2568 dev->dev_addr, ETH_ALEN);
2564 2569
2565 if (netif_running(dev)) 2570 /* virtual address for data */
2566 sky2_phy_reinit(sky2); 2571 gma_set_addr(hw, port, GM_SRC_ADDR_2L, dev->dev_addr);
2572
2573 /* physical address: used for pause frames */
2574 gma_set_addr(hw, port, GM_SRC_ADDR_1L, dev->dev_addr);
2567 2575
2568 return 0; 2576 return 0;
2569} 2577}
@@ -2843,7 +2851,7 @@ static int sky2_set_coalesce(struct net_device *dev,
2843 if (ecmd->rx_coalesce_usecs_irq == 0) 2851 if (ecmd->rx_coalesce_usecs_irq == 0)
2844 sky2_write8(hw, STAT_ISR_TIMER_CTRL, TIM_STOP); 2852 sky2_write8(hw, STAT_ISR_TIMER_CTRL, TIM_STOP);
2845 else { 2853 else {
2846 sky2_write32(hw, STAT_TX_TIMER_INI, 2854 sky2_write32(hw, STAT_ISR_TIMER_INI,
2847 sky2_us2clk(hw, ecmd->rx_coalesce_usecs_irq)); 2855 sky2_us2clk(hw, ecmd->rx_coalesce_usecs_irq));
2848 sky2_write8(hw, STAT_ISR_TIMER_CTRL, TIM_START); 2856 sky2_write8(hw, STAT_ISR_TIMER_CTRL, TIM_START);
2849 } 2857 }
@@ -3055,6 +3063,61 @@ static void __devinit sky2_show_addr(struct net_device *dev)
3055 dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]); 3063 dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]);
3056} 3064}
3057 3065
3066/* Handle software interrupt used during MSI test */
3067static irqreturn_t __devinit sky2_test_intr(int irq, void *dev_id,
3068 struct pt_regs *regs)
3069{
3070 struct sky2_hw *hw = dev_id;
3071 u32 status = sky2_read32(hw, B0_Y2_SP_ISRC2);
3072
3073 if (status == 0)
3074 return IRQ_NONE;
3075
3076 if (status & Y2_IS_IRQ_SW) {
3077 sky2_write8(hw, B0_CTST, CS_CL_SW_IRQ);
3078 hw->msi = 1;
3079 }
3080 sky2_write32(hw, B0_Y2_SP_ICR, 2);
3081
3082 sky2_read32(hw, B0_IMSK);
3083 return IRQ_HANDLED;
3084}
3085
3086/* Test interrupt path by forcing a a software IRQ */
3087static int __devinit sky2_test_msi(struct sky2_hw *hw)
3088{
3089 struct pci_dev *pdev = hw->pdev;
3090 int i, err;
3091
3092 sky2_write32(hw, B0_IMSK, Y2_IS_IRQ_SW);
3093
3094 err = request_irq(pdev->irq, sky2_test_intr, SA_SHIRQ, DRV_NAME, hw);
3095 if (err) {
3096 printk(KERN_ERR PFX "%s: cannot assign irq %d\n",
3097 pci_name(pdev), pdev->irq);
3098 return err;
3099 }
3100
3101 sky2_write8(hw, B0_CTST, CS_ST_SW_IRQ);
3102 wmb();
3103
3104 for (i = 0; i < 10; i++) {
3105 barrier();
3106 if (hw->msi)
3107 goto found;
3108 mdelay(1);
3109 }
3110
3111 err = -EOPNOTSUPP;
3112 sky2_write8(hw, B0_CTST, CS_CL_SW_IRQ);
3113 found:
3114 sky2_write32(hw, B0_IMSK, 0);
3115
3116 free_irq(pdev->irq, hw);
3117
3118 return err;
3119}
3120
3058static int __devinit sky2_probe(struct pci_dev *pdev, 3121static int __devinit sky2_probe(struct pci_dev *pdev,
3059 const struct pci_device_id *ent) 3122 const struct pci_device_id *ent)
3060{ 3123{
@@ -3135,6 +3198,12 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
3135 } 3198 }
3136 hw->pm_cap = pm_cap; 3199 hw->pm_cap = pm_cap;
3137 3200
3201 /* ring for status responses */
3202 hw->st_le = pci_alloc_consistent(hw->pdev, STATUS_LE_BYTES,
3203 &hw->st_dma);
3204 if (!hw->st_le)
3205 goto err_out_iounmap;
3206
3138 err = sky2_reset(hw); 3207 err = sky2_reset(hw);
3139 if (err) 3208 if (err)
3140 goto err_out_iounmap; 3209 goto err_out_iounmap;
@@ -3169,7 +3238,22 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
3169 } 3238 }
3170 } 3239 }
3171 3240
3172 err = request_irq(pdev->irq, sky2_intr, SA_SHIRQ, DRV_NAME, hw); 3241 if (!disable_msi && pci_enable_msi(pdev) == 0) {
3242 err = sky2_test_msi(hw);
3243 if (err == -EOPNOTSUPP) {
3244 /* MSI test failed, go back to INTx mode */
3245 printk(KERN_WARNING PFX "%s: No interrupt was generated using MSI, "
3246 "switching to INTx mode. Please report this failure to "
3247 "the PCI maintainer and include system chipset information.\n",
3248 pci_name(pdev));
3249 pci_disable_msi(pdev);
3250 }
3251 else if (err)
3252 goto err_out_unregister;
3253 }
3254
3255 err = request_irq(pdev->irq, sky2_intr, SA_SHIRQ | SA_SAMPLE_RANDOM,
3256 DRV_NAME, hw);
3173 if (err) { 3257 if (err) {
3174 printk(KERN_ERR PFX "%s: cannot assign irq %d\n", 3258 printk(KERN_ERR PFX "%s: cannot assign irq %d\n",
3175 pci_name(pdev), pdev->irq); 3259 pci_name(pdev), pdev->irq);
@@ -3184,6 +3268,8 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
3184 return 0; 3268 return 0;
3185 3269
3186err_out_unregister: 3270err_out_unregister:
3271 if (hw->msi)
3272 pci_disable_msi(pdev);
3187 if (dev1) { 3273 if (dev1) {
3188 unregister_netdev(dev1); 3274 unregister_netdev(dev1);
3189 free_netdev(dev1); 3275 free_netdev(dev1);
@@ -3226,6 +3312,8 @@ static void __devexit sky2_remove(struct pci_dev *pdev)
3226 sky2_read8(hw, B0_CTST); 3312 sky2_read8(hw, B0_CTST);
3227 3313
3228 free_irq(pdev->irq, hw); 3314 free_irq(pdev->irq, hw);
3315 if (hw->msi)
3316 pci_disable_msi(pdev);
3229 pci_free_consistent(pdev, STATUS_LE_BYTES, hw->st_le, hw->st_dma); 3317 pci_free_consistent(pdev, STATUS_LE_BYTES, hw->st_le, hw->st_dma);
3230 pci_release_regions(pdev); 3318 pci_release_regions(pdev);
3231 pci_disable_device(pdev); 3319 pci_disable_device(pdev);
@@ -3263,25 +3351,33 @@ static int sky2_suspend(struct pci_dev *pdev, pm_message_t state)
3263static int sky2_resume(struct pci_dev *pdev) 3351static int sky2_resume(struct pci_dev *pdev)
3264{ 3352{
3265 struct sky2_hw *hw = pci_get_drvdata(pdev); 3353 struct sky2_hw *hw = pci_get_drvdata(pdev);
3266 int i; 3354 int i, err;
3267 3355
3268 pci_restore_state(pdev); 3356 pci_restore_state(pdev);
3269 pci_enable_wake(pdev, PCI_D0, 0); 3357 pci_enable_wake(pdev, PCI_D0, 0);
3270 sky2_set_power_state(hw, PCI_D0); 3358 err = sky2_set_power_state(hw, PCI_D0);
3359 if (err)
3360 goto out;
3271 3361
3272 sky2_reset(hw); 3362 err = sky2_reset(hw);
3363 if (err)
3364 goto out;
3273 3365
3274 for (i = 0; i < 2; i++) { 3366 for (i = 0; i < 2; i++) {
3275 struct net_device *dev = hw->dev[i]; 3367 struct net_device *dev = hw->dev[i];
3276 if (dev) { 3368 if (dev && netif_running(dev)) {
3277 if (netif_running(dev)) { 3369 netif_device_attach(dev);
3278 netif_device_attach(dev); 3370 err = sky2_up(dev);
3279 if (sky2_up(dev)) 3371 if (err) {
3280 dev_close(dev); 3372 printk(KERN_ERR PFX "%s: could not up: %d\n",
3373 dev->name, err);
3374 dev_close(dev);
3375 break;
3281 } 3376 }
3282 } 3377 }
3283 } 3378 }
3284 return 0; 3379out:
3380 return err;
3285} 3381}
3286#endif 3382#endif
3287 3383
diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h
index 95518921001c..fd12c289a238 100644
--- a/drivers/net/sky2.h
+++ b/drivers/net/sky2.h
@@ -1841,6 +1841,7 @@ struct sky2_hw {
1841 struct net_device *dev[2]; 1841 struct net_device *dev[2];
1842 1842
1843 int pm_cap; 1843 int pm_cap;
1844 int msi;
1844 u8 chip_id; 1845 u8 chip_id;
1845 u8 chip_rev; 1846 u8 chip_rev;
1846 u8 copper; 1847 u8 copper;
@@ -1867,14 +1868,6 @@ static inline u8 sky2_read8(const struct sky2_hw *hw, unsigned reg)
1867 return readb(hw->regs + reg); 1868 return readb(hw->regs + reg);
1868} 1869}
1869 1870
1870/* This should probably go away, bus based tweeks suck */
1871static inline int is_pciex(const struct sky2_hw *hw)
1872{
1873 u32 status;
1874 pci_read_config_dword(hw->pdev, PCI_DEV_STATUS, &status);
1875 return (status & PCI_OS_PCI_X) == 0;
1876}
1877
1878static inline void sky2_write32(const struct sky2_hw *hw, unsigned reg, u32 val) 1871static inline void sky2_write32(const struct sky2_hw *hw, unsigned reg, u32 val)
1879{ 1872{
1880 writel(val, hw->regs + reg); 1873 writel(val, hw->regs + reg);
diff --git a/drivers/net/tulip/uli526x.c b/drivers/net/tulip/uli526x.c
index 983981666800..238e9c72cb3a 100644
--- a/drivers/net/tulip/uli526x.c
+++ b/drivers/net/tulip/uli526x.c
@@ -214,7 +214,7 @@ static u32 uli526x_cr6_user_set;
214/* For module input parameter */ 214/* For module input parameter */
215static int debug; 215static int debug;
216static u32 cr6set; 216static u32 cr6set;
217static unsigned char mode = 8; 217static int mode = 8;
218 218
219/* function declaration ------------------------------------- */ 219/* function declaration ------------------------------------- */
220static int uli526x_open(struct net_device *); 220static int uli526x_open(struct net_device *);
diff --git a/drivers/net/wan/dscc4.c b/drivers/net/wan/dscc4.c
index 2f61a47b4716..1ff5de076d21 100644
--- a/drivers/net/wan/dscc4.c
+++ b/drivers/net/wan/dscc4.c
@@ -1943,7 +1943,7 @@ static int dscc4_init_ring(struct net_device *dev)
1943 (++i%TX_RING_SIZE)*sizeof(*tx_fd)); 1943 (++i%TX_RING_SIZE)*sizeof(*tx_fd));
1944 } while (i < TX_RING_SIZE); 1944 } while (i < TX_RING_SIZE);
1945 1945
1946 if (dscc4_init_dummy_skb(dpriv) < 0) 1946 if (!dscc4_init_dummy_skb(dpriv))
1947 goto err_free_dma_tx; 1947 goto err_free_dma_tx;
1948 1948
1949 memset(dpriv->rx_skbuff, 0, sizeof(struct sk_buff *)*RX_RING_SIZE); 1949 memset(dpriv->rx_skbuff, 0, sizeof(struct sk_buff *)*RX_RING_SIZE);
diff --git a/drivers/serial/68328serial.c b/drivers/serial/68328serial.c
index 8cbf0fc5a225..7f0f35a05dca 100644
--- a/drivers/serial/68328serial.c
+++ b/drivers/serial/68328serial.c
@@ -332,7 +332,7 @@ static _INLINE_ void receive_chars(struct m68k_serial *info, struct pt_regs *reg
332 * Make sure that we do not overflow the buffer 332 * Make sure that we do not overflow the buffer
333 */ 333 */
334 if (tty_request_buffer_room(tty, 1) == 0) { 334 if (tty_request_buffer_room(tty, 1) == 0) {
335 schedule_work(&tty->flip.work); 335 tty_schedule_flip(tty);
336 return; 336 return;
337 } 337 }
338 338
@@ -353,7 +353,7 @@ static _INLINE_ void receive_chars(struct m68k_serial *info, struct pt_regs *reg
353 } while((rx = uart->urx.w) & URX_DATA_READY); 353 } while((rx = uart->urx.w) & URX_DATA_READY);
354#endif 354#endif
355 355
356 schedule_work(&tty->flip.work); 356 tty_schedule_flip(tty);
357 357
358clear_and_exit: 358clear_and_exit:
359 return; 359 return;
diff --git a/drivers/serial/68360serial.c b/drivers/serial/68360serial.c
index 60f5a5dc17f1..9843ae3d420e 100644
--- a/drivers/serial/68360serial.c
+++ b/drivers/serial/68360serial.c
@@ -509,7 +509,7 @@ static _INLINE_ void receive_chars(ser_info_t *info)
509 509
510 info->rx_cur = (QUICC_BD *)bdp; 510 info->rx_cur = (QUICC_BD *)bdp;
511 511
512 schedule_work(&tty->flip.work); 512 tty_schedule_flip(tty);
513} 513}
514 514
515static _INLINE_ void receive_break(ser_info_t *info) 515static _INLINE_ void receive_break(ser_info_t *info)
@@ -521,7 +521,7 @@ static _INLINE_ void receive_break(ser_info_t *info)
521 * the break. If not, we exit now, losing the break. FIXME 521 * the break. If not, we exit now, losing the break. FIXME
522 */ 522 */
523 tty_insert_flip_char(tty, 0, TTY_BREAK); 523 tty_insert_flip_char(tty, 0, TTY_BREAK);
524 schedule_work(&tty->flip.work); 524 tty_schedule_flip(tty);
525} 525}
526 526
527static _INLINE_ void transmit_chars(ser_info_t *info) 527static _INLINE_ void transmit_chars(ser_info_t *info)
diff --git a/drivers/serial/mcfserial.c b/drivers/serial/mcfserial.c
index 0ef648fa4b2d..8cbbb954df2c 100644
--- a/drivers/serial/mcfserial.c
+++ b/drivers/serial/mcfserial.c
@@ -57,20 +57,16 @@ struct timer_list mcfrs_timer_struct;
57 * keep going. Perhaps one day the cflag settings for the 57 * keep going. Perhaps one day the cflag settings for the
58 * console can be used instead. 58 * console can be used instead.
59 */ 59 */
60#if defined(CONFIG_ARNEWSH) || defined(CONFIG_FREESCALE) || \
61 defined(CONFIG_senTec) || defined(CONFIG_SNEHA)
62#define CONSOLE_BAUD_RATE 19200
63#define DEFAULT_CBAUD B19200
64#endif
65
66#if defined(CONFIG_HW_FEITH) 60#if defined(CONFIG_HW_FEITH)
67#define CONSOLE_BAUD_RATE 38400 61#define CONSOLE_BAUD_RATE 38400
68#define DEFAULT_CBAUD B38400 62#define DEFAULT_CBAUD B38400
69#endif 63#elif defined(CONFIG_MOD5272) || defined(CONFIG_M5208EVB)
70
71#if defined(CONFIG_MOD5272) || defined(CONFIG_M5208EVB)
72#define CONSOLE_BAUD_RATE 115200 64#define CONSOLE_BAUD_RATE 115200
73#define DEFAULT_CBAUD B115200 65#define DEFAULT_CBAUD B115200
66#elif defined(CONFIG_ARNEWSH) || defined(CONFIG_FREESCALE) || \
67 defined(CONFIG_senTec) || defined(CONFIG_SNEHA)
68#define CONSOLE_BAUD_RATE 19200
69#define DEFAULT_CBAUD B19200
74#endif 70#endif
75 71
76#ifndef CONSOLE_BAUD_RATE 72#ifndef CONSOLE_BAUD_RATE
@@ -350,7 +346,7 @@ static inline void receive_chars(struct mcf_serial *info)
350 } 346 }
351 tty_insert_flip_char(tty, ch, flag); 347 tty_insert_flip_char(tty, ch, flag);
352 } 348 }
353 tty_flip_buffer_push(tty); 349 tty_schedule_flip(tty);
354 return; 350 return;
355} 351}
356 352