aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/Kconfig2
-rw-r--r--drivers/char/agp/agp.h6
-rw-r--r--drivers/char/agp/intel-agp.c579
-rw-r--r--drivers/char/cyclades.c1
-rw-r--r--drivers/char/drm/Kconfig2
-rw-r--r--drivers/char/drm/drm_drawable.c41
-rw-r--r--drivers/char/drm/drm_pciids.h7
-rw-r--r--drivers/char/drm/i915_irq.c2
-rw-r--r--drivers/char/n_tty.c1
-rw-r--r--drivers/char/random.c67
-rw-r--r--drivers/char/stallion.c81
-rw-r--r--drivers/char/tty_io.c3
-rw-r--r--drivers/char/watchdog/Kconfig7
-rw-r--r--drivers/char/watchdog/Makefile1
-rw-r--r--drivers/char/watchdog/ixp2000_wdt.c2
-rw-r--r--drivers/char/watchdog/ks8695_wdt.c308
16 files changed, 714 insertions, 396 deletions
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index abcafac64738..ef683ebd367c 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -815,7 +815,7 @@ config SGI_IP27_RTC
815 815
816config GEN_RTC 816config GEN_RTC
817 tristate "Generic /dev/rtc emulation" 817 tristate "Generic /dev/rtc emulation"
818 depends on RTC!=y && !IA64 && !ARM && !M32R && !SPARC && !FRV && !S390 818 depends on RTC!=y && !IA64 && !ARM && !M32R && !SPARC && !FRV && !S390 && !SUPERH
819 ---help--- 819 ---help---
820 If you say Y here and create a character special file /dev/rtc with 820 If you say Y here and create a character special file /dev/rtc with
821 major number 10 and minor number 135 using mknod ("man mknod"), you 821 major number 10 and minor number 135 using mknod ("man mknod"), you
diff --git a/drivers/char/agp/agp.h b/drivers/char/agp/agp.h
index fdbca25a3948..35ab1a9f8e8b 100644
--- a/drivers/char/agp/agp.h
+++ b/drivers/char/agp/agp.h
@@ -176,7 +176,7 @@ struct agp_bridge_data {
176#define I830_GMCH_MEM_MASK 0x1 176#define I830_GMCH_MEM_MASK 0x1
177#define I830_GMCH_MEM_64M 0x1 177#define I830_GMCH_MEM_64M 0x1
178#define I830_GMCH_MEM_128M 0 178#define I830_GMCH_MEM_128M 0
179#define I830_GMCH_GMS_MASK 0x70 179#define I830_GMCH_GMS_MASK 0xF0
180#define I830_GMCH_GMS_DISABLED 0x00 180#define I830_GMCH_GMS_DISABLED 0x00
181#define I830_GMCH_GMS_LOCAL 0x10 181#define I830_GMCH_GMS_LOCAL 0x10
182#define I830_GMCH_GMS_STOLEN_512 0x20 182#define I830_GMCH_GMS_STOLEN_512 0x20
@@ -231,6 +231,10 @@ struct agp_bridge_data {
231#define I965_PGETBL_SIZE_512KB (0 << 1) 231#define I965_PGETBL_SIZE_512KB (0 << 1)
232#define I965_PGETBL_SIZE_256KB (1 << 1) 232#define I965_PGETBL_SIZE_256KB (1 << 1)
233#define I965_PGETBL_SIZE_128KB (2 << 1) 233#define I965_PGETBL_SIZE_128KB (2 << 1)
234#define G33_PGETBL_SIZE_MASK (3 << 8)
235#define G33_PGETBL_SIZE_1M (1 << 8)
236#define G33_PGETBL_SIZE_2M (2 << 8)
237
234#define I810_DRAM_CTL 0x3000 238#define I810_DRAM_CTL 0x3000
235#define I810_DRAM_ROW_0 0x00000001 239#define I810_DRAM_ROW_0 0x00000001
236#define I810_DRAM_ROW_0_SDRAM 0x00000001 240#define I810_DRAM_ROW_0_SDRAM 0x00000001
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
index 9c69f2e761f5..0439ee951a11 100644
--- a/drivers/char/agp/intel-agp.c
+++ b/drivers/char/agp/intel-agp.c
@@ -20,6 +20,14 @@
20#define PCI_DEVICE_ID_INTEL_82965G_IG 0x29A2 20#define PCI_DEVICE_ID_INTEL_82965G_IG 0x29A2
21#define PCI_DEVICE_ID_INTEL_82965GM_HB 0x2A00 21#define PCI_DEVICE_ID_INTEL_82965GM_HB 0x2A00
22#define PCI_DEVICE_ID_INTEL_82965GM_IG 0x2A02 22#define PCI_DEVICE_ID_INTEL_82965GM_IG 0x2A02
23#define PCI_DEVICE_ID_INTEL_82965GME_IG 0x2A12
24#define PCI_DEVICE_ID_INTEL_82945GME_IG 0x27AE
25#define PCI_DEVICE_ID_INTEL_G33_HB 0x29C0
26#define PCI_DEVICE_ID_INTEL_G33_IG 0x29C2
27#define PCI_DEVICE_ID_INTEL_Q35_HB 0x29B0
28#define PCI_DEVICE_ID_INTEL_Q35_IG 0x29B2
29#define PCI_DEVICE_ID_INTEL_Q33_HB 0x29D0
30#define PCI_DEVICE_ID_INTEL_Q33_IG 0x29D2
23 31
24#define IS_I965 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82946GZ_HB || \ 32#define IS_I965 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82946GZ_HB || \
25 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_1_HB || \ 33 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_1_HB || \
@@ -27,6 +35,9 @@
27 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_HB || \ 35 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_HB || \
28 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965GM_HB) 36 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965GM_HB)
29 37
38#define IS_G33 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_G33_HB || \
39 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_Q35_HB || \
40 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_Q33_HB)
30 41
31extern int agp_memory_reserved; 42extern int agp_memory_reserved;
32 43
@@ -53,6 +64,8 @@ extern int agp_memory_reserved;
53#define I915_PTEADDR 0x1C 64#define I915_PTEADDR 0x1C
54#define I915_GMCH_GMS_STOLEN_48M (0x6 << 4) 65#define I915_GMCH_GMS_STOLEN_48M (0x6 << 4)
55#define I915_GMCH_GMS_STOLEN_64M (0x7 << 4) 66#define I915_GMCH_GMS_STOLEN_64M (0x7 << 4)
67#define G33_GMCH_GMS_STOLEN_128M (0x8 << 4)
68#define G33_GMCH_GMS_STOLEN_256M (0x9 << 4)
56 69
57/* Intel 965G registers */ 70/* Intel 965G registers */
58#define I965_MSAC 0x62 71#define I965_MSAC 0x62
@@ -86,11 +99,18 @@ static struct gatt_mask intel_i810_masks[] =
86 .type = INTEL_AGP_CACHED_MEMORY} 99 .type = INTEL_AGP_CACHED_MEMORY}
87}; 100};
88 101
89static struct _intel_i810_private { 102static struct _intel_private {
90 struct pci_dev *i810_dev; /* device one */ 103 struct pci_dev *pcidev; /* device one */
91 volatile u8 __iomem *registers; 104 u8 __iomem *registers;
105 u32 __iomem *gtt; /* I915G */
92 int num_dcache_entries; 106 int num_dcache_entries;
93} intel_i810_private; 107 /* gtt_entries is the number of gtt entries that are already mapped
108 * to stolen memory. Stolen memory is larger than the memory mapped
109 * through gtt_entries, as it includes some reserved space for the BIOS
110 * popup and for the GTT.
111 */
112 int gtt_entries; /* i830+ */
113} intel_private;
94 114
95static int intel_i810_fetch_size(void) 115static int intel_i810_fetch_size(void)
96{ 116{
@@ -127,32 +147,32 @@ static int intel_i810_configure(void)
127 147
128 current_size = A_SIZE_FIX(agp_bridge->current_size); 148 current_size = A_SIZE_FIX(agp_bridge->current_size);
129 149
130 if (!intel_i810_private.registers) { 150 if (!intel_private.registers) {
131 pci_read_config_dword(intel_i810_private.i810_dev, I810_MMADDR, &temp); 151 pci_read_config_dword(intel_private.pcidev, I810_MMADDR, &temp);
132 temp &= 0xfff80000; 152 temp &= 0xfff80000;
133 153
134 intel_i810_private.registers = ioremap(temp, 128 * 4096); 154 intel_private.registers = ioremap(temp, 128 * 4096);
135 if (!intel_i810_private.registers) { 155 if (!intel_private.registers) {
136 printk(KERN_ERR PFX "Unable to remap memory.\n"); 156 printk(KERN_ERR PFX "Unable to remap memory.\n");
137 return -ENOMEM; 157 return -ENOMEM;
138 } 158 }
139 } 159 }
140 160
141 if ((readl(intel_i810_private.registers+I810_DRAM_CTL) 161 if ((readl(intel_private.registers+I810_DRAM_CTL)
142 & I810_DRAM_ROW_0) == I810_DRAM_ROW_0_SDRAM) { 162 & I810_DRAM_ROW_0) == I810_DRAM_ROW_0_SDRAM) {
143 /* This will need to be dynamically assigned */ 163 /* This will need to be dynamically assigned */
144 printk(KERN_INFO PFX "detected 4MB dedicated video ram.\n"); 164 printk(KERN_INFO PFX "detected 4MB dedicated video ram.\n");
145 intel_i810_private.num_dcache_entries = 1024; 165 intel_private.num_dcache_entries = 1024;
146 } 166 }
147 pci_read_config_dword(intel_i810_private.i810_dev, I810_GMADDR, &temp); 167 pci_read_config_dword(intel_private.pcidev, I810_GMADDR, &temp);
148 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); 168 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
149 writel(agp_bridge->gatt_bus_addr | I810_PGETBL_ENABLED, intel_i810_private.registers+I810_PGETBL_CTL); 169 writel(agp_bridge->gatt_bus_addr | I810_PGETBL_ENABLED, intel_private.registers+I810_PGETBL_CTL);
150 readl(intel_i810_private.registers+I810_PGETBL_CTL); /* PCI Posting. */ 170 readl(intel_private.registers+I810_PGETBL_CTL); /* PCI Posting. */
151 171
152 if (agp_bridge->driver->needs_scratch_page) { 172 if (agp_bridge->driver->needs_scratch_page) {
153 for (i = 0; i < current_size->num_entries; i++) { 173 for (i = 0; i < current_size->num_entries; i++) {
154 writel(agp_bridge->scratch_page, intel_i810_private.registers+I810_PTE_BASE+(i*4)); 174 writel(agp_bridge->scratch_page, intel_private.registers+I810_PTE_BASE+(i*4));
155 readl(intel_i810_private.registers+I810_PTE_BASE+(i*4)); /* PCI posting. */ 175 readl(intel_private.registers+I810_PTE_BASE+(i*4)); /* PCI posting. */
156 } 176 }
157 } 177 }
158 global_cache_flush(); 178 global_cache_flush();
@@ -161,9 +181,9 @@ static int intel_i810_configure(void)
161 181
162static void intel_i810_cleanup(void) 182static void intel_i810_cleanup(void)
163{ 183{
164 writel(0, intel_i810_private.registers+I810_PGETBL_CTL); 184 writel(0, intel_private.registers+I810_PGETBL_CTL);
165 readl(intel_i810_private.registers); /* PCI Posting. */ 185 readl(intel_private.registers); /* PCI Posting. */
166 iounmap(intel_i810_private.registers); 186 iounmap(intel_private.registers);
167} 187}
168 188
169static void intel_i810_tlbflush(struct agp_memory *mem) 189static void intel_i810_tlbflush(struct agp_memory *mem)
@@ -261,9 +281,9 @@ static int intel_i810_insert_entries(struct agp_memory *mem, off_t pg_start,
261 global_cache_flush(); 281 global_cache_flush();
262 for (i = pg_start; i < (pg_start + mem->page_count); i++) { 282 for (i = pg_start; i < (pg_start + mem->page_count); i++) {
263 writel((i*4096)|I810_PTE_LOCAL|I810_PTE_VALID, 283 writel((i*4096)|I810_PTE_LOCAL|I810_PTE_VALID,
264 intel_i810_private.registers+I810_PTE_BASE+(i*4)); 284 intel_private.registers+I810_PTE_BASE+(i*4));
265 } 285 }
266 readl(intel_i810_private.registers+I810_PTE_BASE+((i-1)*4)); 286 readl(intel_private.registers+I810_PTE_BASE+((i-1)*4));
267 break; 287 break;
268 case AGP_PHYS_MEMORY: 288 case AGP_PHYS_MEMORY:
269 case AGP_NORMAL_MEMORY: 289 case AGP_NORMAL_MEMORY:
@@ -273,9 +293,9 @@ static int intel_i810_insert_entries(struct agp_memory *mem, off_t pg_start,
273 writel(agp_bridge->driver->mask_memory(agp_bridge, 293 writel(agp_bridge->driver->mask_memory(agp_bridge,
274 mem->memory[i], 294 mem->memory[i],
275 mask_type), 295 mask_type),
276 intel_i810_private.registers+I810_PTE_BASE+(j*4)); 296 intel_private.registers+I810_PTE_BASE+(j*4));
277 } 297 }
278 readl(intel_i810_private.registers+I810_PTE_BASE+((j-1)*4)); 298 readl(intel_private.registers+I810_PTE_BASE+((j-1)*4));
279 break; 299 break;
280 default: 300 default:
281 goto out_err; 301 goto out_err;
@@ -298,9 +318,9 @@ static int intel_i810_remove_entries(struct agp_memory *mem, off_t pg_start,
298 return 0; 318 return 0;
299 319
300 for (i = pg_start; i < (mem->page_count + pg_start); i++) { 320 for (i = pg_start; i < (mem->page_count + pg_start); i++) {
301 writel(agp_bridge->scratch_page, intel_i810_private.registers+I810_PTE_BASE+(i*4)); 321 writel(agp_bridge->scratch_page, intel_private.registers+I810_PTE_BASE+(i*4));
302 } 322 }
303 readl(intel_i810_private.registers+I810_PTE_BASE+((i-1)*4)); 323 readl(intel_private.registers+I810_PTE_BASE+((i-1)*4));
304 324
305 agp_bridge->driver->tlb_flush(mem); 325 agp_bridge->driver->tlb_flush(mem);
306 return 0; 326 return 0;
@@ -354,7 +374,7 @@ static struct agp_memory *intel_i810_alloc_by_type(size_t pg_count, int type)
354 struct agp_memory *new; 374 struct agp_memory *new;
355 375
356 if (type == AGP_DCACHE_MEMORY) { 376 if (type == AGP_DCACHE_MEMORY) {
357 if (pg_count != intel_i810_private.num_dcache_entries) 377 if (pg_count != intel_private.num_dcache_entries)
358 return NULL; 378 return NULL;
359 379
360 new = agp_create_memory(1); 380 new = agp_create_memory(1);
@@ -404,18 +424,6 @@ static struct aper_size_info_fixed intel_i830_sizes[] =
404 {512, 131072, 7}, 424 {512, 131072, 7},
405}; 425};
406 426
407static struct _intel_i830_private {
408 struct pci_dev *i830_dev; /* device one */
409 volatile u8 __iomem *registers;
410 volatile u32 __iomem *gtt; /* I915G */
411 /* gtt_entries is the number of gtt entries that are already mapped
412 * to stolen memory. Stolen memory is larger than the memory mapped
413 * through gtt_entries, as it includes some reserved space for the BIOS
414 * popup and for the GTT.
415 */
416 int gtt_entries;
417} intel_i830_private;
418
419static void intel_i830_init_gtt_entries(void) 427static void intel_i830_init_gtt_entries(void)
420{ 428{
421 u16 gmch_ctrl; 429 u16 gmch_ctrl;
@@ -429,7 +437,7 @@ static void intel_i830_init_gtt_entries(void)
429 437
430 if (IS_I965) { 438 if (IS_I965) {
431 u32 pgetbl_ctl; 439 u32 pgetbl_ctl;
432 pgetbl_ctl = readl(intel_i830_private.registers+I810_PGETBL_CTL); 440 pgetbl_ctl = readl(intel_private.registers+I810_PGETBL_CTL);
433 441
434 /* The 965 has a field telling us the size of the GTT, 442 /* The 965 has a field telling us the size of the GTT,
435 * which may be larger than what is necessary to map the 443 * which may be larger than what is necessary to map the
@@ -451,6 +459,22 @@ static void intel_i830_init_gtt_entries(void)
451 size = 512; 459 size = 512;
452 } 460 }
453 size += 4; /* add in BIOS popup space */ 461 size += 4; /* add in BIOS popup space */
462 } else if (IS_G33) {
463 /* G33's GTT size defined in gmch_ctrl */
464 switch (gmch_ctrl & G33_PGETBL_SIZE_MASK) {
465 case G33_PGETBL_SIZE_1M:
466 size = 1024;
467 break;
468 case G33_PGETBL_SIZE_2M:
469 size = 2048;
470 break;
471 default:
472 printk(KERN_INFO PFX "Unknown page table size 0x%x, "
473 "assuming 512KB\n",
474 (gmch_ctrl & G33_PGETBL_SIZE_MASK));
475 size = 512;
476 }
477 size += 4;
454 } else { 478 } else {
455 /* On previous hardware, the GTT size was just what was 479 /* On previous hardware, the GTT size was just what was
456 * required to map the aperture. 480 * required to map the aperture.
@@ -471,7 +495,7 @@ static void intel_i830_init_gtt_entries(void)
471 gtt_entries = MB(8) - KB(size); 495 gtt_entries = MB(8) - KB(size);
472 break; 496 break;
473 case I830_GMCH_GMS_LOCAL: 497 case I830_GMCH_GMS_LOCAL:
474 rdct = readb(intel_i830_private.registers+I830_RDRAM_CHANNEL_TYPE); 498 rdct = readb(intel_private.registers+I830_RDRAM_CHANNEL_TYPE);
475 gtt_entries = (I830_RDRAM_ND(rdct) + 1) * 499 gtt_entries = (I830_RDRAM_ND(rdct) + 1) *
476 MB(ddt[I830_RDRAM_DDT(rdct)]); 500 MB(ddt[I830_RDRAM_DDT(rdct)]);
477 local = 1; 501 local = 1;
@@ -502,7 +526,8 @@ static void intel_i830_init_gtt_entries(void)
502 if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB || 526 if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB ||
503 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB || 527 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB ||
504 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB || 528 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB ||
505 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB || IS_I965 ) 529 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB ||
530 IS_I965 || IS_G33)
506 gtt_entries = MB(48) - KB(size); 531 gtt_entries = MB(48) - KB(size);
507 else 532 else
508 gtt_entries = 0; 533 gtt_entries = 0;
@@ -512,10 +537,24 @@ static void intel_i830_init_gtt_entries(void)
512 if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB || 537 if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB ||
513 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB || 538 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB ||
514 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB || 539 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB ||
515 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB || IS_I965) 540 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB ||
541 IS_I965 || IS_G33)
516 gtt_entries = MB(64) - KB(size); 542 gtt_entries = MB(64) - KB(size);
517 else 543 else
518 gtt_entries = 0; 544 gtt_entries = 0;
545 break;
546 case G33_GMCH_GMS_STOLEN_128M:
547 if (IS_G33)
548 gtt_entries = MB(128) - KB(size);
549 else
550 gtt_entries = 0;
551 break;
552 case G33_GMCH_GMS_STOLEN_256M:
553 if (IS_G33)
554 gtt_entries = MB(256) - KB(size);
555 else
556 gtt_entries = 0;
557 break;
519 default: 558 default:
520 gtt_entries = 0; 559 gtt_entries = 0;
521 break; 560 break;
@@ -529,7 +568,7 @@ static void intel_i830_init_gtt_entries(void)
529 "No pre-allocated video memory detected.\n"); 568 "No pre-allocated video memory detected.\n");
530 gtt_entries /= KB(4); 569 gtt_entries /= KB(4);
531 570
532 intel_i830_private.gtt_entries = gtt_entries; 571 intel_private.gtt_entries = gtt_entries;
533} 572}
534 573
535/* The intel i830 automatically initializes the agp aperture during POST. 574/* The intel i830 automatically initializes the agp aperture during POST.
@@ -547,14 +586,14 @@ static int intel_i830_create_gatt_table(struct agp_bridge_data *bridge)
547 num_entries = size->num_entries; 586 num_entries = size->num_entries;
548 agp_bridge->gatt_table_real = NULL; 587 agp_bridge->gatt_table_real = NULL;
549 588
550 pci_read_config_dword(intel_i830_private.i830_dev,I810_MMADDR,&temp); 589 pci_read_config_dword(intel_private.pcidev,I810_MMADDR,&temp);
551 temp &= 0xfff80000; 590 temp &= 0xfff80000;
552 591
553 intel_i830_private.registers = ioremap(temp,128 * 4096); 592 intel_private.registers = ioremap(temp,128 * 4096);
554 if (!intel_i830_private.registers) 593 if (!intel_private.registers)
555 return -ENOMEM; 594 return -ENOMEM;
556 595
557 temp = readl(intel_i830_private.registers+I810_PGETBL_CTL) & 0xfffff000; 596 temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000;
558 global_cache_flush(); /* FIXME: ?? */ 597 global_cache_flush(); /* FIXME: ?? */
559 598
560 /* we have to call this as early as possible after the MMIO base address is known */ 599 /* we have to call this as early as possible after the MMIO base address is known */
@@ -614,20 +653,20 @@ static int intel_i830_configure(void)
614 653
615 current_size = A_SIZE_FIX(agp_bridge->current_size); 654 current_size = A_SIZE_FIX(agp_bridge->current_size);
616 655
617 pci_read_config_dword(intel_i830_private.i830_dev,I810_GMADDR,&temp); 656 pci_read_config_dword(intel_private.pcidev,I810_GMADDR,&temp);
618 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); 657 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
619 658
620 pci_read_config_word(agp_bridge->dev,I830_GMCH_CTRL,&gmch_ctrl); 659 pci_read_config_word(agp_bridge->dev,I830_GMCH_CTRL,&gmch_ctrl);
621 gmch_ctrl |= I830_GMCH_ENABLED; 660 gmch_ctrl |= I830_GMCH_ENABLED;
622 pci_write_config_word(agp_bridge->dev,I830_GMCH_CTRL,gmch_ctrl); 661 pci_write_config_word(agp_bridge->dev,I830_GMCH_CTRL,gmch_ctrl);
623 662
624 writel(agp_bridge->gatt_bus_addr|I810_PGETBL_ENABLED, intel_i830_private.registers+I810_PGETBL_CTL); 663 writel(agp_bridge->gatt_bus_addr|I810_PGETBL_ENABLED, intel_private.registers+I810_PGETBL_CTL);
625 readl(intel_i830_private.registers+I810_PGETBL_CTL); /* PCI Posting. */ 664 readl(intel_private.registers+I810_PGETBL_CTL); /* PCI Posting. */
626 665
627 if (agp_bridge->driver->needs_scratch_page) { 666 if (agp_bridge->driver->needs_scratch_page) {
628 for (i = intel_i830_private.gtt_entries; i < current_size->num_entries; i++) { 667 for (i = intel_private.gtt_entries; i < current_size->num_entries; i++) {
629 writel(agp_bridge->scratch_page, intel_i830_private.registers+I810_PTE_BASE+(i*4)); 668 writel(agp_bridge->scratch_page, intel_private.registers+I810_PTE_BASE+(i*4));
630 readl(intel_i830_private.registers+I810_PTE_BASE+(i*4)); /* PCI Posting. */ 669 readl(intel_private.registers+I810_PTE_BASE+(i*4)); /* PCI Posting. */
631 } 670 }
632 } 671 }
633 672
@@ -637,7 +676,7 @@ static int intel_i830_configure(void)
637 676
638static void intel_i830_cleanup(void) 677static void intel_i830_cleanup(void)
639{ 678{
640 iounmap(intel_i830_private.registers); 679 iounmap(intel_private.registers);
641} 680}
642 681
643static int intel_i830_insert_entries(struct agp_memory *mem,off_t pg_start, int type) 682static int intel_i830_insert_entries(struct agp_memory *mem,off_t pg_start, int type)
@@ -653,9 +692,9 @@ static int intel_i830_insert_entries(struct agp_memory *mem,off_t pg_start, int
653 temp = agp_bridge->current_size; 692 temp = agp_bridge->current_size;
654 num_entries = A_SIZE_FIX(temp)->num_entries; 693 num_entries = A_SIZE_FIX(temp)->num_entries;
655 694
656 if (pg_start < intel_i830_private.gtt_entries) { 695 if (pg_start < intel_private.gtt_entries) {
657 printk (KERN_DEBUG PFX "pg_start == 0x%.8lx,intel_i830_private.gtt_entries == 0x%.8x\n", 696 printk (KERN_DEBUG PFX "pg_start == 0x%.8lx,intel_private.gtt_entries == 0x%.8x\n",
658 pg_start,intel_i830_private.gtt_entries); 697 pg_start,intel_private.gtt_entries);
659 698
660 printk (KERN_INFO PFX "Trying to insert into local/stolen memory\n"); 699 printk (KERN_INFO PFX "Trying to insert into local/stolen memory\n");
661 goto out_err; 700 goto out_err;
@@ -683,9 +722,9 @@ static int intel_i830_insert_entries(struct agp_memory *mem,off_t pg_start, int
683 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { 722 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
684 writel(agp_bridge->driver->mask_memory(agp_bridge, 723 writel(agp_bridge->driver->mask_memory(agp_bridge,
685 mem->memory[i], mask_type), 724 mem->memory[i], mask_type),
686 intel_i830_private.registers+I810_PTE_BASE+(j*4)); 725 intel_private.registers+I810_PTE_BASE+(j*4));
687 } 726 }
688 readl(intel_i830_private.registers+I810_PTE_BASE+((j-1)*4)); 727 readl(intel_private.registers+I810_PTE_BASE+((j-1)*4));
689 agp_bridge->driver->tlb_flush(mem); 728 agp_bridge->driver->tlb_flush(mem);
690 729
691out: 730out:
@@ -703,15 +742,15 @@ static int intel_i830_remove_entries(struct agp_memory *mem,off_t pg_start,
703 if (mem->page_count == 0) 742 if (mem->page_count == 0)
704 return 0; 743 return 0;
705 744
706 if (pg_start < intel_i830_private.gtt_entries) { 745 if (pg_start < intel_private.gtt_entries) {
707 printk (KERN_INFO PFX "Trying to disable local/stolen memory\n"); 746 printk (KERN_INFO PFX "Trying to disable local/stolen memory\n");
708 return -EINVAL; 747 return -EINVAL;
709 } 748 }
710 749
711 for (i = pg_start; i < (mem->page_count + pg_start); i++) { 750 for (i = pg_start; i < (mem->page_count + pg_start); i++) {
712 writel(agp_bridge->scratch_page, intel_i830_private.registers+I810_PTE_BASE+(i*4)); 751 writel(agp_bridge->scratch_page, intel_private.registers+I810_PTE_BASE+(i*4));
713 } 752 }
714 readl(intel_i830_private.registers+I810_PTE_BASE+((i-1)*4)); 753 readl(intel_private.registers+I810_PTE_BASE+((i-1)*4));
715 754
716 agp_bridge->driver->tlb_flush(mem); 755 agp_bridge->driver->tlb_flush(mem);
717 return 0; 756 return 0;
@@ -734,7 +773,7 @@ static int intel_i915_configure(void)
734 773
735 current_size = A_SIZE_FIX(agp_bridge->current_size); 774 current_size = A_SIZE_FIX(agp_bridge->current_size);
736 775
737 pci_read_config_dword(intel_i830_private.i830_dev, I915_GMADDR, &temp); 776 pci_read_config_dword(intel_private.pcidev, I915_GMADDR, &temp);
738 777
739 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); 778 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
740 779
@@ -742,13 +781,13 @@ static int intel_i915_configure(void)
742 gmch_ctrl |= I830_GMCH_ENABLED; 781 gmch_ctrl |= I830_GMCH_ENABLED;
743 pci_write_config_word(agp_bridge->dev,I830_GMCH_CTRL,gmch_ctrl); 782 pci_write_config_word(agp_bridge->dev,I830_GMCH_CTRL,gmch_ctrl);
744 783
745 writel(agp_bridge->gatt_bus_addr|I810_PGETBL_ENABLED, intel_i830_private.registers+I810_PGETBL_CTL); 784 writel(agp_bridge->gatt_bus_addr|I810_PGETBL_ENABLED, intel_private.registers+I810_PGETBL_CTL);
746 readl(intel_i830_private.registers+I810_PGETBL_CTL); /* PCI Posting. */ 785 readl(intel_private.registers+I810_PGETBL_CTL); /* PCI Posting. */
747 786
748 if (agp_bridge->driver->needs_scratch_page) { 787 if (agp_bridge->driver->needs_scratch_page) {
749 for (i = intel_i830_private.gtt_entries; i < current_size->num_entries; i++) { 788 for (i = intel_private.gtt_entries; i < current_size->num_entries; i++) {
750 writel(agp_bridge->scratch_page, intel_i830_private.gtt+i); 789 writel(agp_bridge->scratch_page, intel_private.gtt+i);
751 readl(intel_i830_private.gtt+i); /* PCI Posting. */ 790 readl(intel_private.gtt+i); /* PCI Posting. */
752 } 791 }
753 } 792 }
754 793
@@ -758,8 +797,8 @@ static int intel_i915_configure(void)
758 797
759static void intel_i915_cleanup(void) 798static void intel_i915_cleanup(void)
760{ 799{
761 iounmap(intel_i830_private.gtt); 800 iounmap(intel_private.gtt);
762 iounmap(intel_i830_private.registers); 801 iounmap(intel_private.registers);
763} 802}
764 803
765static int intel_i915_insert_entries(struct agp_memory *mem,off_t pg_start, 804static int intel_i915_insert_entries(struct agp_memory *mem,off_t pg_start,
@@ -776,9 +815,9 @@ static int intel_i915_insert_entries(struct agp_memory *mem,off_t pg_start,
776 temp = agp_bridge->current_size; 815 temp = agp_bridge->current_size;
777 num_entries = A_SIZE_FIX(temp)->num_entries; 816 num_entries = A_SIZE_FIX(temp)->num_entries;
778 817
779 if (pg_start < intel_i830_private.gtt_entries) { 818 if (pg_start < intel_private.gtt_entries) {
780 printk (KERN_DEBUG PFX "pg_start == 0x%.8lx,intel_i830_private.gtt_entries == 0x%.8x\n", 819 printk (KERN_DEBUG PFX "pg_start == 0x%.8lx,intel_private.gtt_entries == 0x%.8x\n",
781 pg_start,intel_i830_private.gtt_entries); 820 pg_start,intel_private.gtt_entries);
782 821
783 printk (KERN_INFO PFX "Trying to insert into local/stolen memory\n"); 822 printk (KERN_INFO PFX "Trying to insert into local/stolen memory\n");
784 goto out_err; 823 goto out_err;
@@ -805,10 +844,10 @@ static int intel_i915_insert_entries(struct agp_memory *mem,off_t pg_start,
805 844
806 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { 845 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
807 writel(agp_bridge->driver->mask_memory(agp_bridge, 846 writel(agp_bridge->driver->mask_memory(agp_bridge,
808 mem->memory[i], mask_type), intel_i830_private.gtt+j); 847 mem->memory[i], mask_type), intel_private.gtt+j);
809 } 848 }
810 849
811 readl(intel_i830_private.gtt+j-1); 850 readl(intel_private.gtt+j-1);
812 agp_bridge->driver->tlb_flush(mem); 851 agp_bridge->driver->tlb_flush(mem);
813 852
814 out: 853 out:
@@ -826,15 +865,15 @@ static int intel_i915_remove_entries(struct agp_memory *mem,off_t pg_start,
826 if (mem->page_count == 0) 865 if (mem->page_count == 0)
827 return 0; 866 return 0;
828 867
829 if (pg_start < intel_i830_private.gtt_entries) { 868 if (pg_start < intel_private.gtt_entries) {
830 printk (KERN_INFO PFX "Trying to disable local/stolen memory\n"); 869 printk (KERN_INFO PFX "Trying to disable local/stolen memory\n");
831 return -EINVAL; 870 return -EINVAL;
832 } 871 }
833 872
834 for (i = pg_start; i < (mem->page_count + pg_start); i++) { 873 for (i = pg_start; i < (mem->page_count + pg_start); i++) {
835 writel(agp_bridge->scratch_page, intel_i830_private.gtt+i); 874 writel(agp_bridge->scratch_page, intel_private.gtt+i);
836 } 875 }
837 readl(intel_i830_private.gtt+i-1); 876 readl(intel_private.gtt+i-1);
838 877
839 agp_bridge->driver->tlb_flush(mem); 878 agp_bridge->driver->tlb_flush(mem);
840 return 0; 879 return 0;
@@ -850,7 +889,7 @@ static int intel_i9xx_fetch_size(void)
850 int aper_size; /* size in megabytes */ 889 int aper_size; /* size in megabytes */
851 int i; 890 int i;
852 891
853 aper_size = pci_resource_len(intel_i830_private.i830_dev, 2) / MB(1); 892 aper_size = pci_resource_len(intel_private.pcidev, 2) / MB(1);
854 893
855 for (i = 0; i < num_sizes; i++) { 894 for (i = 0; i < num_sizes; i++) {
856 if (aper_size == intel_i830_sizes[i].size) { 895 if (aper_size == intel_i830_sizes[i].size) {
@@ -878,20 +917,20 @@ static int intel_i915_create_gatt_table(struct agp_bridge_data *bridge)
878 num_entries = size->num_entries; 917 num_entries = size->num_entries;
879 agp_bridge->gatt_table_real = NULL; 918 agp_bridge->gatt_table_real = NULL;
880 919
881 pci_read_config_dword(intel_i830_private.i830_dev, I915_MMADDR, &temp); 920 pci_read_config_dword(intel_private.pcidev, I915_MMADDR, &temp);
882 pci_read_config_dword(intel_i830_private.i830_dev, I915_PTEADDR,&temp2); 921 pci_read_config_dword(intel_private.pcidev, I915_PTEADDR,&temp2);
883 922
884 intel_i830_private.gtt = ioremap(temp2, 256 * 1024); 923 intel_private.gtt = ioremap(temp2, 256 * 1024);
885 if (!intel_i830_private.gtt) 924 if (!intel_private.gtt)
886 return -ENOMEM; 925 return -ENOMEM;
887 926
888 temp &= 0xfff80000; 927 temp &= 0xfff80000;
889 928
890 intel_i830_private.registers = ioremap(temp,128 * 4096); 929 intel_private.registers = ioremap(temp,128 * 4096);
891 if (!intel_i830_private.registers) 930 if (!intel_private.registers)
892 return -ENOMEM; 931 return -ENOMEM;
893 932
894 temp = readl(intel_i830_private.registers+I810_PGETBL_CTL) & 0xfffff000; 933 temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000;
895 global_cache_flush(); /* FIXME: ? */ 934 global_cache_flush(); /* FIXME: ? */
896 935
897 /* we have to call this as early as possible after the MMIO base address is known */ 936 /* we have to call this as early as possible after the MMIO base address is known */
@@ -938,20 +977,20 @@ static int intel_i965_create_gatt_table(struct agp_bridge_data *bridge)
938 num_entries = size->num_entries; 977 num_entries = size->num_entries;
939 agp_bridge->gatt_table_real = NULL; 978 agp_bridge->gatt_table_real = NULL;
940 979
941 pci_read_config_dword(intel_i830_private.i830_dev, I915_MMADDR, &temp); 980 pci_read_config_dword(intel_private.pcidev, I915_MMADDR, &temp);
942 981
943 temp &= 0xfff00000; 982 temp &= 0xfff00000;
944 intel_i830_private.gtt = ioremap((temp + (512 * 1024)) , 512 * 1024); 983 intel_private.gtt = ioremap((temp + (512 * 1024)) , 512 * 1024);
945 984
946 if (!intel_i830_private.gtt) 985 if (!intel_private.gtt)
947 return -ENOMEM; 986 return -ENOMEM;
948 987
949 988
950 intel_i830_private.registers = ioremap(temp,128 * 4096); 989 intel_private.registers = ioremap(temp,128 * 4096);
951 if (!intel_i830_private.registers) 990 if (!intel_private.registers)
952 return -ENOMEM; 991 return -ENOMEM;
953 992
954 temp = readl(intel_i830_private.registers+I810_PGETBL_CTL) & 0xfffff000; 993 temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000;
955 global_cache_flush(); /* FIXME: ? */ 994 global_cache_flush(); /* FIXME: ? */
956 995
957 /* we have to call this as early as possible after the MMIO base address is known */ 996 /* we have to call this as early as possible after the MMIO base address is known */
@@ -1722,41 +1761,127 @@ static const struct agp_bridge_driver intel_7505_driver = {
1722 .agp_type_to_mask_type = agp_generic_type_to_mask_type, 1761 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
1723}; 1762};
1724 1763
1725static int find_i810(u16 device) 1764static const struct agp_bridge_driver intel_g33_driver = {
1726{ 1765 .owner = THIS_MODULE,
1727 struct pci_dev *i810_dev; 1766 .aperture_sizes = intel_i830_sizes,
1728 1767 .size_type = FIXED_APER_SIZE,
1729 i810_dev = pci_get_device(PCI_VENDOR_ID_INTEL, device, NULL); 1768 .num_aperture_sizes = 4,
1730 if (!i810_dev) 1769 .needs_scratch_page = TRUE,
1731 return 0; 1770 .configure = intel_i915_configure,
1732 intel_i810_private.i810_dev = i810_dev; 1771 .fetch_size = intel_i9xx_fetch_size,
1733 return 1; 1772 .cleanup = intel_i915_cleanup,
1734} 1773 .tlb_flush = intel_i810_tlbflush,
1774 .mask_memory = intel_i965_mask_memory,
1775 .masks = intel_i810_masks,
1776 .agp_enable = intel_i810_agp_enable,
1777 .cache_flush = global_cache_flush,
1778 .create_gatt_table = intel_i915_create_gatt_table,
1779 .free_gatt_table = intel_i830_free_gatt_table,
1780 .insert_memory = intel_i915_insert_entries,
1781 .remove_memory = intel_i915_remove_entries,
1782 .alloc_by_type = intel_i830_alloc_by_type,
1783 .free_by_type = intel_i810_free_by_type,
1784 .agp_alloc_page = agp_generic_alloc_page,
1785 .agp_destroy_page = agp_generic_destroy_page,
1786 .agp_type_to_mask_type = intel_i830_type_to_mask_type,
1787};
1735 1788
1736static int find_i830(u16 device) 1789static int find_gmch(u16 device)
1737{ 1790{
1738 struct pci_dev *i830_dev; 1791 struct pci_dev *gmch_device;
1739 1792
1740 i830_dev = pci_get_device(PCI_VENDOR_ID_INTEL, device, NULL); 1793 gmch_device = pci_get_device(PCI_VENDOR_ID_INTEL, device, NULL);
1741 if (i830_dev && PCI_FUNC(i830_dev->devfn) != 0) { 1794 if (gmch_device && PCI_FUNC(gmch_device->devfn) != 0) {
1742 i830_dev = pci_get_device(PCI_VENDOR_ID_INTEL, 1795 gmch_device = pci_get_device(PCI_VENDOR_ID_INTEL,
1743 device, i830_dev); 1796 device, gmch_device);
1744 } 1797 }
1745 1798
1746 if (!i830_dev) 1799 if (!gmch_device)
1747 return 0; 1800 return 0;
1748 1801
1749 intel_i830_private.i830_dev = i830_dev; 1802 intel_private.pcidev = gmch_device;
1750 return 1; 1803 return 1;
1751} 1804}
1752 1805
1806/* Table to describe Intel GMCH and AGP/PCIE GART drivers. At least one of
1807 * driver and gmch_driver must be non-null, and find_gmch will determine
1808 * which one should be used if a gmch_chip_id is present.
1809 */
1810static const struct intel_driver_description {
1811 unsigned int chip_id;
1812 unsigned int gmch_chip_id;
1813 unsigned int multi_gmch_chip; /* if we have more gfx chip type on this HB. */
1814 char *name;
1815 const struct agp_bridge_driver *driver;
1816 const struct agp_bridge_driver *gmch_driver;
1817} intel_agp_chipsets[] = {
1818 { PCI_DEVICE_ID_INTEL_82443LX_0, 0, 0, "440LX", &intel_generic_driver, NULL },
1819 { PCI_DEVICE_ID_INTEL_82443BX_0, 0, 0, "440BX", &intel_generic_driver, NULL },
1820 { PCI_DEVICE_ID_INTEL_82443GX_0, 0, 0, "440GX", &intel_generic_driver, NULL },
1821 { PCI_DEVICE_ID_INTEL_82810_MC1, PCI_DEVICE_ID_INTEL_82810_IG1, 0, "i810",
1822 NULL, &intel_810_driver },
1823 { PCI_DEVICE_ID_INTEL_82810_MC3, PCI_DEVICE_ID_INTEL_82810_IG3, 0, "i810",
1824 NULL, &intel_810_driver },
1825 { PCI_DEVICE_ID_INTEL_82810E_MC, PCI_DEVICE_ID_INTEL_82810E_IG, 0, "i810",
1826 NULL, &intel_810_driver },
1827 { PCI_DEVICE_ID_INTEL_82815_MC, PCI_DEVICE_ID_INTEL_82815_CGC, 0, "i815",
1828 &intel_815_driver, &intel_810_driver },
1829 { PCI_DEVICE_ID_INTEL_82820_HB, 0, 0, "i820", &intel_820_driver, NULL },
1830 { PCI_DEVICE_ID_INTEL_82820_UP_HB, 0, 0, "i820", &intel_820_driver, NULL },
1831 { PCI_DEVICE_ID_INTEL_82830_HB, PCI_DEVICE_ID_INTEL_82830_CGC, 0, "830M",
1832 &intel_830mp_driver, &intel_830_driver },
1833 { PCI_DEVICE_ID_INTEL_82840_HB, 0, 0, "i840", &intel_840_driver, NULL },
1834 { PCI_DEVICE_ID_INTEL_82845_HB, 0, 0, "845G", &intel_845_driver, NULL },
1835 { PCI_DEVICE_ID_INTEL_82845G_HB, PCI_DEVICE_ID_INTEL_82845G_IG, 0, "830M",
1836 &intel_845_driver, &intel_830_driver },
1837 { PCI_DEVICE_ID_INTEL_82850_HB, 0, 0, "i850", &intel_850_driver, NULL },
1838 { PCI_DEVICE_ID_INTEL_82855PM_HB, 0, 0, "855PM", &intel_845_driver, NULL },
1839 { PCI_DEVICE_ID_INTEL_82855GM_HB, PCI_DEVICE_ID_INTEL_82855GM_IG, 0, "855GM",
1840 &intel_845_driver, &intel_830_driver },
1841 { PCI_DEVICE_ID_INTEL_82860_HB, 0, 0, "i860", &intel_860_driver, NULL },
1842 { PCI_DEVICE_ID_INTEL_82865_HB, PCI_DEVICE_ID_INTEL_82865_IG, 0, "865",
1843 &intel_845_driver, &intel_830_driver },
1844 { PCI_DEVICE_ID_INTEL_82875_HB, 0, 0, "i875", &intel_845_driver, NULL },
1845 { PCI_DEVICE_ID_INTEL_82915G_HB, PCI_DEVICE_ID_INTEL_82915G_IG, 0, "915G",
1846 &intel_845_driver, &intel_915_driver },
1847 { PCI_DEVICE_ID_INTEL_82915GM_HB, PCI_DEVICE_ID_INTEL_82915GM_IG, 0, "915GM",
1848 &intel_845_driver, &intel_915_driver },
1849 { PCI_DEVICE_ID_INTEL_82945G_HB, PCI_DEVICE_ID_INTEL_82945G_IG, 0, "945G",
1850 &intel_845_driver, &intel_915_driver },
1851 { PCI_DEVICE_ID_INTEL_82945GM_HB, PCI_DEVICE_ID_INTEL_82945GM_IG, 1, "945GM",
1852 &intel_845_driver, &intel_915_driver },
1853 { PCI_DEVICE_ID_INTEL_82945GM_HB, PCI_DEVICE_ID_INTEL_82945GME_IG, 0, "945GME",
1854 &intel_845_driver, &intel_915_driver },
1855 { PCI_DEVICE_ID_INTEL_82946GZ_HB, PCI_DEVICE_ID_INTEL_82946GZ_IG, 0, "946GZ",
1856 &intel_845_driver, &intel_i965_driver },
1857 { PCI_DEVICE_ID_INTEL_82965G_1_HB, PCI_DEVICE_ID_INTEL_82965G_1_IG, 0, "965G",
1858 &intel_845_driver, &intel_i965_driver },
1859 { PCI_DEVICE_ID_INTEL_82965Q_HB, PCI_DEVICE_ID_INTEL_82965Q_IG, 0, "965Q",
1860 &intel_845_driver, &intel_i965_driver },
1861 { PCI_DEVICE_ID_INTEL_82965G_HB, PCI_DEVICE_ID_INTEL_82965G_IG, 0, "965G",
1862 &intel_845_driver, &intel_i965_driver },
1863 { PCI_DEVICE_ID_INTEL_82965GM_HB, PCI_DEVICE_ID_INTEL_82965GM_IG, 1, "965GM",
1864 &intel_845_driver, &intel_i965_driver },
1865 { PCI_DEVICE_ID_INTEL_82965GM_HB, PCI_DEVICE_ID_INTEL_82965GME_IG, 0, "965GME/GLE",
1866 &intel_845_driver, &intel_i965_driver },
1867 { PCI_DEVICE_ID_INTEL_7505_0, 0, 0, "E7505", &intel_7505_driver, NULL },
1868 { PCI_DEVICE_ID_INTEL_7205_0, 0, 0, "E7205", &intel_7505_driver, NULL },
1869 { PCI_DEVICE_ID_INTEL_G33_HB, PCI_DEVICE_ID_INTEL_G33_IG, 0, "G33",
1870 &intel_845_driver, &intel_g33_driver },
1871 { PCI_DEVICE_ID_INTEL_Q35_HB, PCI_DEVICE_ID_INTEL_Q35_IG, 0, "Q35",
1872 &intel_845_driver, &intel_g33_driver },
1873 { PCI_DEVICE_ID_INTEL_Q33_HB, PCI_DEVICE_ID_INTEL_Q33_IG, 0, "Q33",
1874 &intel_845_driver, &intel_g33_driver },
1875 { 0, 0, 0, NULL, NULL, NULL }
1876};
1877
1753static int __devinit agp_intel_probe(struct pci_dev *pdev, 1878static int __devinit agp_intel_probe(struct pci_dev *pdev,
1754 const struct pci_device_id *ent) 1879 const struct pci_device_id *ent)
1755{ 1880{
1756 struct agp_bridge_data *bridge; 1881 struct agp_bridge_data *bridge;
1757 char *name = "(unknown)";
1758 u8 cap_ptr = 0; 1882 u8 cap_ptr = 0;
1759 struct resource *r; 1883 struct resource *r;
1884 int i;
1760 1885
1761 cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP); 1886 cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP);
1762 1887
@@ -1764,195 +1889,46 @@ static int __devinit agp_intel_probe(struct pci_dev *pdev,
1764 if (!bridge) 1889 if (!bridge)
1765 return -ENOMEM; 1890 return -ENOMEM;
1766 1891
1767 switch (pdev->device) { 1892 for (i = 0; intel_agp_chipsets[i].name != NULL; i++) {
1768 case PCI_DEVICE_ID_INTEL_82443LX_0: 1893 /* In case that multiple models of gfx chip may
1769 bridge->driver = &intel_generic_driver; 1894 stand on same host bridge type, this can be
1770 name = "440LX"; 1895 sure we detect the right IGD. */
1771 break; 1896 if (pdev->device == intel_agp_chipsets[i].chip_id) {
1772 case PCI_DEVICE_ID_INTEL_82443BX_0: 1897 if ((intel_agp_chipsets[i].gmch_chip_id != 0) &&
1773 bridge->driver = &intel_generic_driver; 1898 find_gmch(intel_agp_chipsets[i].gmch_chip_id)) {
1774 name = "440BX"; 1899 bridge->driver =
1775 break; 1900 intel_agp_chipsets[i].gmch_driver;
1776 case PCI_DEVICE_ID_INTEL_82443GX_0: 1901 break;
1777 bridge->driver = &intel_generic_driver; 1902 } else if (intel_agp_chipsets[i].multi_gmch_chip) {
1778 name = "440GX"; 1903 continue;
1779 break; 1904 } else {
1780 case PCI_DEVICE_ID_INTEL_82810_MC1: 1905 bridge->driver = intel_agp_chipsets[i].driver;
1781 name = "i810"; 1906 break;
1782 if (!find_i810(PCI_DEVICE_ID_INTEL_82810_IG1)) 1907 }
1783 goto fail;
1784 bridge->driver = &intel_810_driver;
1785 break;
1786 case PCI_DEVICE_ID_INTEL_82810_MC3:
1787 name = "i810 DC100";
1788 if (!find_i810(PCI_DEVICE_ID_INTEL_82810_IG3))
1789 goto fail;
1790 bridge->driver = &intel_810_driver;
1791 break;
1792 case PCI_DEVICE_ID_INTEL_82810E_MC:
1793 name = "i810 E";
1794 if (!find_i810(PCI_DEVICE_ID_INTEL_82810E_IG))
1795 goto fail;
1796 bridge->driver = &intel_810_driver;
1797 break;
1798 case PCI_DEVICE_ID_INTEL_82815_MC:
1799 /*
1800 * The i815 can operate either as an i810 style
1801 * integrated device, or as an AGP4X motherboard.
1802 */
1803 if (find_i810(PCI_DEVICE_ID_INTEL_82815_CGC))
1804 bridge->driver = &intel_810_driver;
1805 else
1806 bridge->driver = &intel_815_driver;
1807 name = "i815";
1808 break;
1809 case PCI_DEVICE_ID_INTEL_82820_HB:
1810 case PCI_DEVICE_ID_INTEL_82820_UP_HB:
1811 bridge->driver = &intel_820_driver;
1812 name = "i820";
1813 break;
1814 case PCI_DEVICE_ID_INTEL_82830_HB:
1815 if (find_i830(PCI_DEVICE_ID_INTEL_82830_CGC))
1816 bridge->driver = &intel_830_driver;
1817 else
1818 bridge->driver = &intel_830mp_driver;
1819 name = "830M";
1820 break;
1821 case PCI_DEVICE_ID_INTEL_82840_HB:
1822 bridge->driver = &intel_840_driver;
1823 name = "i840";
1824 break;
1825 case PCI_DEVICE_ID_INTEL_82845_HB:
1826 bridge->driver = &intel_845_driver;
1827 name = "i845";
1828 break;
1829 case PCI_DEVICE_ID_INTEL_82845G_HB:
1830 if (find_i830(PCI_DEVICE_ID_INTEL_82845G_IG))
1831 bridge->driver = &intel_830_driver;
1832 else
1833 bridge->driver = &intel_845_driver;
1834 name = "845G";
1835 break;
1836 case PCI_DEVICE_ID_INTEL_82850_HB:
1837 bridge->driver = &intel_850_driver;
1838 name = "i850";
1839 break;
1840 case PCI_DEVICE_ID_INTEL_82855PM_HB:
1841 bridge->driver = &intel_845_driver;
1842 name = "855PM";
1843 break;
1844 case PCI_DEVICE_ID_INTEL_82855GM_HB:
1845 if (find_i830(PCI_DEVICE_ID_INTEL_82855GM_IG)) {
1846 bridge->driver = &intel_830_driver;
1847 name = "855";
1848 } else {
1849 bridge->driver = &intel_845_driver;
1850 name = "855GM";
1851 } 1908 }
1852 break; 1909 }
1853 case PCI_DEVICE_ID_INTEL_82860_HB: 1910
1854 bridge->driver = &intel_860_driver; 1911 if (intel_agp_chipsets[i].name == NULL) {
1855 name = "i860";
1856 break;
1857 case PCI_DEVICE_ID_INTEL_82865_HB:
1858 if (find_i830(PCI_DEVICE_ID_INTEL_82865_IG))
1859 bridge->driver = &intel_830_driver;
1860 else
1861 bridge->driver = &intel_845_driver;
1862 name = "865";
1863 break;
1864 case PCI_DEVICE_ID_INTEL_82875_HB:
1865 bridge->driver = &intel_845_driver;
1866 name = "i875";
1867 break;
1868 case PCI_DEVICE_ID_INTEL_82915G_HB:
1869 if (find_i830(PCI_DEVICE_ID_INTEL_82915G_IG))
1870 bridge->driver = &intel_915_driver;
1871 else
1872 bridge->driver = &intel_845_driver;
1873 name = "915G";
1874 break;
1875 case PCI_DEVICE_ID_INTEL_82915GM_HB:
1876 if (find_i830(PCI_DEVICE_ID_INTEL_82915GM_IG))
1877 bridge->driver = &intel_915_driver;
1878 else
1879 bridge->driver = &intel_845_driver;
1880 name = "915GM";
1881 break;
1882 case PCI_DEVICE_ID_INTEL_82945G_HB:
1883 if (find_i830(PCI_DEVICE_ID_INTEL_82945G_IG))
1884 bridge->driver = &intel_915_driver;
1885 else
1886 bridge->driver = &intel_845_driver;
1887 name = "945G";
1888 break;
1889 case PCI_DEVICE_ID_INTEL_82945GM_HB:
1890 if (find_i830(PCI_DEVICE_ID_INTEL_82945GM_IG))
1891 bridge->driver = &intel_915_driver;
1892 else
1893 bridge->driver = &intel_845_driver;
1894 name = "945GM";
1895 break;
1896 case PCI_DEVICE_ID_INTEL_82946GZ_HB:
1897 if (find_i830(PCI_DEVICE_ID_INTEL_82946GZ_IG))
1898 bridge->driver = &intel_i965_driver;
1899 else
1900 bridge->driver = &intel_845_driver;
1901 name = "946GZ";
1902 break;
1903 case PCI_DEVICE_ID_INTEL_82965G_1_HB:
1904 if (find_i830(PCI_DEVICE_ID_INTEL_82965G_1_IG))
1905 bridge->driver = &intel_i965_driver;
1906 else
1907 bridge->driver = &intel_845_driver;
1908 name = "965G";
1909 break;
1910 case PCI_DEVICE_ID_INTEL_82965Q_HB:
1911 if (find_i830(PCI_DEVICE_ID_INTEL_82965Q_IG))
1912 bridge->driver = &intel_i965_driver;
1913 else
1914 bridge->driver = &intel_845_driver;
1915 name = "965Q";
1916 break;
1917 case PCI_DEVICE_ID_INTEL_82965G_HB:
1918 if (find_i830(PCI_DEVICE_ID_INTEL_82965G_IG))
1919 bridge->driver = &intel_i965_driver;
1920 else
1921 bridge->driver = &intel_845_driver;
1922 name = "965G";
1923 break;
1924 case PCI_DEVICE_ID_INTEL_82965GM_HB:
1925 if (find_i830(PCI_DEVICE_ID_INTEL_82965GM_IG))
1926 bridge->driver = &intel_i965_driver;
1927 else
1928 bridge->driver = &intel_845_driver;
1929 name = "965GM";
1930 break;
1931 case PCI_DEVICE_ID_INTEL_7505_0:
1932 bridge->driver = &intel_7505_driver;
1933 name = "E7505";
1934 break;
1935 case PCI_DEVICE_ID_INTEL_7205_0:
1936 bridge->driver = &intel_7505_driver;
1937 name = "E7205";
1938 break;
1939 default:
1940 if (cap_ptr) 1912 if (cap_ptr)
1941 printk(KERN_WARNING PFX "Unsupported Intel chipset (device id: %04x)\n", 1913 printk(KERN_WARNING PFX "Unsupported Intel chipset"
1942 pdev->device); 1914 "(device id: %04x)\n", pdev->device);
1915 agp_put_bridge(bridge);
1916 return -ENODEV;
1917 }
1918
1919 if (bridge->driver == NULL) {
1920 printk(KERN_WARNING PFX "Failed to find bridge device "
1921 "(chip_id: %04x)\n", intel_agp_chipsets[i].gmch_chip_id);
1943 agp_put_bridge(bridge); 1922 agp_put_bridge(bridge);
1944 return -ENODEV; 1923 return -ENODEV;
1945 }; 1924 }
1946 1925
1947 bridge->dev = pdev; 1926 bridge->dev = pdev;
1948 bridge->capndx = cap_ptr; 1927 bridge->capndx = cap_ptr;
1928 bridge->dev_private_data = &intel_private;
1949 1929
1950 if (bridge->driver == &intel_810_driver) 1930 printk(KERN_INFO PFX "Detected an Intel %s Chipset.\n",
1951 bridge->dev_private_data = &intel_i810_private; 1931 intel_agp_chipsets[i].name);
1952 else if (bridge->driver == &intel_830_driver)
1953 bridge->dev_private_data = &intel_i830_private;
1954
1955 printk(KERN_INFO PFX "Detected an Intel %s Chipset.\n", name);
1956 1932
1957 /* 1933 /*
1958 * The following fixes the case where the BIOS has "forgotten" to 1934 * The following fixes the case where the BIOS has "forgotten" to
@@ -1988,12 +1964,6 @@ static int __devinit agp_intel_probe(struct pci_dev *pdev,
1988 1964
1989 pci_set_drvdata(pdev, bridge); 1965 pci_set_drvdata(pdev, bridge);
1990 return agp_add_bridge(bridge); 1966 return agp_add_bridge(bridge);
1991
1992fail:
1993 printk(KERN_ERR PFX "Detected an Intel %s chipset, "
1994 "but could not find the secondary device.\n", name);
1995 agp_put_bridge(bridge);
1996 return -ENODEV;
1997} 1967}
1998 1968
1999static void __devexit agp_intel_remove(struct pci_dev *pdev) 1969static void __devexit agp_intel_remove(struct pci_dev *pdev)
@@ -2002,10 +1972,8 @@ static void __devexit agp_intel_remove(struct pci_dev *pdev)
2002 1972
2003 agp_remove_bridge(bridge); 1973 agp_remove_bridge(bridge);
2004 1974
2005 if (intel_i810_private.i810_dev) 1975 if (intel_private.pcidev)
2006 pci_dev_put(intel_i810_private.i810_dev); 1976 pci_dev_put(intel_private.pcidev);
2007 if (intel_i830_private.i830_dev)
2008 pci_dev_put(intel_i830_private.i830_dev);
2009 1977
2010 agp_put_bridge(bridge); 1978 agp_put_bridge(bridge);
2011} 1979}
@@ -2021,10 +1989,8 @@ static int agp_intel_resume(struct pci_dev *pdev)
2021 * as host bridge (00:00) resumes before graphics device (02:00), 1989 * as host bridge (00:00) resumes before graphics device (02:00),
2022 * then our access to its pci space can work right. 1990 * then our access to its pci space can work right.
2023 */ 1991 */
2024 if (intel_i810_private.i810_dev) 1992 if (intel_private.pcidev)
2025 pci_restore_state(intel_i810_private.i810_dev); 1993 pci_restore_state(intel_private.pcidev);
2026 if (intel_i830_private.i830_dev)
2027 pci_restore_state(intel_i830_private.i830_dev);
2028 1994
2029 if (bridge->driver == &intel_generic_driver) 1995 if (bridge->driver == &intel_generic_driver)
2030 intel_configure(); 1996 intel_configure();
@@ -2087,6 +2053,9 @@ static struct pci_device_id agp_intel_pci_table[] = {
2087 ID(PCI_DEVICE_ID_INTEL_82965Q_HB), 2053 ID(PCI_DEVICE_ID_INTEL_82965Q_HB),
2088 ID(PCI_DEVICE_ID_INTEL_82965G_HB), 2054 ID(PCI_DEVICE_ID_INTEL_82965G_HB),
2089 ID(PCI_DEVICE_ID_INTEL_82965GM_HB), 2055 ID(PCI_DEVICE_ID_INTEL_82965GM_HB),
2056 ID(PCI_DEVICE_ID_INTEL_G33_HB),
2057 ID(PCI_DEVICE_ID_INTEL_Q35_HB),
2058 ID(PCI_DEVICE_ID_INTEL_Q33_HB),
2090 { } 2059 { }
2091}; 2060};
2092 2061
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index c72ee97d3892..ca376b92162c 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -1061,6 +1061,7 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
1061 1061
1062 if (data & info->ignore_status_mask) { 1062 if (data & info->ignore_status_mask) {
1063 info->icount.rx++; 1063 info->icount.rx++;
1064 spin_unlock(&cinfo->card_lock);
1064 return; 1065 return;
1065 } 1066 }
1066 if (tty_buffer_request_room(tty, 1)) { 1067 if (tty_buffer_request_room(tty, 1)) {
diff --git a/drivers/char/drm/Kconfig b/drivers/char/drm/Kconfig
index ef833a1c27eb..0b7ffa5191c6 100644
--- a/drivers/char/drm/Kconfig
+++ b/drivers/char/drm/Kconfig
@@ -6,7 +6,7 @@
6# 6#
7config DRM 7config DRM
8 tristate "Direct Rendering Manager (XFree86 4.1.0 and higher DRI support)" 8 tristate "Direct Rendering Manager (XFree86 4.1.0 and higher DRI support)"
9 depends on (AGP || AGP=n) && PCI 9 depends on (AGP || AGP=n) && PCI && !EMULATED_CMPXCHG
10 help 10 help
11 Kernel-level support for the Direct Rendering Infrastructure (DRI) 11 Kernel-level support for the Direct Rendering Infrastructure (DRI)
12 introduced in XFree86 4.0. If you say Y here, you need to select 12 introduced in XFree86 4.0. If you say Y here, you need to select
diff --git a/drivers/char/drm/drm_drawable.c b/drivers/char/drm/drm_drawable.c
index de37d5f74563..b33313be2547 100644
--- a/drivers/char/drm/drm_drawable.c
+++ b/drivers/char/drm/drm_drawable.c
@@ -172,38 +172,49 @@ int drm_rmdraw(DRM_IOCTL_ARGS)
172 172
173 bitfield_length = idx + 1; 173 bitfield_length = idx + 1;
174 174
175 if (idx != id / (8 * sizeof(*bitfield))) 175 bitfield = NULL;
176 bitfield = drm_alloc(bitfield_length *
177 sizeof(*bitfield), DRM_MEM_BUFS);
178 176
179 if (!bitfield && bitfield_length) { 177 if (bitfield_length) {
180 bitfield = dev->drw_bitfield; 178 if (bitfield_length != dev->drw_bitfield_length)
181 bitfield_length = dev->drw_bitfield_length; 179 bitfield = drm_alloc(bitfield_length *
180 sizeof(*bitfield),
181 DRM_MEM_BUFS);
182
183 if (!bitfield) {
184 bitfield = dev->drw_bitfield;
185 bitfield_length = dev->drw_bitfield_length;
186 }
182 } 187 }
183 } 188 }
184 189
185 if (bitfield != dev->drw_bitfield) { 190 if (bitfield != dev->drw_bitfield) {
186 info_length = 8 * sizeof(*bitfield) * bitfield_length; 191 info_length = 8 * sizeof(*bitfield) * bitfield_length;
187 192
188 info = drm_alloc(info_length * sizeof(*info), DRM_MEM_BUFS); 193 if (info_length) {
194 info = drm_alloc(info_length * sizeof(*info),
195 DRM_MEM_BUFS);
189 196
190 if (!info && info_length) { 197 if (!info) {
191 info = dev->drw_info; 198 info = dev->drw_info;
192 info_length = dev->drw_info_length; 199 info_length = dev->drw_info_length;
193 } 200 }
201 } else
202 info = NULL;
194 203
195 spin_lock_irqsave(&dev->drw_lock, irqflags); 204 spin_lock_irqsave(&dev->drw_lock, irqflags);
196 205
197 memcpy(bitfield, dev->drw_bitfield, bitfield_length * 206 if (bitfield)
198 sizeof(*bitfield)); 207 memcpy(bitfield, dev->drw_bitfield, bitfield_length *
208 sizeof(*bitfield));
199 drm_free(dev->drw_bitfield, sizeof(*bitfield) * 209 drm_free(dev->drw_bitfield, sizeof(*bitfield) *
200 dev->drw_bitfield_length, DRM_MEM_BUFS); 210 dev->drw_bitfield_length, DRM_MEM_BUFS);
201 dev->drw_bitfield = bitfield; 211 dev->drw_bitfield = bitfield;
202 dev->drw_bitfield_length = bitfield_length; 212 dev->drw_bitfield_length = bitfield_length;
203 213
204 if (info != dev->drw_info) { 214 if (info != dev->drw_info) {
205 memcpy(info, dev->drw_info, info_length * 215 if (info)
206 sizeof(*info)); 216 memcpy(info, dev->drw_info, info_length *
217 sizeof(*info));
207 drm_free(dev->drw_info, sizeof(*info) * 218 drm_free(dev->drw_info, sizeof(*info) *
208 dev->drw_info_length, DRM_MEM_BUFS); 219 dev->drw_info_length, DRM_MEM_BUFS);
209 dev->drw_info = info; 220 dev->drw_info = info;
diff --git a/drivers/char/drm/drm_pciids.h b/drivers/char/drm/drm_pciids.h
index 31cdde83713b..177ccc07f968 100644
--- a/drivers/char/drm/drm_pciids.h
+++ b/drivers/char/drm/drm_pciids.h
@@ -102,13 +102,20 @@
102 {0x1002, 0x5653, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV410|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ 102 {0x1002, 0x5653, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV410|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
103 {0x1002, 0x5834, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS300|RADEON_IS_IGP}, \ 103 {0x1002, 0x5834, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS300|RADEON_IS_IGP}, \
104 {0x1002, 0x5835, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS300|RADEON_IS_IGP|RADEON_IS_MOBILITY}, \ 104 {0x1002, 0x5835, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS300|RADEON_IS_IGP|RADEON_IS_MOBILITY}, \
105 {0x1002, 0x5954, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS400|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART}, \
105 {0x1002, 0x5955, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS400|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART}, \ 106 {0x1002, 0x5955, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS400|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART}, \
107 {0x1002, 0x5974, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS400|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART}, \
108 {0x1002, 0x5975, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS400|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART}, \
106 {0x1002, 0x5960, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280}, \ 109 {0x1002, 0x5960, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280}, \
107 {0x1002, 0x5961, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280}, \ 110 {0x1002, 0x5961, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280}, \
108 {0x1002, 0x5962, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280}, \ 111 {0x1002, 0x5962, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280}, \
109 {0x1002, 0x5964, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280}, \ 112 {0x1002, 0x5964, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280}, \
110 {0x1002, 0x5965, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280}, \ 113 {0x1002, 0x5965, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280}, \
111 {0x1002, 0x5969, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV100}, \ 114 {0x1002, 0x5969, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV100}, \
115 {0x1002, 0x5a41, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS400|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART}, \
116 {0x1002, 0x5a42, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS400|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART}, \
117 {0x1002, 0x5a61, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS400|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART}, \
118 {0x1002, 0x5a62, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS400|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART}, \
112 {0x1002, 0x5b60, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_NEW_MEMMAP}, \ 119 {0x1002, 0x5b60, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_NEW_MEMMAP}, \
113 {0x1002, 0x5b62, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_NEW_MEMMAP}, \ 120 {0x1002, 0x5b62, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_NEW_MEMMAP}, \
114 {0x1002, 0x5b63, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_NEW_MEMMAP}, \ 121 {0x1002, 0x5b63, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_NEW_MEMMAP}, \
diff --git a/drivers/char/drm/i915_irq.c b/drivers/char/drm/i915_irq.c
index 78c1ae28f17c..b92062a239f1 100644
--- a/drivers/char/drm/i915_irq.c
+++ b/drivers/char/drm/i915_irq.c
@@ -582,7 +582,7 @@ void i915_driver_irq_postinstall(drm_device_t * dev)
582{ 582{
583 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; 583 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
584 584
585 dev_priv->swaps_lock = SPIN_LOCK_UNLOCKED; 585 spin_lock_init(&dev_priv->swaps_lock);
586 INIT_LIST_HEAD(&dev_priv->vbl_swaps.head); 586 INIT_LIST_HEAD(&dev_priv->vbl_swaps.head);
587 dev_priv->swaps_pending = 0; 587 dev_priv->swaps_pending = 0;
588 588
diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c
index b3d4ccc33a47..154f42203b05 100644
--- a/drivers/char/n_tty.c
+++ b/drivers/char/n_tty.c
@@ -1191,6 +1191,7 @@ static int job_control(struct tty_struct *tty, struct file *file)
1191 is_current_pgrp_orphaned()) 1191 is_current_pgrp_orphaned())
1192 return -EIO; 1192 return -EIO;
1193 kill_pgrp(task_pgrp(current), SIGTTIN, 1); 1193 kill_pgrp(task_pgrp(current), SIGTTIN, 1);
1194 set_thread_flag(TIF_SIGPENDING);
1194 return -ERESTARTSYS; 1195 return -ERESTARTSYS;
1195 } 1196 }
1196 } 1197 }
diff --git a/drivers/char/random.c b/drivers/char/random.c
index 46c1b97748b6..0474cac4a84e 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -760,7 +760,7 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min,
760 760
761static void extract_buf(struct entropy_store *r, __u8 *out) 761static void extract_buf(struct entropy_store *r, __u8 *out)
762{ 762{
763 int i, x; 763 int i;
764 __u32 data[16], buf[5 + SHA_WORKSPACE_WORDS]; 764 __u32 data[16], buf[5 + SHA_WORKSPACE_WORDS];
765 765
766 sha_init(buf); 766 sha_init(buf);
@@ -772,9 +772,11 @@ static void extract_buf(struct entropy_store *r, __u8 *out)
772 * attempts to find previous ouputs), unless the hash 772 * attempts to find previous ouputs), unless the hash
773 * function can be inverted. 773 * function can be inverted.
774 */ 774 */
775 for (i = 0, x = 0; i < r->poolinfo->poolwords; i += 16, x+=2) { 775 for (i = 0; i < r->poolinfo->poolwords; i += 16) {
776 sha_transform(buf, (__u8 *)r->pool+i, buf + 5); 776 /* hash blocks of 16 words = 512 bits */
777 add_entropy_words(r, &buf[x % 5], 1); 777 sha_transform(buf, (__u8 *)(r->pool + i), buf + 5);
778 /* feed back portion of the resulting hash */
779 add_entropy_words(r, &buf[i % 5], 1);
778 } 780 }
779 781
780 /* 782 /*
@@ -782,7 +784,7 @@ static void extract_buf(struct entropy_store *r, __u8 *out)
782 * portion of the pool while mixing, and hash one 784 * portion of the pool while mixing, and hash one
783 * final time. 785 * final time.
784 */ 786 */
785 __add_entropy_words(r, &buf[x % 5], 1, data); 787 __add_entropy_words(r, &buf[i % 5], 1, data);
786 sha_transform(buf, (__u8 *)data, buf + 5); 788 sha_transform(buf, (__u8 *)data, buf + 5);
787 789
788 /* 790 /*
@@ -1018,37 +1020,44 @@ random_poll(struct file *file, poll_table * wait)
1018 return mask; 1020 return mask;
1019} 1021}
1020 1022
1021static ssize_t 1023static int
1022random_write(struct file * file, const char __user * buffer, 1024write_pool(struct entropy_store *r, const char __user *buffer, size_t count)
1023 size_t count, loff_t *ppos)
1024{ 1025{
1025 int ret = 0;
1026 size_t bytes; 1026 size_t bytes;
1027 __u32 buf[16]; 1027 __u32 buf[16];
1028 const char __user *p = buffer; 1028 const char __user *p = buffer;
1029 size_t c = count;
1030 1029
1031 while (c > 0) { 1030 while (count > 0) {
1032 bytes = min(c, sizeof(buf)); 1031 bytes = min(count, sizeof(buf));
1032 if (copy_from_user(&buf, p, bytes))
1033 return -EFAULT;
1033 1034
1034 bytes -= copy_from_user(&buf, p, bytes); 1035 count -= bytes;
1035 if (!bytes) {
1036 ret = -EFAULT;
1037 break;
1038 }
1039 c -= bytes;
1040 p += bytes; 1036 p += bytes;
1041 1037
1042 add_entropy_words(&input_pool, buf, (bytes + 3) / 4); 1038 add_entropy_words(r, buf, (bytes + 3) / 4);
1043 }
1044 if (p == buffer) {
1045 return (ssize_t)ret;
1046 } else {
1047 struct inode *inode = file->f_path.dentry->d_inode;
1048 inode->i_mtime = current_fs_time(inode->i_sb);
1049 mark_inode_dirty(inode);
1050 return (ssize_t)(p - buffer);
1051 } 1039 }
1040
1041 return 0;
1042}
1043
1044static ssize_t
1045random_write(struct file * file, const char __user * buffer,
1046 size_t count, loff_t *ppos)
1047{
1048 size_t ret;
1049 struct inode *inode = file->f_path.dentry->d_inode;
1050
1051 ret = write_pool(&blocking_pool, buffer, count);
1052 if (ret)
1053 return ret;
1054 ret = write_pool(&nonblocking_pool, buffer, count);
1055 if (ret)
1056 return ret;
1057
1058 inode->i_mtime = current_fs_time(inode->i_sb);
1059 mark_inode_dirty(inode);
1060 return (ssize_t)count;
1052} 1061}
1053 1062
1054static int 1063static int
@@ -1087,8 +1096,8 @@ random_ioctl(struct inode * inode, struct file * file,
1087 return -EINVAL; 1096 return -EINVAL;
1088 if (get_user(size, p++)) 1097 if (get_user(size, p++))
1089 return -EFAULT; 1098 return -EFAULT;
1090 retval = random_write(file, (const char __user *) p, 1099 retval = write_pool(&input_pool, (const char __user *)p,
1091 size, &file->f_pos); 1100 size);
1092 if (retval < 0) 1101 if (retval < 0)
1093 return retval; 1102 return retval;
1094 credit_entropy_store(&input_pool, ent_count); 1103 credit_entropy_store(&input_pool, ent_count);
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
index e45113a7a472..45bf2a262a85 100644
--- a/drivers/char/stallion.c
+++ b/drivers/char/stallion.c
@@ -2172,11 +2172,12 @@ static int __devinit stl_initech(struct stlbrd *brdp)
2172 } 2172 }
2173 status = inb(ioaddr + ECH_PNLSTATUS); 2173 status = inb(ioaddr + ECH_PNLSTATUS);
2174 if ((status & ECH_PNLIDMASK) != nxtid) 2174 if ((status & ECH_PNLIDMASK) != nxtid)
2175 goto err_fr; 2175 break;
2176 panelp = kzalloc(sizeof(struct stlpanel), GFP_KERNEL); 2176 panelp = kzalloc(sizeof(struct stlpanel), GFP_KERNEL);
2177 if (!panelp) { 2177 if (!panelp) {
2178 printk("STALLION: failed to allocate memory " 2178 printk("STALLION: failed to allocate memory "
2179 "(size=%Zd)\n", sizeof(struct stlpanel)); 2179 "(size=%Zd)\n", sizeof(struct stlpanel));
2180 retval = -ENOMEM;
2180 goto err_fr; 2181 goto err_fr;
2181 } 2182 }
2182 panelp->magic = STL_PANELMAGIC; 2183 panelp->magic = STL_PANELMAGIC;
@@ -2223,8 +2224,10 @@ static int __devinit stl_initech(struct stlbrd *brdp)
2223 brdp->nrports += panelp->nrports; 2224 brdp->nrports += panelp->nrports;
2224 brdp->panels[panelnr++] = panelp; 2225 brdp->panels[panelnr++] = panelp;
2225 if ((brdp->brdtype != BRD_ECHPCI) && 2226 if ((brdp->brdtype != BRD_ECHPCI) &&
2226 (ioaddr >= (brdp->ioaddr2 + brdp->iosize2))) 2227 (ioaddr >= (brdp->ioaddr2 + brdp->iosize2))) {
2228 retval = -EINVAL;
2227 goto err_fr; 2229 goto err_fr;
2230 }
2228 } 2231 }
2229 2232
2230 brdp->nrpanels = panelnr; 2233 brdp->nrpanels = panelnr;
@@ -2371,6 +2374,7 @@ static int __devinit stl_pciprobe(struct pci_dev *pdev,
2371 dev_err(&pdev->dev, "too many boards found, " 2374 dev_err(&pdev->dev, "too many boards found, "
2372 "maximum supported %d\n", STL_MAXBRDS); 2375 "maximum supported %d\n", STL_MAXBRDS);
2373 mutex_unlock(&stl_brdslock); 2376 mutex_unlock(&stl_brdslock);
2377 retval = -ENODEV;
2374 goto err_fr; 2378 goto err_fr;
2375 } 2379 }
2376 brdp->brdnr = (unsigned int)brdnr; 2380 brdp->brdnr = (unsigned int)brdnr;
@@ -4710,6 +4714,29 @@ static int __init stallion_module_init(void)
4710 spin_lock_init(&stallion_lock); 4714 spin_lock_init(&stallion_lock);
4711 spin_lock_init(&brd_lock); 4715 spin_lock_init(&brd_lock);
4712 4716
4717 stl_serial = alloc_tty_driver(STL_MAXBRDS * STL_MAXPORTS);
4718 if (!stl_serial) {
4719 retval = -ENOMEM;
4720 goto err;
4721 }
4722
4723 stl_serial->owner = THIS_MODULE;
4724 stl_serial->driver_name = stl_drvname;
4725 stl_serial->name = "ttyE";
4726 stl_serial->major = STL_SERIALMAJOR;
4727 stl_serial->minor_start = 0;
4728 stl_serial->type = TTY_DRIVER_TYPE_SERIAL;
4729 stl_serial->subtype = SERIAL_TYPE_NORMAL;
4730 stl_serial->init_termios = stl_deftermios;
4731 stl_serial->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
4732 tty_set_operations(stl_serial, &stl_ops);
4733
4734 retval = tty_register_driver(stl_serial);
4735 if (retval) {
4736 printk("STALLION: failed to register serial driver\n");
4737 goto err_frtty;
4738 }
4739
4713/* 4740/*
4714 * Find any dynamically supported boards. That is via module load 4741 * Find any dynamically supported boards. That is via module load
4715 * line options. 4742 * line options.
@@ -4739,13 +4766,9 @@ static int __init stallion_module_init(void)
4739 4766
4740 /* this has to be _after_ isa finding because of locking */ 4767 /* this has to be _after_ isa finding because of locking */
4741 retval = pci_register_driver(&stl_pcidriver); 4768 retval = pci_register_driver(&stl_pcidriver);
4742 if (retval && stl_nrbrds == 0) 4769 if (retval && stl_nrbrds == 0) {
4743 goto err; 4770 printk(KERN_ERR "STALLION: can't register pci driver\n");
4744 4771 goto err_unrtty;
4745 stl_serial = alloc_tty_driver(STL_MAXBRDS * STL_MAXPORTS);
4746 if (!stl_serial) {
4747 retval = -ENOMEM;
4748 goto err_pcidr;
4749 } 4772 }
4750 4773
4751/* 4774/*
@@ -4756,43 +4779,18 @@ static int __init stallion_module_init(void)
4756 printk("STALLION: failed to register serial board device\n"); 4779 printk("STALLION: failed to register serial board device\n");
4757 4780
4758 stallion_class = class_create(THIS_MODULE, "staliomem"); 4781 stallion_class = class_create(THIS_MODULE, "staliomem");
4759 if (IS_ERR(stallion_class)) { 4782 if (IS_ERR(stallion_class))
4760 retval = PTR_ERR(stallion_class); 4783 printk("STALLION: failed to create class\n");
4761 goto err_reg;
4762 }
4763 for (i = 0; i < 4; i++) 4784 for (i = 0; i < 4; i++)
4764 class_device_create(stallion_class, NULL, 4785 class_device_create(stallion_class, NULL,
4765 MKDEV(STL_SIOMEMMAJOR, i), NULL, 4786 MKDEV(STL_SIOMEMMAJOR, i), NULL,
4766 "staliomem%d", i); 4787 "staliomem%d", i);
4767 4788
4768 stl_serial->owner = THIS_MODULE;
4769 stl_serial->driver_name = stl_drvname;
4770 stl_serial->name = "ttyE";
4771 stl_serial->major = STL_SERIALMAJOR;
4772 stl_serial->minor_start = 0;
4773 stl_serial->type = TTY_DRIVER_TYPE_SERIAL;
4774 stl_serial->subtype = SERIAL_TYPE_NORMAL;
4775 stl_serial->init_termios = stl_deftermios;
4776 stl_serial->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
4777 tty_set_operations(stl_serial, &stl_ops);
4778
4779 retval = tty_register_driver(stl_serial);
4780 if (retval) {
4781 printk("STALLION: failed to register serial driver\n");
4782 goto err_clsdev;
4783 }
4784
4785 return 0; 4789 return 0;
4786err_clsdev: 4790err_unrtty:
4787 for (i = 0; i < 4; i++) 4791 tty_unregister_driver(stl_serial);
4788 class_device_destroy(stallion_class, MKDEV(STL_SIOMEMMAJOR, i)); 4792err_frtty:
4789 class_destroy(stallion_class);
4790err_reg:
4791 unregister_chrdev(STL_SIOMEMMAJOR, "staliomem");
4792 put_tty_driver(stl_serial); 4793 put_tty_driver(stl_serial);
4793err_pcidr:
4794 pci_unregister_driver(&stl_pcidriver);
4795 stl_free_isabrds();
4796err: 4794err:
4797 return retval; 4795 return retval;
4798} 4796}
@@ -4821,8 +4819,6 @@ static void __exit stallion_module_exit(void)
4821 tty_unregister_device(stl_serial, 4819 tty_unregister_device(stl_serial,
4822 brdp->brdnr * STL_MAXPORTS + j); 4820 brdp->brdnr * STL_MAXPORTS + j);
4823 } 4821 }
4824 tty_unregister_driver(stl_serial);
4825 put_tty_driver(stl_serial);
4826 4822
4827 for (i = 0; i < 4; i++) 4823 for (i = 0; i < 4; i++)
4828 class_device_destroy(stallion_class, MKDEV(STL_SIOMEMMAJOR, i)); 4824 class_device_destroy(stallion_class, MKDEV(STL_SIOMEMMAJOR, i));
@@ -4834,6 +4830,9 @@ static void __exit stallion_module_exit(void)
4834 pci_unregister_driver(&stl_pcidriver); 4830 pci_unregister_driver(&stl_pcidriver);
4835 4831
4836 stl_free_isabrds(); 4832 stl_free_isabrds();
4833
4834 tty_unregister_driver(stl_serial);
4835 put_tty_driver(stl_serial);
4837} 4836}
4838 4837
4839module_init(stallion_module_init); 4838module_init(stallion_module_init);
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 75d2a46e106f..3752edc30c36 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -1148,7 +1148,8 @@ int tty_check_change(struct tty_struct * tty)
1148 return 0; 1148 return 0;
1149 if (is_current_pgrp_orphaned()) 1149 if (is_current_pgrp_orphaned())
1150 return -EIO; 1150 return -EIO;
1151 (void) kill_pgrp(task_pgrp(current), SIGTTOU, 1); 1151 kill_pgrp(task_pgrp(current), SIGTTOU, 1);
1152 set_thread_flag(TIF_SIGPENDING);
1152 return -ERESTARTSYS; 1153 return -ERESTARTSYS;
1153} 1154}
1154 1155
diff --git a/drivers/char/watchdog/Kconfig b/drivers/char/watchdog/Kconfig
index 1cad32c62ed3..53f5538c0c05 100644
--- a/drivers/char/watchdog/Kconfig
+++ b/drivers/char/watchdog/Kconfig
@@ -115,6 +115,13 @@ config IXP4XX_WATCHDOG
115 115
116 Say N if you are unsure. 116 Say N if you are unsure.
117 117
118config KS8695_WATCHDOG
119 tristate "KS8695 watchdog"
120 depends on ARCH_KS8695
121 help
122 Watchdog timer embedded into KS8695 processor. This will reboot your
123 system when the timeout is reached.
124
118config S3C2410_WATCHDOG 125config S3C2410_WATCHDOG
119 tristate "S3C2410 Watchdog" 126 tristate "S3C2410 Watchdog"
120 depends on ARCH_S3C2410 127 depends on ARCH_S3C2410
diff --git a/drivers/char/watchdog/Makefile b/drivers/char/watchdog/Makefile
index 8bfc00cc7c2b..d90f649038c2 100644
--- a/drivers/char/watchdog/Makefile
+++ b/drivers/char/watchdog/Makefile
@@ -29,6 +29,7 @@ obj-$(CONFIG_21285_WATCHDOG) += wdt285.o
29obj-$(CONFIG_977_WATCHDOG) += wdt977.o 29obj-$(CONFIG_977_WATCHDOG) += wdt977.o
30obj-$(CONFIG_IXP2000_WATCHDOG) += ixp2000_wdt.o 30obj-$(CONFIG_IXP2000_WATCHDOG) += ixp2000_wdt.o
31obj-$(CONFIG_IXP4XX_WATCHDOG) += ixp4xx_wdt.o 31obj-$(CONFIG_IXP4XX_WATCHDOG) += ixp4xx_wdt.o
32obj-$(CONFIG_KS8695_WATCHDOG) += ks8695_wdt.o
32obj-$(CONFIG_S3C2410_WATCHDOG) += s3c2410_wdt.o 33obj-$(CONFIG_S3C2410_WATCHDOG) += s3c2410_wdt.o
33obj-$(CONFIG_SA1100_WATCHDOG) += sa1100_wdt.o 34obj-$(CONFIG_SA1100_WATCHDOG) += sa1100_wdt.o
34obj-$(CONFIG_MPCORE_WATCHDOG) += mpcore_wdt.o 35obj-$(CONFIG_MPCORE_WATCHDOG) += mpcore_wdt.o
diff --git a/drivers/char/watchdog/ixp2000_wdt.c b/drivers/char/watchdog/ixp2000_wdt.c
index fd955dbd588c..dc7548dcaf35 100644
--- a/drivers/char/watchdog/ixp2000_wdt.c
+++ b/drivers/char/watchdog/ixp2000_wdt.c
@@ -205,7 +205,7 @@ static void __exit ixp2000_wdt_exit(void)
205module_init(ixp2000_wdt_init); 205module_init(ixp2000_wdt_init);
206module_exit(ixp2000_wdt_exit); 206module_exit(ixp2000_wdt_exit);
207 207
208MODULE_AUTHOR("Deepak Saxena <dsaxena@plexity.net">); 208MODULE_AUTHOR("Deepak Saxena <dsaxena@plexity.net>");
209MODULE_DESCRIPTION("IXP2000 Network Processor Watchdog"); 209MODULE_DESCRIPTION("IXP2000 Network Processor Watchdog");
210 210
211module_param(heartbeat, int, 0); 211module_param(heartbeat, int, 0);
diff --git a/drivers/char/watchdog/ks8695_wdt.c b/drivers/char/watchdog/ks8695_wdt.c
new file mode 100644
index 000000000000..7150fb945eaf
--- /dev/null
+++ b/drivers/char/watchdog/ks8695_wdt.c
@@ -0,0 +1,308 @@
1/*
2 * Watchdog driver for Kendin/Micrel KS8695.
3 *
4 * (C) 2007 Andrew Victor
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 version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#include <linux/errno.h>
12#include <linux/fs.h>
13#include <linux/init.h>
14#include <linux/kernel.h>
15#include <linux/miscdevice.h>
16#include <linux/module.h>
17#include <linux/moduleparam.h>
18#include <linux/platform_device.h>
19#include <linux/types.h>
20#include <linux/watchdog.h>
21#include <asm/bitops.h>
22#include <asm/io.h>
23#include <asm/uaccess.h>
24#include <asm/arch/regs-timer.h>
25
26
27#define WDT_DEFAULT_TIME 5 /* seconds */
28#define WDT_MAX_TIME 171 /* seconds */
29
30static int wdt_time = WDT_DEFAULT_TIME;
31static int nowayout = WATCHDOG_NOWAYOUT;
32
33module_param(wdt_time, int, 0);
34MODULE_PARM_DESC(wdt_time, "Watchdog time in seconds. (default="__MODULE_STRING(WDT_DEFAULT_TIME) ")");
35
36#ifdef CONFIG_WATCHDOG_NOWAYOUT
37module_param(nowayout, int, 0);
38MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
39#endif
40
41
42static unsigned long ks8695wdt_busy;
43
44/* ......................................................................... */
45
46/*
47 * Disable the watchdog.
48 */
49static void inline ks8695_wdt_stop(void)
50{
51 unsigned long tmcon;
52
53 /* disable timer0 */
54 tmcon = __raw_readl(KS8695_TMR_VA + KS8695_TMCON);
55 __raw_writel(tmcon & ~TMCON_T0EN, KS8695_TMR_VA + KS8695_TMCON);
56}
57
58/*
59 * Enable and reset the watchdog.
60 */
61static void inline ks8695_wdt_start(void)
62{
63 unsigned long tmcon;
64 unsigned long tval = wdt_time * CLOCK_TICK_RATE;
65
66 /* disable timer0 */
67 tmcon = __raw_readl(KS8695_TMR_VA + KS8695_TMCON);
68 __raw_writel(tmcon & ~TMCON_T0EN, KS8695_TMR_VA + KS8695_TMCON);
69
70 /* program timer0 */
71 __raw_writel(tval | T0TC_WATCHDOG, KS8695_TMR_VA + KS8695_T0TC);
72
73 /* re-enable timer0 */
74 tmcon = __raw_readl(KS8695_TMR_VA + KS8695_TMCON);
75 __raw_writel(tmcon | TMCON_T0EN, KS8695_TMR_VA + KS8695_TMCON);
76}
77
78/*
79 * Reload the watchdog timer. (ie, pat the watchdog)
80 */
81static void inline ks8695_wdt_reload(void)
82{
83 unsigned long tmcon;
84
85 /* disable, then re-enable timer0 */
86 tmcon = __raw_readl(KS8695_TMR_VA + KS8695_TMCON);
87 __raw_writel(tmcon & ~TMCON_T0EN, KS8695_TMR_VA + KS8695_TMCON);
88 __raw_writel(tmcon | TMCON_T0EN, KS8695_TMR_VA + KS8695_TMCON);
89}
90
91/*
92 * Change the watchdog time interval.
93 */
94static int ks8695_wdt_settimeout(int new_time)
95{
96 /*
97 * All counting occurs at SLOW_CLOCK / 128 = 0.256 Hz
98 *
99 * Since WDV is a 16-bit counter, the maximum period is
100 * 65536 / 0.256 = 256 seconds.
101 */
102 if ((new_time <= 0) || (new_time > WDT_MAX_TIME))
103 return -EINVAL;
104
105 /* Set new watchdog time. It will be used when ks8695_wdt_start() is called. */
106 wdt_time = new_time;
107 return 0;
108}
109
110/* ......................................................................... */
111
112/*
113 * Watchdog device is opened, and watchdog starts running.
114 */
115static int ks8695_wdt_open(struct inode *inode, struct file *file)
116{
117 if (test_and_set_bit(0, &ks8695wdt_busy))
118 return -EBUSY;
119
120 ks8695_wdt_start();
121 return nonseekable_open(inode, file);
122}
123
124/*
125 * Close the watchdog device.
126 * If CONFIG_WATCHDOG_NOWAYOUT is NOT defined then the watchdog is also
127 * disabled.
128 */
129static int ks8695_wdt_close(struct inode *inode, struct file *file)
130{
131 if (!nowayout)
132 ks8695_wdt_stop(); /* Disable the watchdog when file is closed */
133
134 clear_bit(0, &ks8695wdt_busy);
135 return 0;
136}
137
138static struct watchdog_info ks8695_wdt_info = {
139 .identity = "ks8695 watchdog",
140 .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING,
141};
142
143/*
144 * Handle commands from user-space.
145 */
146static int ks8695_wdt_ioctl(struct inode *inode, struct file *file,
147 unsigned int cmd, unsigned long arg)
148{
149 void __user *argp = (void __user *)arg;
150 int __user *p = argp;
151 int new_value;
152
153 switch(cmd) {
154 case WDIOC_KEEPALIVE:
155 ks8695_wdt_reload(); /* pat the watchdog */
156 return 0;
157
158 case WDIOC_GETSUPPORT:
159 return copy_to_user(argp, &ks8695_wdt_info, sizeof(ks8695_wdt_info)) ? -EFAULT : 0;
160
161 case WDIOC_SETTIMEOUT:
162 if (get_user(new_value, p))
163 return -EFAULT;
164
165 if (ks8695_wdt_settimeout(new_value))
166 return -EINVAL;
167
168 /* Enable new time value */
169 ks8695_wdt_start();
170
171 /* Return current value */
172 return put_user(wdt_time, p);
173
174 case WDIOC_GETTIMEOUT:
175 return put_user(wdt_time, p);
176
177 case WDIOC_GETSTATUS:
178 case WDIOC_GETBOOTSTATUS:
179 return put_user(0, p);
180
181 case WDIOC_SETOPTIONS:
182 if (get_user(new_value, p))
183 return -EFAULT;
184
185 if (new_value & WDIOS_DISABLECARD)
186 ks8695_wdt_stop();
187 if (new_value & WDIOS_ENABLECARD)
188 ks8695_wdt_start();
189 return 0;
190
191 default:
192 return -ENOTTY;
193 }
194}
195
196/*
197 * Pat the watchdog whenever device is written to.
198 */
199static ssize_t ks8695_wdt_write(struct file *file, const char *data, size_t len, loff_t *ppos)
200{
201 ks8695_wdt_reload(); /* pat the watchdog */
202 return len;
203}
204
205/* ......................................................................... */
206
207static const struct file_operations ks8695wdt_fops = {
208 .owner = THIS_MODULE,
209 .llseek = no_llseek,
210 .ioctl = ks8695_wdt_ioctl,
211 .open = ks8695_wdt_open,
212 .release = ks8695_wdt_close,
213 .write = ks8695_wdt_write,
214};
215
216static struct miscdevice ks8695wdt_miscdev = {
217 .minor = WATCHDOG_MINOR,
218 .name = "watchdog",
219 .fops = &ks8695wdt_fops,
220};
221
222static int __init ks8695wdt_probe(struct platform_device *pdev)
223{
224 int res;
225
226 if (ks8695wdt_miscdev.parent)
227 return -EBUSY;
228 ks8695wdt_miscdev.parent = &pdev->dev;
229
230 res = misc_register(&ks8695wdt_miscdev);
231 if (res)
232 return res;
233
234 printk("KS8695 Watchdog Timer enabled (%d seconds%s)\n", wdt_time, nowayout ? ", nowayout" : "");
235 return 0;
236}
237
238static int __exit ks8695wdt_remove(struct platform_device *pdev)
239{
240 int res;
241
242 res = misc_deregister(&ks8695wdt_miscdev);
243 if (!res)
244 ks8695wdt_miscdev.parent = NULL;
245
246 return res;
247}
248
249static void ks8695wdt_shutdown(struct platform_device *pdev)
250{
251 ks8695_wdt_stop();
252}
253
254#ifdef CONFIG_PM
255
256static int ks8695wdt_suspend(struct platform_device *pdev, pm_message_t message)
257{
258 ks8695_wdt_stop();
259 return 0;
260}
261
262static int ks8695wdt_resume(struct platform_device *pdev)
263{
264 if (ks8695wdt_busy)
265 ks8695_wdt_start();
266 return 0;
267}
268
269#else
270#define ks8695wdt_suspend NULL
271#define ks8695wdt_resume NULL
272#endif
273
274static struct platform_driver ks8695wdt_driver = {
275 .probe = ks8695wdt_probe,
276 .remove = __exit_p(ks8695wdt_remove),
277 .shutdown = ks8695wdt_shutdown,
278 .suspend = ks8695wdt_suspend,
279 .resume = ks8695wdt_resume,
280 .driver = {
281 .name = "ks8695_wdt",
282 .owner = THIS_MODULE,
283 },
284};
285
286static int __init ks8695_wdt_init(void)
287{
288 /* Check that the heartbeat value is within range; if not reset to the default */
289 if (ks8695_wdt_settimeout(wdt_time)) {
290 ks8695_wdt_settimeout(WDT_DEFAULT_TIME);
291 pr_info("ks8695_wdt: wdt_time value must be 1 <= wdt_time <= %i, using %d\n", wdt_time, WDT_MAX_TIME);
292 }
293
294 return platform_driver_register(&ks8695wdt_driver);
295}
296
297static void __exit ks8695_wdt_exit(void)
298{
299 platform_driver_unregister(&ks8695wdt_driver);
300}
301
302module_init(ks8695_wdt_init);
303module_exit(ks8695_wdt_exit);
304
305MODULE_AUTHOR("Andrew Victor");
306MODULE_DESCRIPTION("Watchdog driver for KS8695");
307MODULE_LICENSE("GPL");
308MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);