Merge branch 'upstream' of git://ftp.linux-mips.org/pub/scm/upstream-linus

* 'upstream' of git://ftp.linux-mips.org/pub/scm/upstream-linus:
CHAR: Delete old and now unused M48T35 RTC driver for SGI IP27.
CHAR: Delete old and now unused DS1286 driver.
MIPS: Sort out CPU type to name translation.
MIPS: Use the new byteorder headers
MIPS: Probe for watch registers on cores of all vendors, not just MTI.
MIPS: Switch FPU emulator trap to BREAK instruction.
MIPS: SMP: Do not initialize __cpu_number_map/__cpu_logical_map for CPU 0.
MIPS: Consider value of c0_ebase when computing value of exception base.
MIPS: Clean up MIPSxx-optimized bitop functions
MIPS: New feature test macro cpu_has_mips_r
MIPS: RBTX4927: Add GPIO-LED support
MIPS: TXx9: Fix RBTX4939 ethernet address initialization

+282 -1244
-5
arch/mips/Kconfig
··· 327 327 select IP22_CPU_SCACHE 328 328 select IRQ_CPU 329 329 select GENERIC_ISA_DMA_SUPPORT_BROKEN 330 - select SGI_HAS_DS1286 331 330 select SGI_HAS_I8042 332 331 select SGI_HAS_INDYDOG 333 332 select SGI_HAS_HAL2 ··· 381 382 select HW_HAS_EISA 382 383 select I8253 383 384 select I8259 384 - select SGI_HAS_DS1286 385 385 select SGI_HAS_I8042 386 386 select SGI_HAS_INDYDOG 387 387 select SGI_HAS_HAL2 ··· 889 891 default y 890 892 891 893 config SERIAL_RM9000 892 - bool 893 - 894 - config SGI_HAS_DS1286 895 894 bool 896 895 897 896 config SGI_HAS_INDYDOG
-1
arch/mips/configs/ip22_defconfig
··· 771 771 CONFIG_INDYDOG=m 772 772 # CONFIG_HW_RANDOM is not set 773 773 # CONFIG_RTC is not set 774 - CONFIG_SGI_DS1286=m 775 774 # CONFIG_R3964 is not set 776 775 CONFIG_RAW_DRIVER=m 777 776 CONFIG_MAX_RAW_DEVS=256
-1
arch/mips/configs/ip27_defconfig
··· 701 701 # CONFIG_WATCHDOG is not set 702 702 CONFIG_HW_RANDOM=m 703 703 # CONFIG_RTC is not set 704 - CONFIG_SGI_IP27_RTC=y 705 704 # CONFIG_R3964 is not set 706 705 # CONFIG_APPLICOM is not set 707 706 # CONFIG_DRM is not set
-2
arch/mips/configs/ip28_defconfig
··· 70 70 CONFIG_SYS_SUPPORTS_BIG_ENDIAN=y 71 71 CONFIG_IRQ_CPU=y 72 72 CONFIG_SWAP_IO_SPACE=y 73 - CONFIG_SGI_HAS_DS1286=y 74 73 CONFIG_SGI_HAS_INDYDOG=y 75 74 CONFIG_SGI_HAS_SEEQ=y 76 75 CONFIG_SGI_HAS_WD93=y ··· 584 585 # CONFIG_IPMI_HANDLER is not set 585 586 # CONFIG_HW_RANDOM is not set 586 587 # CONFIG_RTC is not set 587 - CONFIG_SGI_DS1286=y 588 588 # CONFIG_DTLK is not set 589 589 # CONFIG_R3964 is not set 590 590 # CONFIG_RAW_DRIVER is not set
+77 -39
arch/mips/include/asm/bitops.h
··· 558 558 __clear_bit(nr, addr); 559 559 } 560 560 561 - #if defined(CONFIG_CPU_MIPS32) || defined(CONFIG_CPU_MIPS64) 562 - 563 561 /* 564 562 * Return the bit position (0..63) of the most significant 1 bit in a word 565 563 * Returns -1 if no 1 bit exists 566 564 */ 567 - static inline unsigned long __fls(unsigned long x) 565 + static inline unsigned long __fls(unsigned long word) 568 566 { 569 - int lz; 567 + int num; 570 568 571 - if (sizeof(x) == 4) { 569 + if (BITS_PER_LONG == 32 && 570 + __builtin_constant_p(cpu_has_mips_r) && cpu_has_mips_r) { 572 571 __asm__( 573 572 " .set push \n" 574 573 " .set mips32 \n" 575 574 " clz %0, %1 \n" 576 575 " .set pop \n" 577 - : "=r" (lz) 578 - : "r" (x)); 576 + : "=r" (num) 577 + : "r" (word)); 579 578 580 - return 31 - lz; 579 + return 31 - num; 581 580 } 582 581 583 - BUG_ON(sizeof(x) != 8); 582 + if (BITS_PER_LONG == 64 && 583 + __builtin_constant_p(cpu_has_mips64) && cpu_has_mips64) { 584 + __asm__( 585 + " .set push \n" 586 + " .set mips64 \n" 587 + " dclz %0, %1 \n" 588 + " .set pop \n" 589 + : "=r" (num) 590 + : "r" (word)); 584 591 585 - __asm__( 586 - " .set push \n" 587 - " .set mips64 \n" 588 - " dclz %0, %1 \n" 589 - " .set pop \n" 590 - : "=r" (lz) 591 - : "r" (x)); 592 + return 63 - num; 593 + } 592 594 593 - return 63 - lz; 595 + num = BITS_PER_LONG - 1; 596 + 597 + #if BITS_PER_LONG == 64 598 + if (!(word & (~0ul << 32))) { 599 + num -= 32; 600 + word <<= 32; 601 + } 602 + #endif 603 + if (!(word & (~0ul << (BITS_PER_LONG-16)))) { 604 + num -= 16; 605 + word <<= 16; 606 + } 607 + if (!(word & (~0ul << (BITS_PER_LONG-8)))) { 608 + num -= 8; 609 + word <<= 8; 610 + } 611 + if (!(word & (~0ul << (BITS_PER_LONG-4)))) { 612 + num -= 4; 613 + word <<= 4; 614 + } 615 + if (!(word & (~0ul << (BITS_PER_LONG-2)))) { 616 + num -= 2; 617 + word <<= 2; 618 + } 619 + if (!(word & (~0ul << (BITS_PER_LONG-1)))) 620 + num -= 1; 621 + return num; 594 622 } 595 623 596 624 /* ··· 640 612 * This is defined the same way as ffs. 641 613 * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32. 642 614 */ 643 - static inline int fls(int word) 615 + static inline int fls(int x) 644 616 { 645 - __asm__("clz %0, %1" : "=r" (word) : "r" (word)); 617 + int r; 646 618 647 - return 32 - word; 619 + if (__builtin_constant_p(cpu_has_mips_r) && cpu_has_mips_r) { 620 + __asm__("clz %0, %1" : "=r" (x) : "r" (x)); 621 + 622 + return 32 - x; 623 + } 624 + 625 + r = 32; 626 + if (!x) 627 + return 0; 628 + if (!(x & 0xffff0000u)) { 629 + x <<= 16; 630 + r -= 16; 631 + } 632 + if (!(x & 0xff000000u)) { 633 + x <<= 8; 634 + r -= 8; 635 + } 636 + if (!(x & 0xf0000000u)) { 637 + x <<= 4; 638 + r -= 4; 639 + } 640 + if (!(x & 0xc0000000u)) { 641 + x <<= 2; 642 + r -= 2; 643 + } 644 + if (!(x & 0x80000000u)) { 645 + x <<= 1; 646 + r -= 1; 647 + } 648 + return r; 648 649 } 649 650 650 - #if defined(CONFIG_64BIT) && defined(CONFIG_CPU_MIPS64) 651 - static inline int fls64(__u64 word) 652 - { 653 - __asm__("dclz %0, %1" : "=r" (word) : "r" (word)); 654 - 655 - return 64 - word; 656 - } 657 - #else 658 651 #include <asm-generic/bitops/fls64.h> 659 - #endif 660 652 661 653 /* 662 654 * ffs - find first bit set. ··· 693 645 694 646 return fls(word & -word); 695 647 } 696 - 697 - #else 698 - 699 - #include <asm-generic/bitops/__ffs.h> 700 - #include <asm-generic/bitops/__fls.h> 701 - #include <asm-generic/bitops/ffs.h> 702 - #include <asm-generic/bitops/fls.h> 703 - #include <asm-generic/bitops/fls64.h> 704 - 705 - #endif /*defined(CONFIG_CPU_MIPS32) || defined(CONFIG_CPU_MIPS64) */ 706 648 707 649 #include <asm-generic/bitops/ffz.h> 708 650 #include <asm-generic/bitops/find.h>
+1
arch/mips/include/asm/break.h
··· 29 29 #define _BRK_THREADBP 11 /* For threads, user bp (used by debuggers) */ 30 30 #define BRK_BUG 512 /* Used by BUG() */ 31 31 #define BRK_KDB 513 /* Used in KDB_ENTER() */ 32 + #define BRK_MEMU 514 /* Used by FPU emulator */ 32 33 #define BRK_MULOVF 1023 /* Multiply overflow */ 33 34 34 35 #endif /* __ASM_BREAK_H */
+16 -24
arch/mips/include/asm/byteorder.h
··· 11 11 #include <linux/compiler.h> 12 12 #include <asm/types.h> 13 13 14 - #ifdef __GNUC__ 14 + #if defined(__MIPSEB__) 15 + # define __BIG_ENDIAN 16 + #elif defined(__MIPSEL__) 17 + # define __LITTLE_ENDIAN 18 + #else 19 + # error "MIPS, but neither __MIPSEB__, nor __MIPSEL__???" 20 + #endif 21 + 22 + #define __SWAB_64_THRU_32__ 15 23 16 24 #ifdef CONFIG_CPU_MIPSR2 17 25 18 - static __inline__ __attribute_const__ __u16 ___arch__swab16(__u16 x) 26 + static inline __attribute_const__ __u16 __arch_swab16(__u16 x) 19 27 { 20 28 __asm__( 21 29 " wsbh %0, %1 \n" ··· 32 24 33 25 return x; 34 26 } 35 - #define __arch__swab16(x) ___arch__swab16(x) 27 + #define __arch_swab16 __arch_swab16 36 28 37 - static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x) 29 + static inline __attribute_const__ __u32 __arch_swab32(__u32 x) 38 30 { 39 31 __asm__( 40 32 " wsbh %0, %1 \n" ··· 44 36 45 37 return x; 46 38 } 47 - #define __arch__swab32(x) ___arch__swab32(x) 39 + #define __arch_swab32 __arch_swab32 48 40 49 41 #ifdef CONFIG_CPU_MIPS64_R2 50 - 51 - static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 x) 42 + static inline __attribute_const__ __u64 __arch_swab64(__u64 x) 52 43 { 53 44 __asm__( 54 45 " dsbh %0, %1 \n" ··· 58 51 59 52 return x; 60 53 } 61 - 62 - #define __arch__swab64(x) ___arch__swab64(x) 63 - 54 + #define __arch_swab64 __arch_swab64 64 55 #endif /* CONFIG_CPU_MIPS64_R2 */ 65 56 66 57 #endif /* CONFIG_CPU_MIPSR2 */ 67 58 68 - #if !defined(__STRICT_ANSI__) || defined(__KERNEL__) 69 - # define __BYTEORDER_HAS_U64__ 70 - # define __SWAB_64_THRU_32__ 71 - #endif 72 - 73 - #endif /* __GNUC__ */ 74 - 75 - #if defined(__MIPSEB__) 76 - # include <linux/byteorder/big_endian.h> 77 - #elif defined(__MIPSEL__) 78 - # include <linux/byteorder/little_endian.h> 79 - #else 80 - # error "MIPS, but neither __MIPSEB__, nor __MIPSEL__???" 81 - #endif 59 + #include <linux/byteorder.h> 82 60 83 61 #endif /* _ASM_BYTEORDER_H */
+2
arch/mips/include/asm/cpu-features.h
··· 141 141 #define cpu_has_mips64 (cpu_has_mips64r1 | cpu_has_mips64r2) 142 142 #define cpu_has_mips_r1 (cpu_has_mips32r1 | cpu_has_mips64r1) 143 143 #define cpu_has_mips_r2 (cpu_has_mips32r2 | cpu_has_mips64r2) 144 + #define cpu_has_mips_r (cpu_has_mips32r1 | cpu_has_mips32r2 | \ 145 + cpu_has_mips64r1 | cpu_has_mips64r2) 144 146 145 147 #ifndef cpu_has_dsp 146 148 #define cpu_has_dsp (cpu_data[0].ases & MIPS_ASE_DSP)
-15
arch/mips/include/asm/ds1286.h
··· 1 - /* 2 - * This file is subject to the terms and conditions of the GNU General Public 3 - * License. See the file "COPYING" in the main directory of this archive 4 - * for more details. 5 - * 6 - * Machine dependent access functions for RTC registers. 7 - * 8 - * Copyright (C) 2003 Ralf Baechle (ralf@linux-mips.org) 9 - */ 10 - #ifndef _ASM_DS1286_H 11 - #define _ASM_DS1286_H 12 - 13 - #include <ds1286.h> 14 - 15 - #endif /* _ASM_DS1286_H */
+17
arch/mips/include/asm/fpu_emulator.h
··· 23 23 #ifndef _ASM_FPU_EMULATOR_H 24 24 #define _ASM_FPU_EMULATOR_H 25 25 26 + #include <asm/break.h> 27 + #include <asm/inst.h> 28 + 26 29 struct mips_fpu_emulator_stats { 27 30 unsigned int emulated; 28 31 unsigned int loads; ··· 36 33 }; 37 34 38 35 extern struct mips_fpu_emulator_stats fpuemustats; 36 + 37 + extern int mips_dsemul(struct pt_regs *regs, mips_instruction ir, 38 + unsigned long cpc); 39 + extern int do_dsemulret(struct pt_regs *xcp); 40 + 41 + /* 42 + * Instruction inserted following the badinst to further tag the sequence 43 + */ 44 + #define BD_COOKIE 0x0000bd36 /* tne $0, $0 with baggage */ 45 + 46 + /* 47 + * Break instruction with special math emu break code set 48 + */ 49 + #define BREAK_MATH (0x0000000d | (BRK_MEMU << 16)) 39 50 40 51 #endif /* _ASM_FPU_EMULATOR_H */
-27
arch/mips/include/asm/m48t35.h
··· 1 - /* 2 - * Registers for the SGS-Thomson M48T35 Timekeeper RAM chip 3 - */ 4 - #ifndef _ASM_M48T35_H 5 - #define _ASM_M48T35_H 6 - 7 - #include <linux/spinlock.h> 8 - 9 - extern spinlock_t rtc_lock; 10 - 11 - struct m48t35_rtc { 12 - volatile u8 pad[0x7ff8]; /* starts at 0x7ff8 */ 13 - volatile u8 control; 14 - volatile u8 sec; 15 - volatile u8 min; 16 - volatile u8 hour; 17 - volatile u8 day; 18 - volatile u8 date; 19 - volatile u8 month; 20 - volatile u8 year; 21 - }; 22 - 23 - #define M48T35_RTC_SET 0x80 24 - #define M48T35_RTC_STOPPED 0x80 25 - #define M48T35_RTC_READ 0x40 26 - 27 - #endif /* _ASM_M48T35_H */
+110 -137
arch/mips/kernel/cpu-probe.c
··· 286 286 #define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \ 287 287 | MIPS_CPU_COUNTER) 288 288 289 - static inline void cpu_probe_legacy(struct cpuinfo_mips *c) 289 + static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu) 290 290 { 291 291 switch (c->processor_id & 0xff00) { 292 292 case PRID_IMP_R2000: 293 293 c->cputype = CPU_R2000; 294 + __cpu_name[cpu] = "R2000"; 294 295 c->isa_level = MIPS_CPU_ISA_I; 295 296 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE | 296 297 MIPS_CPU_NOFPUEX; ··· 300 299 c->tlbsize = 64; 301 300 break; 302 301 case PRID_IMP_R3000: 303 - if ((c->processor_id & 0xff) == PRID_REV_R3000A) 304 - if (cpu_has_confreg()) 302 + if ((c->processor_id & 0xff) == PRID_REV_R3000A) { 303 + if (cpu_has_confreg()) { 305 304 c->cputype = CPU_R3081E; 306 - else 305 + __cpu_name[cpu] = "R3081"; 306 + } else { 307 307 c->cputype = CPU_R3000A; 308 - else 308 + __cpu_name[cpu] = "R3000A"; 309 + } 310 + break; 311 + } else { 309 312 c->cputype = CPU_R3000; 313 + __cpu_name[cpu] = "R3000"; 314 + } 310 315 c->isa_level = MIPS_CPU_ISA_I; 311 316 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE | 312 317 MIPS_CPU_NOFPUEX; ··· 322 315 break; 323 316 case PRID_IMP_R4000: 324 317 if (read_c0_config() & CONF_SC) { 325 - if ((c->processor_id & 0xff) >= PRID_REV_R4400) 318 + if ((c->processor_id & 0xff) >= PRID_REV_R4400) { 326 319 c->cputype = CPU_R4400PC; 327 - else 320 + __cpu_name[cpu] = "R4400PC"; 321 + } else { 328 322 c->cputype = CPU_R4000PC; 323 + __cpu_name[cpu] = "R4000PC"; 324 + } 329 325 } else { 330 - if ((c->processor_id & 0xff) >= PRID_REV_R4400) 326 + if ((c->processor_id & 0xff) >= PRID_REV_R4400) { 331 327 c->cputype = CPU_R4400SC; 332 - else 328 + __cpu_name[cpu] = "R4400SC"; 329 + } else { 333 330 c->cputype = CPU_R4000SC; 331 + __cpu_name[cpu] = "R4000SC"; 332 + } 334 333 } 335 334 336 335 c->isa_level = MIPS_CPU_ISA_III; ··· 349 336 switch (c->processor_id & 0xf0) { 350 337 case PRID_REV_VR4111: 351 338 c->cputype = CPU_VR4111; 339 + __cpu_name[cpu] = "NEC VR4111"; 352 340 break; 353 341 case PRID_REV_VR4121: 354 342 c->cputype = CPU_VR4121; 343 + __cpu_name[cpu] = "NEC VR4121"; 355 344 break; 356 345 case PRID_REV_VR4122: 357 - if ((c->processor_id & 0xf) < 0x3) 346 + if ((c->processor_id & 0xf) < 0x3) { 358 347 c->cputype = CPU_VR4122; 359 - else 348 + __cpu_name[cpu] = "NEC VR4122"; 349 + } else { 360 350 c->cputype = CPU_VR4181A; 351 + __cpu_name[cpu] = "NEC VR4181A"; 352 + } 361 353 break; 362 354 case PRID_REV_VR4130: 363 - if ((c->processor_id & 0xf) < 0x4) 355 + if ((c->processor_id & 0xf) < 0x4) { 364 356 c->cputype = CPU_VR4131; 365 - else 357 + __cpu_name[cpu] = "NEC VR4131"; 358 + } else { 366 359 c->cputype = CPU_VR4133; 360 + __cpu_name[cpu] = "NEC VR4133"; 361 + } 367 362 break; 368 363 default: 369 364 printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n"); 370 365 c->cputype = CPU_VR41XX; 366 + __cpu_name[cpu] = "NEC Vr41xx"; 371 367 break; 372 368 } 373 369 c->isa_level = MIPS_CPU_ISA_III; ··· 385 363 break; 386 364 case PRID_IMP_R4300: 387 365 c->cputype = CPU_R4300; 366 + __cpu_name[cpu] = "R4300"; 388 367 c->isa_level = MIPS_CPU_ISA_III; 389 368 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | 390 369 MIPS_CPU_LLSC; ··· 393 370 break; 394 371 case PRID_IMP_R4600: 395 372 c->cputype = CPU_R4600; 373 + __cpu_name[cpu] = "R4600"; 396 374 c->isa_level = MIPS_CPU_ISA_III; 397 375 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | 398 376 MIPS_CPU_LLSC; ··· 408 384 * it's c0_prid id number with the TX3900. 409 385 */ 410 386 c->cputype = CPU_R4650; 387 + __cpu_name[cpu] = "R4650"; 411 388 c->isa_level = MIPS_CPU_ISA_III; 412 389 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC; 413 390 c->tlbsize = 48; ··· 420 395 421 396 if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) { 422 397 c->cputype = CPU_TX3927; 398 + __cpu_name[cpu] = "TX3927"; 423 399 c->tlbsize = 64; 424 400 } else { 425 401 switch (c->processor_id & 0xff) { 426 402 case PRID_REV_TX3912: 427 403 c->cputype = CPU_TX3912; 404 + __cpu_name[cpu] = "TX3912"; 428 405 c->tlbsize = 32; 429 406 break; 430 407 case PRID_REV_TX3922: 431 408 c->cputype = CPU_TX3922; 409 + __cpu_name[cpu] = "TX3922"; 432 410 c->tlbsize = 64; 433 - break; 434 - default: 435 - c->cputype = CPU_UNKNOWN; 436 411 break; 437 412 } 438 413 } 439 414 break; 440 415 case PRID_IMP_R4700: 441 416 c->cputype = CPU_R4700; 417 + __cpu_name[cpu] = "R4700"; 442 418 c->isa_level = MIPS_CPU_ISA_III; 443 419 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | 444 420 MIPS_CPU_LLSC; ··· 447 421 break; 448 422 case PRID_IMP_TX49: 449 423 c->cputype = CPU_TX49XX; 424 + __cpu_name[cpu] = "R49XX"; 450 425 c->isa_level = MIPS_CPU_ISA_III; 451 426 c->options = R4K_OPTS | MIPS_CPU_LLSC; 452 427 if (!(c->processor_id & 0x08)) ··· 456 429 break; 457 430 case PRID_IMP_R5000: 458 431 c->cputype = CPU_R5000; 432 + __cpu_name[cpu] = "R5000"; 459 433 c->isa_level = MIPS_CPU_ISA_IV; 460 434 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | 461 435 MIPS_CPU_LLSC; ··· 464 436 break; 465 437 case PRID_IMP_R5432: 466 438 c->cputype = CPU_R5432; 439 + __cpu_name[cpu] = "R5432"; 467 440 c->isa_level = MIPS_CPU_ISA_IV; 468 441 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | 469 442 MIPS_CPU_WATCH | MIPS_CPU_LLSC; ··· 472 443 break; 473 444 case PRID_IMP_R5500: 474 445 c->cputype = CPU_R5500; 446 + __cpu_name[cpu] = "R5500"; 475 447 c->isa_level = MIPS_CPU_ISA_IV; 476 448 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | 477 449 MIPS_CPU_WATCH | MIPS_CPU_LLSC; ··· 480 450 break; 481 451 case PRID_IMP_NEVADA: 482 452 c->cputype = CPU_NEVADA; 453 + __cpu_name[cpu] = "Nevada"; 483 454 c->isa_level = MIPS_CPU_ISA_IV; 484 455 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | 485 456 MIPS_CPU_DIVEC | MIPS_CPU_LLSC; ··· 488 457 break; 489 458 case PRID_IMP_R6000: 490 459 c->cputype = CPU_R6000; 460 + __cpu_name[cpu] = "R6000"; 491 461 c->isa_level = MIPS_CPU_ISA_II; 492 462 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU | 493 463 MIPS_CPU_LLSC; ··· 496 464 break; 497 465 case PRID_IMP_R6000A: 498 466 c->cputype = CPU_R6000A; 467 + __cpu_name[cpu] = "R6000A"; 499 468 c->isa_level = MIPS_CPU_ISA_II; 500 469 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU | 501 470 MIPS_CPU_LLSC; ··· 504 471 break; 505 472 case PRID_IMP_RM7000: 506 473 c->cputype = CPU_RM7000; 474 + __cpu_name[cpu] = "RM7000"; 507 475 c->isa_level = MIPS_CPU_ISA_IV; 508 476 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | 509 477 MIPS_CPU_LLSC; ··· 520 486 break; 521 487 case PRID_IMP_RM9000: 522 488 c->cputype = CPU_RM9000; 489 + __cpu_name[cpu] = "RM9000"; 523 490 c->isa_level = MIPS_CPU_ISA_IV; 524 491 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR | 525 492 MIPS_CPU_LLSC; ··· 535 500 break; 536 501 case PRID_IMP_R8000: 537 502 c->cputype = CPU_R8000; 503 + __cpu_name[cpu] = "RM8000"; 538 504 c->isa_level = MIPS_CPU_ISA_IV; 539 505 c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX | 540 506 MIPS_CPU_FPU | MIPS_CPU_32FPR | ··· 544 508 break; 545 509 case PRID_IMP_R10000: 546 510 c->cputype = CPU_R10000; 511 + __cpu_name[cpu] = "R10000"; 547 512 c->isa_level = MIPS_CPU_ISA_IV; 548 513 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX | 549 514 MIPS_CPU_FPU | MIPS_CPU_32FPR | ··· 554 517 break; 555 518 case PRID_IMP_R12000: 556 519 c->cputype = CPU_R12000; 520 + __cpu_name[cpu] = "R12000"; 557 521 c->isa_level = MIPS_CPU_ISA_IV; 558 522 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX | 559 523 MIPS_CPU_FPU | MIPS_CPU_32FPR | ··· 564 526 break; 565 527 case PRID_IMP_R14000: 566 528 c->cputype = CPU_R14000; 529 + __cpu_name[cpu] = "R14000"; 567 530 c->isa_level = MIPS_CPU_ISA_IV; 568 531 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX | 569 532 MIPS_CPU_FPU | MIPS_CPU_32FPR | ··· 574 535 break; 575 536 case PRID_IMP_LOONGSON2: 576 537 c->cputype = CPU_LOONGSON2; 538 + __cpu_name[cpu] = "ICT Loongson-2"; 577 539 c->isa_level = MIPS_CPU_ISA_III; 578 540 c->options = R4K_OPTS | 579 541 MIPS_CPU_FPU | MIPS_CPU_LLSC | ··· 692 652 693 653 static void __cpuinit decode_configs(struct cpuinfo_mips *c) 694 654 { 655 + int ok; 656 + 695 657 /* MIPS32 or MIPS64 compliant CPU. */ 696 658 c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER | 697 659 MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK; 698 660 699 661 c->scache.flags = MIPS_CACHE_NOT_PRESENT; 700 662 701 - /* Read Config registers. */ 702 - if (!decode_config0(c)) 703 - return; /* actually worth a panic() */ 704 - if (!decode_config1(c)) 705 - return; 706 - if (!decode_config2(c)) 707 - return; 708 - if (!decode_config3(c)) 709 - return; 663 + ok = decode_config0(c); /* Read Config registers. */ 664 + BUG_ON(!ok); /* Arch spec violation! */ 665 + if (ok) 666 + ok = decode_config1(c); 667 + if (ok) 668 + ok = decode_config2(c); 669 + if (ok) 670 + ok = decode_config3(c); 671 + 672 + mips_probe_watch_registers(c); 710 673 } 711 674 712 675 #ifdef CONFIG_CPU_MIPSR2 ··· 718 675 static inline void spram_config(void) {} 719 676 #endif 720 677 721 - static inline void cpu_probe_mips(struct cpuinfo_mips *c) 678 + static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu) 722 679 { 723 680 decode_configs(c); 724 - mips_probe_watch_registers(c); 725 681 switch (c->processor_id & 0xff00) { 726 682 case PRID_IMP_4KC: 727 683 c->cputype = CPU_4KC; 684 + __cpu_name[cpu] = "MIPS 4Kc"; 728 685 break; 729 686 case PRID_IMP_4KEC: 730 687 c->cputype = CPU_4KEC; 688 + __cpu_name[cpu] = "MIPS 4KEc"; 731 689 break; 732 690 case PRID_IMP_4KECR2: 733 691 c->cputype = CPU_4KEC; 692 + __cpu_name[cpu] = "MIPS 4KEc"; 734 693 break; 735 694 case PRID_IMP_4KSC: 736 695 case PRID_IMP_4KSD: 737 696 c->cputype = CPU_4KSC; 697 + __cpu_name[cpu] = "MIPS 4KSc"; 738 698 break; 739 699 case PRID_IMP_5KC: 740 700 c->cputype = CPU_5KC; 701 + __cpu_name[cpu] = "MIPS 5Kc"; 741 702 break; 742 703 case PRID_IMP_20KC: 743 704 c->cputype = CPU_20KC; 705 + __cpu_name[cpu] = "MIPS 20Kc"; 744 706 break; 745 707 case PRID_IMP_24K: 746 708 case PRID_IMP_24KE: 747 709 c->cputype = CPU_24K; 710 + __cpu_name[cpu] = "MIPS 24Kc"; 748 711 break; 749 712 case PRID_IMP_25KF: 750 713 c->cputype = CPU_25KF; 714 + __cpu_name[cpu] = "MIPS 25Kc"; 751 715 break; 752 716 case PRID_IMP_34K: 753 717 c->cputype = CPU_34K; 718 + __cpu_name[cpu] = "MIPS 34Kc"; 754 719 break; 755 720 case PRID_IMP_74K: 756 721 c->cputype = CPU_74K; 722 + __cpu_name[cpu] = "MIPS 74Kc"; 757 723 break; 758 724 case PRID_IMP_1004K: 759 725 c->cputype = CPU_1004K; 726 + __cpu_name[cpu] = "MIPS 1004Kc"; 760 727 break; 761 728 } 762 729 763 730 spram_config(); 764 731 } 765 732 766 - static inline void cpu_probe_alchemy(struct cpuinfo_mips *c) 733 + static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu) 767 734 { 768 735 decode_configs(c); 769 736 switch (c->processor_id & 0xff00) { ··· 782 729 switch ((c->processor_id >> 24) & 0xff) { 783 730 case 0: 784 731 c->cputype = CPU_AU1000; 732 + __cpu_name[cpu] = "Au1000"; 785 733 break; 786 734 case 1: 787 735 c->cputype = CPU_AU1500; 736 + __cpu_name[cpu] = "Au1500"; 788 737 break; 789 738 case 2: 790 739 c->cputype = CPU_AU1100; 740 + __cpu_name[cpu] = "Au1100"; 791 741 break; 792 742 case 3: 793 743 c->cputype = CPU_AU1550; 744 + __cpu_name[cpu] = "Au1550"; 794 745 break; 795 746 case 4: 796 747 c->cputype = CPU_AU1200; 797 - if (2 == (c->processor_id & 0xff)) 748 + __cpu_name[cpu] = "Au1200"; 749 + if ((c->processor_id & 0xff) == 2) { 798 750 c->cputype = CPU_AU1250; 751 + __cpu_name[cpu] = "Au1250"; 752 + } 799 753 break; 800 754 case 5: 801 755 c->cputype = CPU_AU1210; 756 + __cpu_name[cpu] = "Au1210"; 802 757 break; 803 758 default: 804 759 panic("Unknown Au Core!"); ··· 816 755 } 817 756 } 818 757 819 - static inline void cpu_probe_sibyte(struct cpuinfo_mips *c) 758 + static inline void cpu_probe_sibyte(struct cpuinfo_mips *c, unsigned int cpu) 820 759 { 821 760 decode_configs(c); 822 761 823 762 switch (c->processor_id & 0xff00) { 824 763 case PRID_IMP_SB1: 825 764 c->cputype = CPU_SB1; 765 + __cpu_name[cpu] = "SiByte SB1"; 826 766 /* FPU in pass1 is known to have issues. */ 827 767 if ((c->processor_id & 0xff) < 0x02) 828 768 c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR); 829 769 break; 830 770 case PRID_IMP_SB1A: 831 771 c->cputype = CPU_SB1A; 772 + __cpu_name[cpu] = "SiByte SB1A"; 832 773 break; 833 774 } 834 775 } 835 776 836 - static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c) 777 + static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c, unsigned int cpu) 837 778 { 838 779 decode_configs(c); 839 780 switch (c->processor_id & 0xff00) { 840 781 case PRID_IMP_SR71000: 841 782 c->cputype = CPU_SR71000; 783 + __cpu_name[cpu] = "Sandcraft SR71000"; 842 784 c->scache.ways = 8; 843 785 c->tlbsize = 64; 844 786 break; 845 787 } 846 788 } 847 789 848 - static inline void cpu_probe_nxp(struct cpuinfo_mips *c) 790 + static inline void cpu_probe_nxp(struct cpuinfo_mips *c, unsigned int cpu) 849 791 { 850 792 decode_configs(c); 851 793 switch (c->processor_id & 0xff00) { 852 794 case PRID_IMP_PR4450: 853 795 c->cputype = CPU_PR4450; 796 + __cpu_name[cpu] = "Philips PR4450"; 854 797 c->isa_level = MIPS_CPU_ISA_M32R1; 855 - break; 856 - default: 857 - panic("Unknown NXP Core!"); /* REVISIT: die? */ 858 798 break; 859 799 } 860 800 } 861 801 862 - 863 - static inline void cpu_probe_broadcom(struct cpuinfo_mips *c) 802 + static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu) 864 803 { 865 804 decode_configs(c); 866 805 switch (c->processor_id & 0xff00) { 867 806 case PRID_IMP_BCM3302: 868 807 c->cputype = CPU_BCM3302; 808 + __cpu_name[cpu] = "Broadcom BCM3302"; 869 809 break; 870 810 case PRID_IMP_BCM4710: 871 811 c->cputype = CPU_BCM4710; 872 - break; 873 - default: 874 - c->cputype = CPU_UNKNOWN; 812 + __cpu_name[cpu] = "Broadcom BCM4710"; 875 813 break; 876 814 } 877 815 } 878 816 879 817 const char *__cpu_name[NR_CPUS]; 880 - 881 - /* 882 - * Name a CPU 883 - */ 884 - static __cpuinit const char *cpu_to_name(struct cpuinfo_mips *c) 885 - { 886 - const char *name = NULL; 887 - 888 - switch (c->cputype) { 889 - case CPU_UNKNOWN: name = "unknown"; break; 890 - case CPU_R2000: name = "R2000"; break; 891 - case CPU_R3000: name = "R3000"; break; 892 - case CPU_R3000A: name = "R3000A"; break; 893 - case CPU_R3041: name = "R3041"; break; 894 - case CPU_R3051: name = "R3051"; break; 895 - case CPU_R3052: name = "R3052"; break; 896 - case CPU_R3081: name = "R3081"; break; 897 - case CPU_R3081E: name = "R3081E"; break; 898 - case CPU_R4000PC: name = "R4000PC"; break; 899 - case CPU_R4000SC: name = "R4000SC"; break; 900 - case CPU_R4000MC: name = "R4000MC"; break; 901 - case CPU_R4200: name = "R4200"; break; 902 - case CPU_R4400PC: name = "R4400PC"; break; 903 - case CPU_R4400SC: name = "R4400SC"; break; 904 - case CPU_R4400MC: name = "R4400MC"; break; 905 - case CPU_R4600: name = "R4600"; break; 906 - case CPU_R6000: name = "R6000"; break; 907 - case CPU_R6000A: name = "R6000A"; break; 908 - case CPU_R8000: name = "R8000"; break; 909 - case CPU_R10000: name = "R10000"; break; 910 - case CPU_R12000: name = "R12000"; break; 911 - case CPU_R14000: name = "R14000"; break; 912 - case CPU_R4300: name = "R4300"; break; 913 - case CPU_R4650: name = "R4650"; break; 914 - case CPU_R4700: name = "R4700"; break; 915 - case CPU_R5000: name = "R5000"; break; 916 - case CPU_R5000A: name = "R5000A"; break; 917 - case CPU_R4640: name = "R4640"; break; 918 - case CPU_NEVADA: name = "Nevada"; break; 919 - case CPU_RM7000: name = "RM7000"; break; 920 - case CPU_RM9000: name = "RM9000"; break; 921 - case CPU_R5432: name = "R5432"; break; 922 - case CPU_4KC: name = "MIPS 4Kc"; break; 923 - case CPU_5KC: name = "MIPS 5Kc"; break; 924 - case CPU_R4310: name = "R4310"; break; 925 - case CPU_SB1: name = "SiByte SB1"; break; 926 - case CPU_SB1A: name = "SiByte SB1A"; break; 927 - case CPU_TX3912: name = "TX3912"; break; 928 - case CPU_TX3922: name = "TX3922"; break; 929 - case CPU_TX3927: name = "TX3927"; break; 930 - case CPU_AU1000: name = "Au1000"; break; 931 - case CPU_AU1500: name = "Au1500"; break; 932 - case CPU_AU1100: name = "Au1100"; break; 933 - case CPU_AU1550: name = "Au1550"; break; 934 - case CPU_AU1200: name = "Au1200"; break; 935 - case CPU_AU1210: name = "Au1210"; break; 936 - case CPU_AU1250: name = "Au1250"; break; 937 - case CPU_4KEC: name = "MIPS 4KEc"; break; 938 - case CPU_4KSC: name = "MIPS 4KSc"; break; 939 - case CPU_VR41XX: name = "NEC Vr41xx"; break; 940 - case CPU_R5500: name = "R5500"; break; 941 - case CPU_TX49XX: name = "TX49xx"; break; 942 - case CPU_20KC: name = "MIPS 20Kc"; break; 943 - case CPU_24K: name = "MIPS 24K"; break; 944 - case CPU_25KF: name = "MIPS 25Kf"; break; 945 - case CPU_34K: name = "MIPS 34K"; break; 946 - case CPU_1004K: name = "MIPS 1004K"; break; 947 - case CPU_74K: name = "MIPS 74K"; break; 948 - case CPU_VR4111: name = "NEC VR4111"; break; 949 - case CPU_VR4121: name = "NEC VR4121"; break; 950 - case CPU_VR4122: name = "NEC VR4122"; break; 951 - case CPU_VR4131: name = "NEC VR4131"; break; 952 - case CPU_VR4133: name = "NEC VR4133"; break; 953 - case CPU_VR4181: name = "NEC VR4181"; break; 954 - case CPU_VR4181A: name = "NEC VR4181A"; break; 955 - case CPU_SR71000: name = "Sandcraft SR71000"; break; 956 - case CPU_BCM3302: name = "Broadcom BCM3302"; break; 957 - case CPU_BCM4710: name = "Broadcom BCM4710"; break; 958 - case CPU_PR4450: name = "Philips PR4450"; break; 959 - case CPU_LOONGSON2: name = "ICT Loongson-2"; break; 960 - default: 961 - BUG(); 962 - } 963 - 964 - return name; 965 - } 966 818 967 819 __cpuinit void cpu_probe(void) 968 820 { ··· 889 915 c->processor_id = read_c0_prid(); 890 916 switch (c->processor_id & 0xff0000) { 891 917 case PRID_COMP_LEGACY: 892 - cpu_probe_legacy(c); 918 + cpu_probe_legacy(c, cpu); 893 919 break; 894 920 case PRID_COMP_MIPS: 895 - cpu_probe_mips(c); 921 + cpu_probe_mips(c, cpu); 896 922 break; 897 923 case PRID_COMP_ALCHEMY: 898 - cpu_probe_alchemy(c); 924 + cpu_probe_alchemy(c, cpu); 899 925 break; 900 926 case PRID_COMP_SIBYTE: 901 - cpu_probe_sibyte(c); 927 + cpu_probe_sibyte(c, cpu); 902 928 break; 903 929 case PRID_COMP_BROADCOM: 904 - cpu_probe_broadcom(c); 930 + cpu_probe_broadcom(c, cpu); 905 931 break; 906 932 case PRID_COMP_SANDCRAFT: 907 - cpu_probe_sandcraft(c); 933 + cpu_probe_sandcraft(c, cpu); 908 934 break; 909 935 case PRID_COMP_NXP: 910 - cpu_probe_nxp(c); 936 + cpu_probe_nxp(c, cpu); 911 937 break; 912 - default: 913 - c->cputype = CPU_UNKNOWN; 914 938 } 939 + 940 + BUG_ON(!__cpu_name[cpu]); 941 + BUG_ON(c->cputype == CPU_UNKNOWN); 915 942 916 943 /* 917 944 * Platform code can force the cpu type to optimize code ··· 932 957 c->ases |= MIPS_ASE_MIPS3D; 933 958 } 934 959 } 935 - 936 - __cpu_name[cpu] = cpu_to_name(c); 937 960 938 961 if (cpu_has_mips_r2) 939 962 c->srsets = ((read_c0_srsctl() >> 26) & 0x0f) + 1;
-6
arch/mips/kernel/smp.c
··· 195 195 /* preload SMP state for boot cpu */ 196 196 void __devinit smp_prepare_boot_cpu(void) 197 197 { 198 - /* 199 - * This assumes that bootup is always handled by the processor 200 - * with the logic and physical number 0. 201 - */ 202 - __cpu_number_map[0] = 0; 203 - __cpu_logical_map[0] = 0; 204 198 cpu_set(0, phys_cpu_present_map); 205 199 cpu_set(0, cpu_online_map); 206 200 cpu_set(0, cpu_callin_map);
+25 -4
arch/mips/kernel/traps.c
··· 32 32 #include <asm/cpu.h> 33 33 #include <asm/dsp.h> 34 34 #include <asm/fpu.h> 35 + #include <asm/fpu_emulator.h> 35 36 #include <asm/mipsregs.h> 36 37 #include <asm/mipsmtregs.h> 37 38 #include <asm/module.h> ··· 721 720 break; 722 721 case BRK_BUG: 723 722 die_if_kernel("Kernel bug detected", regs); 723 + force_sig(SIGTRAP, current); 724 + break; 725 + case BRK_MEMU: 726 + /* 727 + * Address errors may be deliberately induced by the FPU 728 + * emulator to retake control of the CPU after executing the 729 + * instruction in the delay slot of an emulated branch. 730 + * 731 + * Terminate if exception was recognized as a delay slot return 732 + * otherwise handle as normal. 733 + */ 734 + if (do_dsemulret(regs)) 735 + return; 736 + 737 + die_if_kernel("Math emu break/trap", regs); 724 738 force_sig(SIGTRAP, current); 725 739 break; 726 740 default: ··· 1571 1555 #ifdef CONFIG_64BIT 1572 1556 unsigned long uncached_ebase = TO_UNCAC(ebase); 1573 1557 #endif 1558 + if (cpu_has_mips_r2) 1559 + ebase += (read_c0_ebase() & 0x3ffff000); 1574 1560 1575 1561 if (!addr) 1576 1562 panic(panic_null_cerr); ··· 1606 1588 1607 1589 if (cpu_has_veic || cpu_has_vint) 1608 1590 ebase = (unsigned long) alloc_bootmem_low_pages(0x200 + VECTORSPACING*64); 1609 - else 1591 + else { 1610 1592 ebase = CAC_BASE; 1593 + if (cpu_has_mips_r2) 1594 + ebase += (read_c0_ebase() & 0x3ffff000); 1595 + } 1611 1596 1612 1597 per_cpu_trap_init(); 1613 1598 ··· 1718 1697 1719 1698 if (cpu_has_vce) 1720 1699 /* Special exception: R4[04]00 uses also the divec space. */ 1721 - memcpy((void *)(CAC_BASE + 0x180), &except_vec3_r4000, 0x100); 1700 + memcpy((void *)(ebase + 0x180), &except_vec3_r4000, 0x100); 1722 1701 else if (cpu_has_4kex) 1723 - memcpy((void *)(CAC_BASE + 0x180), &except_vec3_generic, 0x80); 1702 + memcpy((void *)(ebase + 0x180), &except_vec3_generic, 0x80); 1724 1703 else 1725 - memcpy((void *)(CAC_BASE + 0x080), &except_vec3_generic, 0x80); 1704 + memcpy((void *)(ebase + 0x080), &except_vec3_generic, 0x80); 1726 1705 1727 1706 signal_init(); 1728 1707 #ifdef CONFIG_MIPS32_COMPAT
-12
arch/mips/kernel/unaligned.c
··· 499 499 500 500 asmlinkage void do_ade(struct pt_regs *regs) 501 501 { 502 - extern int do_dsemulret(struct pt_regs *); 503 502 unsigned int __user *pc; 504 503 mm_segment_t seg; 505 - 506 - /* 507 - * Address errors may be deliberately induced by the FPU emulator to 508 - * retake control of the CPU after executing the instruction in the 509 - * delay slot of an emulated branch. 510 - */ 511 - /* Terminate if exception was recognized as a delay slot return */ 512 - if (do_dsemulret(regs)) 513 - return; 514 - 515 - /* Otherwise handle as normal */ 516 504 517 505 /* 518 506 * Did we catch a fault trying to load an instruction?
-4
arch/mips/math-emu/cp1emu.c
··· 48 48 #include <asm/branch.h> 49 49 50 50 #include "ieee754.h" 51 - #include "dsemul.h" 52 51 53 52 /* Strap kernel emulator for full MIPS IV emulation */ 54 53 ··· 345 346 /* cop control register rd -> gpr[rt] */ 346 347 u32 value; 347 348 348 - if (ir == CP1UNDEF) { 349 - return do_dsemulret(xcp); 350 - } 351 349 if (MIPSInst_RD(ir) == FPCREG_CSR) { 352 350 value = ctx->fcr31; 353 351 value = (value & ~0x3) | mips_rm[value & 0x3];
+3 -4
arch/mips/math-emu/dsemul.c
··· 18 18 #include <asm/fpu_emulator.h> 19 19 20 20 #include "ieee754.h" 21 - #include "dsemul.h" 22 21 23 22 /* Strap kernel emulator for full MIPS IV emulation */ 24 23 ··· 93 94 return SIGBUS; 94 95 95 96 err = __put_user(ir, &fr->emul); 96 - err |= __put_user((mips_instruction)BADINST, &fr->badinst); 97 + err |= __put_user((mips_instruction)BREAK_MATH, &fr->badinst); 97 98 err |= __put_user((mips_instruction)BD_COOKIE, &fr->cookie); 98 99 err |= __put_user(cpc, &fr->epc); 99 100 ··· 129 130 /* 130 131 * Do some sanity checking on the stackframe: 131 132 * 132 - * - Is the instruction pointed to by the EPC an BADINST? 133 + * - Is the instruction pointed to by the EPC an BREAK_MATH? 133 134 * - Is the following memory word the BD_COOKIE? 134 135 */ 135 136 err = __get_user(insn, &fr->badinst); 136 137 err |= __get_user(cookie, &fr->cookie); 137 138 138 - if (unlikely(err || (insn != BADINST) || (cookie != BD_COOKIE))) { 139 + if (unlikely(err || (insn != BREAK_MATH) || (cookie != BD_COOKIE))) { 139 140 fpuemustats.errors++; 140 141 return 0; 141 142 }
-17
arch/mips/math-emu/dsemul.h
··· 1 - extern int mips_dsemul(struct pt_regs *regs, mips_instruction ir, unsigned long cpc); 2 - extern int do_dsemulret(struct pt_regs *xcp); 3 - 4 - /* Instruction which will always cause an address error */ 5 - #define AdELOAD 0x8c000001 /* lw $0,1($0) */ 6 - /* Instruction which will plainly cause a CP1 exception when FPU is disabled */ 7 - #define CP1UNDEF 0x44400001 /* cfc1 $0,$0 undef */ 8 - 9 - /* Instruction inserted following the badinst to further tag the sequence */ 10 - #define BD_COOKIE 0x0000bd36 /* tne $0,$0 with baggage */ 11 - 12 - /* Setup which instruction to use for trampoline */ 13 - #ifdef STANDALONE_EMULATOR 14 - #define BADINST CP1UNDEF 15 - #else 16 - #define BADINST AdELOAD 17 - #endif
+21 -4
arch/mips/txx9/rbtx4927/setup.c
··· 49 49 #include <linux/platform_device.h> 50 50 #include <linux/delay.h> 51 51 #include <linux/gpio.h> 52 + #include <linux/leds.h> 52 53 #include <asm/io.h> 53 54 #include <asm/reboot.h> 54 55 #include <asm/txx9/generic.h> ··· 211 210 /* TX4927-SIO DTR on (PIO[15]) */ 212 211 gpio_request(15, "sio-dtr"); 213 212 gpio_direction_output(15, 1); 214 - gpio_request(0, "led"); 215 - gpio_direction_output(0, 1); 216 - gpio_request(1, "led"); 217 - gpio_direction_output(1, 1); 218 213 219 214 tx4927_sio_init(0, 0); 220 215 #ifdef CONFIG_SERIAL_TXX9_CONSOLE ··· 312 315 tx4927_mtd_init(i); 313 316 } 314 317 318 + static void __init rbtx4927_gpioled_init(void) 319 + { 320 + static struct gpio_led leds[] = { 321 + { .name = "gpioled:green:0", .gpio = 0, .active_low = 1, }, 322 + { .name = "gpioled:green:1", .gpio = 1, .active_low = 1, }, 323 + }; 324 + static struct gpio_led_platform_data pdata = { 325 + .num_leds = ARRAY_SIZE(leds), 326 + .leds = leds, 327 + }; 328 + struct platform_device *pdev = platform_device_alloc("leds-gpio", 0); 329 + 330 + if (!pdev) 331 + return; 332 + pdev->dev.platform_data = &pdata; 333 + if (platform_device_add(pdev)) 334 + platform_device_put(pdev); 335 + } 336 + 315 337 static void __init rbtx4927_device_init(void) 316 338 { 317 339 toshiba_rbtx4927_rtc_init(); ··· 338 322 tx4927_wdt_init(); 339 323 rbtx4927_mtd_init(); 340 324 txx9_iocled_init(RBTX4927_LED_ADDR - IO_BASE, -1, 3, 1, "green", NULL); 325 + rbtx4927_gpioled_init(); 341 326 } 342 327 343 328 struct txx9_board_vec rbtx4927_vec __initdata = {
+10 -4
arch/mips/txx9/rbtx4939/setup.c
··· 308 308 #if defined(CONFIG_TC35815) || defined(CONFIG_TC35815_MODULE) 309 309 int i, j; 310 310 unsigned char ethaddr[2][6]; 311 + u8 bdipsw = readb(rbtx4939_bdipsw_addr) & 0x0f; 312 + 311 313 for (i = 0; i < 2; i++) { 312 314 unsigned long area = CKSEG1 + 0x1fff0000 + (i * 0x10); 313 - if (readb(rbtx4939_bdipsw_addr) & 8) { 315 + if (bdipsw == 0) 316 + memcpy(ethaddr[i], (void *)area, 6); 317 + else { 314 318 u16 buf[3]; 315 - area -= 0x03000000; 319 + if (bdipsw & 8) 320 + area -= 0x03000000; 321 + else 322 + area -= 0x01000000; 316 323 for (j = 0; j < 3; j++) 317 324 buf[j] = le16_to_cpup((u16 *)(area + j * 2)); 318 325 memcpy(ethaddr[i], buf, 6); 319 - } else 320 - memcpy(ethaddr[i], (void *)area, 6); 326 + } 321 327 } 322 328 tx4939_ethaddr_init(ethaddr[0], ethaddr[1]); 323 329 #endif
-22
drivers/char/Kconfig
··· 812 812 To compile this driver as a module, choose M here: the 813 813 module will be called js-rtc. 814 814 815 - config SGI_DS1286 816 - tristate "SGI DS1286 RTC support" 817 - depends on SGI_HAS_DS1286 818 - help 819 - If you say Y here and create a character special file /dev/rtc with 820 - major number 10 and minor number 135 using mknod ("man mknod"), you 821 - will get access to the real time clock built into your computer. 822 - Every SGI has such a clock built in. It reports status information 823 - via the file /proc/rtc and its behaviour is set by various ioctls on 824 - /dev/rtc. 825 - 826 - config SGI_IP27_RTC 827 - bool "SGI M48T35 RTC support" 828 - depends on SGI_IP27 829 - help 830 - If you say Y here and create a character special file /dev/rtc with 831 - major number 10 and minor number 135 using mknod ("man mknod"), you 832 - will get access to the real time clock built into your computer. 833 - Every SGI has such a clock built in. It reports status information 834 - via the file /proc/rtc and its behaviour is set by various ioctls on 835 - /dev/rtc. 836 - 837 815 config GEN_RTC 838 816 tristate "Generic /dev/rtc emulation" 839 817 depends on RTC!=y && !IA64 && !ARM && !M32R && !MIPS && !SPARC && !FRV && !S390 && !SUPERH && !AVR32
-2
drivers/char/Makefile
··· 74 74 obj-$(CONFIG_HPET) += hpet.o 75 75 obj-$(CONFIG_GEN_RTC) += genrtc.o 76 76 obj-$(CONFIG_EFI_RTC) += efirtc.o 77 - obj-$(CONFIG_SGI_DS1286) += ds1286.o 78 - obj-$(CONFIG_SGI_IP27_RTC) += ip27-rtc.o 79 77 obj-$(CONFIG_DS1302) += ds1302.o 80 78 obj-$(CONFIG_XILINX_HWICAP) += xilinx_hwicap/ 81 79 ifeq ($(CONFIG_GENERIC_NVRAM),y)
-585
drivers/char/ds1286.c
··· 1 - /* 2 - * DS1286 Real Time Clock interface for Linux 3 - * 4 - * Copyright (C) 1998, 1999, 2000 Ralf Baechle 5 - * 6 - * Based on code written by Paul Gortmaker. 7 - * 8 - * This driver allows use of the real time clock (built into nearly all 9 - * computers) from user space. It exports the /dev/rtc interface supporting 10 - * various ioctl() and also the /proc/rtc pseudo-file for status 11 - * information. 12 - * 13 - * The ioctls can be used to set the interrupt behaviour and generation rate 14 - * from the RTC via IRQ 8. Then the /dev/rtc interface can be used to make 15 - * use of these timer interrupts, be they interval or alarm based. 16 - * 17 - * The /dev/rtc interface will block on reads until an interrupt has been 18 - * received. If a RTC interrupt has already happened, it will output an 19 - * unsigned long and then block. The output value contains the interrupt 20 - * status in the low byte and the number of interrupts since the last read 21 - * in the remaining high bytes. The /dev/rtc interface can also be used with 22 - * the select(2) call. 23 - * 24 - * This program is free software; you can redistribute it and/or modify it 25 - * under the terms of the GNU General Public License as published by the 26 - * Free Software Foundation; either version 2 of the License, or (at your 27 - * option) any later version. 28 - */ 29 - #include <linux/ds1286.h> 30 - #include <linux/smp_lock.h> 31 - #include <linux/types.h> 32 - #include <linux/errno.h> 33 - #include <linux/miscdevice.h> 34 - #include <linux/slab.h> 35 - #include <linux/ioport.h> 36 - #include <linux/fcntl.h> 37 - #include <linux/init.h> 38 - #include <linux/poll.h> 39 - #include <linux/rtc.h> 40 - #include <linux/spinlock.h> 41 - #include <linux/bcd.h> 42 - #include <linux/proc_fs.h> 43 - #include <linux/jiffies.h> 44 - 45 - #include <asm/uaccess.h> 46 - #include <asm/system.h> 47 - 48 - #define DS1286_VERSION "1.0" 49 - 50 - /* 51 - * We sponge a minor off of the misc major. No need slurping 52 - * up another valuable major dev number for this. If you add 53 - * an ioctl, make sure you don't conflict with SPARC's RTC 54 - * ioctls. 55 - */ 56 - 57 - static DECLARE_WAIT_QUEUE_HEAD(ds1286_wait); 58 - 59 - static ssize_t ds1286_read(struct file *file, char *buf, 60 - size_t count, loff_t *ppos); 61 - 62 - static int ds1286_ioctl(struct inode *inode, struct file *file, 63 - unsigned int cmd, unsigned long arg); 64 - 65 - static unsigned int ds1286_poll(struct file *file, poll_table *wait); 66 - 67 - static void ds1286_get_alm_time (struct rtc_time *alm_tm); 68 - static void ds1286_get_time(struct rtc_time *rtc_tm); 69 - static int ds1286_set_time(struct rtc_time *rtc_tm); 70 - 71 - static inline unsigned char ds1286_is_updating(void); 72 - 73 - static DEFINE_SPINLOCK(ds1286_lock); 74 - 75 - static int ds1286_read_proc(char *page, char **start, off_t off, 76 - int count, int *eof, void *data); 77 - 78 - /* 79 - * Bits in rtc_status. (7 bits of room for future expansion) 80 - */ 81 - 82 - #define RTC_IS_OPEN 0x01 /* means /dev/rtc is in use */ 83 - #define RTC_TIMER_ON 0x02 /* missed irq timer active */ 84 - 85 - static unsigned char ds1286_status; /* bitmapped status byte. */ 86 - 87 - static unsigned char days_in_mo[] = { 88 - 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 89 - }; 90 - 91 - /* 92 - * Now all the various file operations that we export. 93 - */ 94 - 95 - static ssize_t ds1286_read(struct file *file, char *buf, 96 - size_t count, loff_t *ppos) 97 - { 98 - return -EIO; 99 - } 100 - 101 - static int ds1286_ioctl(struct inode *inode, struct file *file, 102 - unsigned int cmd, unsigned long arg) 103 - { 104 - struct rtc_time wtime; 105 - 106 - switch (cmd) { 107 - case RTC_AIE_OFF: /* Mask alarm int. enab. bit */ 108 - { 109 - unsigned long flags; 110 - unsigned char val; 111 - 112 - if (!capable(CAP_SYS_TIME)) 113 - return -EACCES; 114 - 115 - spin_lock_irqsave(&ds1286_lock, flags); 116 - val = rtc_read(RTC_CMD); 117 - val |= RTC_TDM; 118 - rtc_write(val, RTC_CMD); 119 - spin_unlock_irqrestore(&ds1286_lock, flags); 120 - 121 - return 0; 122 - } 123 - case RTC_AIE_ON: /* Allow alarm interrupts. */ 124 - { 125 - unsigned long flags; 126 - unsigned char val; 127 - 128 - if (!capable(CAP_SYS_TIME)) 129 - return -EACCES; 130 - 131 - spin_lock_irqsave(&ds1286_lock, flags); 132 - val = rtc_read(RTC_CMD); 133 - val &= ~RTC_TDM; 134 - rtc_write(val, RTC_CMD); 135 - spin_unlock_irqrestore(&ds1286_lock, flags); 136 - 137 - return 0; 138 - } 139 - case RTC_WIE_OFF: /* Mask watchdog int. enab. bit */ 140 - { 141 - unsigned long flags; 142 - unsigned char val; 143 - 144 - if (!capable(CAP_SYS_TIME)) 145 - return -EACCES; 146 - 147 - spin_lock_irqsave(&ds1286_lock, flags); 148 - val = rtc_read(RTC_CMD); 149 - val |= RTC_WAM; 150 - rtc_write(val, RTC_CMD); 151 - spin_unlock_irqrestore(&ds1286_lock, flags); 152 - 153 - return 0; 154 - } 155 - case RTC_WIE_ON: /* Allow watchdog interrupts. */ 156 - { 157 - unsigned long flags; 158 - unsigned char val; 159 - 160 - if (!capable(CAP_SYS_TIME)) 161 - return -EACCES; 162 - 163 - spin_lock_irqsave(&ds1286_lock, flags); 164 - val = rtc_read(RTC_CMD); 165 - val &= ~RTC_WAM; 166 - rtc_write(val, RTC_CMD); 167 - spin_unlock_irqrestore(&ds1286_lock, flags); 168 - 169 - return 0; 170 - } 171 - case RTC_ALM_READ: /* Read the present alarm time */ 172 - { 173 - /* 174 - * This returns a struct rtc_time. Reading >= 0xc0 175 - * means "don't care" or "match all". Only the tm_hour, 176 - * tm_min, and tm_sec values are filled in. 177 - */ 178 - 179 - memset(&wtime, 0, sizeof(wtime)); 180 - ds1286_get_alm_time(&wtime); 181 - break; 182 - } 183 - case RTC_ALM_SET: /* Store a time into the alarm */ 184 - { 185 - /* 186 - * This expects a struct rtc_time. Writing 0xff means 187 - * "don't care" or "match all". Only the tm_hour, 188 - * tm_min and tm_sec are used. 189 - */ 190 - unsigned char hrs, min, sec; 191 - struct rtc_time alm_tm; 192 - 193 - if (!capable(CAP_SYS_TIME)) 194 - return -EACCES; 195 - 196 - if (copy_from_user(&alm_tm, (struct rtc_time*)arg, 197 - sizeof(struct rtc_time))) 198 - return -EFAULT; 199 - 200 - hrs = alm_tm.tm_hour; 201 - min = alm_tm.tm_min; 202 - sec = alm_tm.tm_sec; 203 - 204 - if (hrs >= 24) 205 - hrs = 0xff; 206 - 207 - if (min >= 60) 208 - min = 0xff; 209 - 210 - if (sec != 0) 211 - return -EINVAL; 212 - 213 - min = bin2bcd(min); 214 - min = bin2bcd(hrs); 215 - 216 - spin_lock(&ds1286_lock); 217 - rtc_write(hrs, RTC_HOURS_ALARM); 218 - rtc_write(min, RTC_MINUTES_ALARM); 219 - spin_unlock(&ds1286_lock); 220 - 221 - return 0; 222 - } 223 - case RTC_RD_TIME: /* Read the time/date from RTC */ 224 - { 225 - memset(&wtime, 0, sizeof(wtime)); 226 - ds1286_get_time(&wtime); 227 - break; 228 - } 229 - case RTC_SET_TIME: /* Set the RTC */ 230 - { 231 - struct rtc_time rtc_tm; 232 - 233 - if (!capable(CAP_SYS_TIME)) 234 - return -EACCES; 235 - 236 - if (copy_from_user(&rtc_tm, (struct rtc_time*)arg, 237 - sizeof(struct rtc_time))) 238 - return -EFAULT; 239 - 240 - return ds1286_set_time(&rtc_tm); 241 - } 242 - default: 243 - return -EINVAL; 244 - } 245 - return copy_to_user((void *)arg, &wtime, sizeof wtime) ? -EFAULT : 0; 246 - } 247 - 248 - /* 249 - * We enforce only one user at a time here with the open/close. 250 - * Also clear the previous interrupt data on an open, and clean 251 - * up things on a close. 252 - */ 253 - 254 - static int ds1286_open(struct inode *inode, struct file *file) 255 - { 256 - lock_kernel(); 257 - spin_lock_irq(&ds1286_lock); 258 - 259 - if (ds1286_status & RTC_IS_OPEN) 260 - goto out_busy; 261 - 262 - ds1286_status |= RTC_IS_OPEN; 263 - 264 - spin_unlock_irq(&ds1286_lock); 265 - unlock_kernel(); 266 - return 0; 267 - 268 - out_busy: 269 - spin_lock_irq(&ds1286_lock); 270 - unlock_kernel(); 271 - return -EBUSY; 272 - } 273 - 274 - static int ds1286_release(struct inode *inode, struct file *file) 275 - { 276 - ds1286_status &= ~RTC_IS_OPEN; 277 - 278 - return 0; 279 - } 280 - 281 - static unsigned int ds1286_poll(struct file *file, poll_table *wait) 282 - { 283 - poll_wait(file, &ds1286_wait, wait); 284 - 285 - return 0; 286 - } 287 - 288 - /* 289 - * The various file operations we support. 290 - */ 291 - 292 - static const struct file_operations ds1286_fops = { 293 - .llseek = no_llseek, 294 - .read = ds1286_read, 295 - .poll = ds1286_poll, 296 - .ioctl = ds1286_ioctl, 297 - .open = ds1286_open, 298 - .release = ds1286_release, 299 - }; 300 - 301 - static struct miscdevice ds1286_dev= 302 - { 303 - .minor = RTC_MINOR, 304 - .name = "rtc", 305 - .fops = &ds1286_fops, 306 - }; 307 - 308 - static int __init ds1286_init(void) 309 - { 310 - int err; 311 - 312 - printk(KERN_INFO "DS1286 Real Time Clock Driver v%s\n", DS1286_VERSION); 313 - 314 - err = misc_register(&ds1286_dev); 315 - if (err) 316 - goto out; 317 - 318 - if (!create_proc_read_entry("driver/rtc", 0, 0, ds1286_read_proc, NULL)) { 319 - err = -ENOMEM; 320 - 321 - goto out_deregister; 322 - } 323 - 324 - return 0; 325 - 326 - out_deregister: 327 - misc_deregister(&ds1286_dev); 328 - 329 - out: 330 - return err; 331 - } 332 - 333 - static void __exit ds1286_exit(void) 334 - { 335 - remove_proc_entry("driver/rtc", NULL); 336 - misc_deregister(&ds1286_dev); 337 - } 338 - 339 - static char *days[] = { 340 - "***", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" 341 - }; 342 - 343 - /* 344 - * Info exported via "/proc/rtc". 345 - */ 346 - static int ds1286_proc_output(char *buf) 347 - { 348 - char *p, *s; 349 - struct rtc_time tm; 350 - unsigned char hundredth, month, cmd, amode; 351 - 352 - p = buf; 353 - 354 - ds1286_get_time(&tm); 355 - hundredth = rtc_read(RTC_HUNDREDTH_SECOND); 356 - hundredth = bcd2bin(hundredth); 357 - 358 - p += sprintf(p, 359 - "rtc_time\t: %02d:%02d:%02d.%02d\n" 360 - "rtc_date\t: %04d-%02d-%02d\n", 361 - tm.tm_hour, tm.tm_min, tm.tm_sec, hundredth, 362 - tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday); 363 - 364 - /* 365 - * We implicitly assume 24hr mode here. Alarm values >= 0xc0 will 366 - * match any value for that particular field. Values that are 367 - * greater than a valid time, but less than 0xc0 shouldn't appear. 368 - */ 369 - ds1286_get_alm_time(&tm); 370 - p += sprintf(p, "alarm\t\t: %s ", days[tm.tm_wday]); 371 - if (tm.tm_hour <= 24) 372 - p += sprintf(p, "%02d:", tm.tm_hour); 373 - else 374 - p += sprintf(p, "**:"); 375 - 376 - if (tm.tm_min <= 59) 377 - p += sprintf(p, "%02d\n", tm.tm_min); 378 - else 379 - p += sprintf(p, "**\n"); 380 - 381 - month = rtc_read(RTC_MONTH); 382 - p += sprintf(p, 383 - "oscillator\t: %s\n" 384 - "square_wave\t: %s\n", 385 - (month & RTC_EOSC) ? "disabled" : "enabled", 386 - (month & RTC_ESQW) ? "disabled" : "enabled"); 387 - 388 - amode = ((rtc_read(RTC_MINUTES_ALARM) & 0x80) >> 5) | 389 - ((rtc_read(RTC_HOURS_ALARM) & 0x80) >> 6) | 390 - ((rtc_read(RTC_DAY_ALARM) & 0x80) >> 7); 391 - if (amode == 7) s = "each minute"; 392 - else if (amode == 3) s = "minutes match"; 393 - else if (amode == 1) s = "hours and minutes match"; 394 - else if (amode == 0) s = "days, hours and minutes match"; 395 - else s = "invalid"; 396 - p += sprintf(p, "alarm_mode\t: %s\n", s); 397 - 398 - cmd = rtc_read(RTC_CMD); 399 - p += sprintf(p, 400 - "alarm_enable\t: %s\n" 401 - "wdog_alarm\t: %s\n" 402 - "alarm_mask\t: %s\n" 403 - "wdog_alarm_mask\t: %s\n" 404 - "interrupt_mode\t: %s\n" 405 - "INTB_mode\t: %s_active\n" 406 - "interrupt_pins\t: %s\n", 407 - (cmd & RTC_TDF) ? "yes" : "no", 408 - (cmd & RTC_WAF) ? "yes" : "no", 409 - (cmd & RTC_TDM) ? "disabled" : "enabled", 410 - (cmd & RTC_WAM) ? "disabled" : "enabled", 411 - (cmd & RTC_PU_LVL) ? "pulse" : "level", 412 - (cmd & RTC_IBH_LO) ? "low" : "high", 413 - (cmd & RTC_IPSW) ? "unswapped" : "swapped"); 414 - 415 - return p - buf; 416 - } 417 - 418 - static int ds1286_read_proc(char *page, char **start, off_t off, 419 - int count, int *eof, void *data) 420 - { 421 - int len = ds1286_proc_output (page); 422 - if (len <= off+count) *eof = 1; 423 - *start = page + off; 424 - len -= off; 425 - if (len>count) 426 - len = count; 427 - if (len<0) 428 - len = 0; 429 - 430 - return len; 431 - } 432 - 433 - /* 434 - * Returns true if a clock update is in progress 435 - */ 436 - static inline unsigned char ds1286_is_updating(void) 437 - { 438 - return rtc_read(RTC_CMD) & RTC_TE; 439 - } 440 - 441 - 442 - static void ds1286_get_time(struct rtc_time *rtc_tm) 443 - { 444 - unsigned char save_control; 445 - unsigned long flags; 446 - 447 - /* 448 - * read RTC once any update in progress is done. The update 449 - * can take just over 2ms. We wait 10 to 20ms. There is no need to 450 - * to poll-wait (up to 1s - eeccch) for the falling edge of RTC_UIP. 451 - * If you need to know *exactly* when a second has started, enable 452 - * periodic update complete interrupts, (via ioctl) and then 453 - * immediately read /dev/rtc which will block until you get the IRQ. 454 - * Once the read clears, read the RTC time (again via ioctl). Easy. 455 - */ 456 - 457 - if (ds1286_is_updating() != 0) 458 - msleep(20); 459 - 460 - /* 461 - * Only the values that we read from the RTC are set. We leave 462 - * tm_wday, tm_yday and tm_isdst untouched. Even though the 463 - * RTC has RTC_DAY_OF_WEEK, we ignore it, as it is only updated 464 - * by the RTC when initially set to a non-zero value. 465 - */ 466 - spin_lock_irqsave(&ds1286_lock, flags); 467 - save_control = rtc_read(RTC_CMD); 468 - rtc_write((save_control|RTC_TE), RTC_CMD); 469 - 470 - rtc_tm->tm_sec = rtc_read(RTC_SECONDS); 471 - rtc_tm->tm_min = rtc_read(RTC_MINUTES); 472 - rtc_tm->tm_hour = rtc_read(RTC_HOURS) & 0x3f; 473 - rtc_tm->tm_mday = rtc_read(RTC_DATE); 474 - rtc_tm->tm_mon = rtc_read(RTC_MONTH) & 0x1f; 475 - rtc_tm->tm_year = rtc_read(RTC_YEAR); 476 - 477 - rtc_write(save_control, RTC_CMD); 478 - spin_unlock_irqrestore(&ds1286_lock, flags); 479 - 480 - rtc_tm->tm_sec = bcd2bin(rtc_tm->tm_sec); 481 - rtc_tm->tm_min = bcd2bin(rtc_tm->tm_min); 482 - rtc_tm->tm_hour = bcd2bin(rtc_tm->tm_hour); 483 - rtc_tm->tm_mday = bcd2bin(rtc_tm->tm_mday); 484 - rtc_tm->tm_mon = bcd2bin(rtc_tm->tm_mon); 485 - rtc_tm->tm_year = bcd2bin(rtc_tm->tm_year); 486 - 487 - /* 488 - * Account for differences between how the RTC uses the values 489 - * and how they are defined in a struct rtc_time; 490 - */ 491 - if (rtc_tm->tm_year < 45) 492 - rtc_tm->tm_year += 30; 493 - if ((rtc_tm->tm_year += 40) < 70) 494 - rtc_tm->tm_year += 100; 495 - 496 - rtc_tm->tm_mon--; 497 - } 498 - 499 - static int ds1286_set_time(struct rtc_time *rtc_tm) 500 - { 501 - unsigned char mon, day, hrs, min, sec, leap_yr; 502 - unsigned char save_control; 503 - unsigned int yrs; 504 - unsigned long flags; 505 - 506 - 507 - yrs = rtc_tm->tm_year + 1900; 508 - mon = rtc_tm->tm_mon + 1; /* tm_mon starts at zero */ 509 - day = rtc_tm->tm_mday; 510 - hrs = rtc_tm->tm_hour; 511 - min = rtc_tm->tm_min; 512 - sec = rtc_tm->tm_sec; 513 - 514 - if (yrs < 1970) 515 - return -EINVAL; 516 - 517 - leap_yr = ((!(yrs % 4) && (yrs % 100)) || !(yrs % 400)); 518 - 519 - if ((mon > 12) || (day == 0)) 520 - return -EINVAL; 521 - 522 - if (day > (days_in_mo[mon] + ((mon == 2) && leap_yr))) 523 - return -EINVAL; 524 - 525 - if ((hrs >= 24) || (min >= 60) || (sec >= 60)) 526 - return -EINVAL; 527 - 528 - if ((yrs -= 1940) > 255) /* They are unsigned */ 529 - return -EINVAL; 530 - 531 - if (yrs >= 100) 532 - yrs -= 100; 533 - 534 - sec = bin2bcd(sec); 535 - min = bin2bcd(min); 536 - hrs = bin2bcd(hrs); 537 - day = bin2bcd(day); 538 - mon = bin2bcd(mon); 539 - yrs = bin2bcd(yrs); 540 - 541 - spin_lock_irqsave(&ds1286_lock, flags); 542 - save_control = rtc_read(RTC_CMD); 543 - rtc_write((save_control|RTC_TE), RTC_CMD); 544 - 545 - rtc_write(yrs, RTC_YEAR); 546 - rtc_write(mon, RTC_MONTH); 547 - rtc_write(day, RTC_DATE); 548 - rtc_write(hrs, RTC_HOURS); 549 - rtc_write(min, RTC_MINUTES); 550 - rtc_write(sec, RTC_SECONDS); 551 - rtc_write(0, RTC_HUNDREDTH_SECOND); 552 - 553 - rtc_write(save_control, RTC_CMD); 554 - spin_unlock_irqrestore(&ds1286_lock, flags); 555 - 556 - return 0; 557 - } 558 - 559 - static void ds1286_get_alm_time(struct rtc_time *alm_tm) 560 - { 561 - unsigned char cmd; 562 - unsigned long flags; 563 - 564 - /* 565 - * Only the values that we read from the RTC are set. That 566 - * means only tm_wday, tm_hour, tm_min. 567 - */ 568 - spin_lock_irqsave(&ds1286_lock, flags); 569 - alm_tm->tm_min = rtc_read(RTC_MINUTES_ALARM) & 0x7f; 570 - alm_tm->tm_hour = rtc_read(RTC_HOURS_ALARM) & 0x1f; 571 - alm_tm->tm_wday = rtc_read(RTC_DAY_ALARM) & 0x07; 572 - cmd = rtc_read(RTC_CMD); 573 - spin_unlock_irqrestore(&ds1286_lock, flags); 574 - 575 - alm_tm->tm_min = bcd2bin(alm_tm->tm_min); 576 - alm_tm->tm_hour = bcd2bin(alm_tm->tm_hour); 577 - alm_tm->tm_sec = 0; 578 - } 579 - 580 - module_init(ds1286_init); 581 - module_exit(ds1286_exit); 582 - 583 - MODULE_AUTHOR("Ralf Baechle"); 584 - MODULE_LICENSE("GPL"); 585 - MODULE_ALIAS_MISCDEV(RTC_MINOR);
-329
drivers/char/ip27-rtc.c
··· 1 - /* 2 - * Driver for the SGS-Thomson M48T35 Timekeeper RAM chip 3 - * 4 - * Real Time Clock interface for Linux 5 - * 6 - * TODO: Implement periodic interrupts. 7 - * 8 - * Copyright (C) 2000 Silicon Graphics, Inc. 9 - * Written by Ulf Carlsson (ulfc@engr.sgi.com) 10 - * 11 - * Based on code written by Paul Gortmaker. 12 - * 13 - * This driver allows use of the real time clock (built into 14 - * nearly all computers) from user space. It exports the /dev/rtc 15 - * interface supporting various ioctl() and also the /proc/rtc 16 - * pseudo-file for status information. 17 - * 18 - * This program is free software; you can redistribute it and/or 19 - * modify it under the terms of the GNU General Public License 20 - * as published by the Free Software Foundation; either version 21 - * 2 of the License, or (at your option) any later version. 22 - * 23 - */ 24 - 25 - #define RTC_VERSION "1.09b" 26 - 27 - #include <linux/bcd.h> 28 - #include <linux/module.h> 29 - #include <linux/kernel.h> 30 - #include <linux/smp_lock.h> 31 - #include <linux/types.h> 32 - #include <linux/miscdevice.h> 33 - #include <linux/ioport.h> 34 - #include <linux/fcntl.h> 35 - #include <linux/rtc.h> 36 - #include <linux/init.h> 37 - #include <linux/poll.h> 38 - #include <linux/proc_fs.h> 39 - 40 - #include <asm/m48t35.h> 41 - #include <asm/sn/ioc3.h> 42 - #include <asm/io.h> 43 - #include <asm/uaccess.h> 44 - #include <asm/system.h> 45 - #include <asm/sn/klconfig.h> 46 - #include <asm/sn/sn0/ip27.h> 47 - #include <asm/sn/sn0/hub.h> 48 - #include <asm/sn/sn_private.h> 49 - 50 - static long rtc_ioctl(struct file *filp, unsigned int cmd, 51 - unsigned long arg); 52 - 53 - static int rtc_read_proc(char *page, char **start, off_t off, 54 - int count, int *eof, void *data); 55 - 56 - static void get_rtc_time(struct rtc_time *rtc_tm); 57 - 58 - /* 59 - * Bits in rtc_status. (6 bits of room for future expansion) 60 - */ 61 - 62 - #define RTC_IS_OPEN 0x01 /* means /dev/rtc is in use */ 63 - #define RTC_TIMER_ON 0x02 /* missed irq timer active */ 64 - 65 - static unsigned char rtc_status; /* bitmapped status byte. */ 66 - static unsigned long rtc_freq; /* Current periodic IRQ rate */ 67 - static struct m48t35_rtc *rtc; 68 - 69 - /* 70 - * If this driver ever becomes modularised, it will be really nice 71 - * to make the epoch retain its value across module reload... 72 - */ 73 - 74 - static unsigned long epoch = 1970; /* year corresponding to 0x00 */ 75 - 76 - static const unsigned char days_in_mo[] = 77 - {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; 78 - 79 - static long rtc_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) 80 - { 81 - 82 - struct rtc_time wtime; 83 - 84 - switch (cmd) { 85 - case RTC_RD_TIME: /* Read the time/date from RTC */ 86 - { 87 - get_rtc_time(&wtime); 88 - break; 89 - } 90 - case RTC_SET_TIME: /* Set the RTC */ 91 - { 92 - struct rtc_time rtc_tm; 93 - unsigned char mon, day, hrs, min, sec, leap_yr; 94 - unsigned int yrs; 95 - 96 - if (!capable(CAP_SYS_TIME)) 97 - return -EACCES; 98 - 99 - if (copy_from_user(&rtc_tm, (struct rtc_time*)arg, 100 - sizeof(struct rtc_time))) 101 - return -EFAULT; 102 - 103 - yrs = rtc_tm.tm_year + 1900; 104 - mon = rtc_tm.tm_mon + 1; /* tm_mon starts at zero */ 105 - day = rtc_tm.tm_mday; 106 - hrs = rtc_tm.tm_hour; 107 - min = rtc_tm.tm_min; 108 - sec = rtc_tm.tm_sec; 109 - 110 - if (yrs < 1970) 111 - return -EINVAL; 112 - 113 - leap_yr = ((!(yrs % 4) && (yrs % 100)) || !(yrs % 400)); 114 - 115 - if ((mon > 12) || (day == 0)) 116 - return -EINVAL; 117 - 118 - if (day > (days_in_mo[mon] + ((mon == 2) && leap_yr))) 119 - return -EINVAL; 120 - 121 - if ((hrs >= 24) || (min >= 60) || (sec >= 60)) 122 - return -EINVAL; 123 - 124 - if ((yrs -= epoch) > 255) /* They are unsigned */ 125 - return -EINVAL; 126 - 127 - if (yrs > 169) 128 - return -EINVAL; 129 - 130 - if (yrs >= 100) 131 - yrs -= 100; 132 - 133 - sec = bin2bcd(sec); 134 - min = bin2bcd(min); 135 - hrs = bin2bcd(hrs); 136 - day = bin2bcd(day); 137 - mon = bin2bcd(mon); 138 - yrs = bin2bcd(yrs); 139 - 140 - spin_lock_irq(&rtc_lock); 141 - rtc->control |= M48T35_RTC_SET; 142 - rtc->year = yrs; 143 - rtc->month = mon; 144 - rtc->date = day; 145 - rtc->hour = hrs; 146 - rtc->min = min; 147 - rtc->sec = sec; 148 - rtc->control &= ~M48T35_RTC_SET; 149 - spin_unlock_irq(&rtc_lock); 150 - 151 - return 0; 152 - } 153 - default: 154 - return -EINVAL; 155 - } 156 - return copy_to_user((void *)arg, &wtime, sizeof wtime) ? -EFAULT : 0; 157 - } 158 - 159 - /* 160 - * We enforce only one user at a time here with the open/close. 161 - * Also clear the previous interrupt data on an open, and clean 162 - * up things on a close. 163 - */ 164 - 165 - static int rtc_open(struct inode *inode, struct file *file) 166 - { 167 - lock_kernel(); 168 - spin_lock_irq(&rtc_lock); 169 - 170 - if (rtc_status & RTC_IS_OPEN) { 171 - spin_unlock_irq(&rtc_lock); 172 - unlock_kernel(); 173 - return -EBUSY; 174 - } 175 - 176 - rtc_status |= RTC_IS_OPEN; 177 - spin_unlock_irq(&rtc_lock); 178 - unlock_kernel(); 179 - 180 - return 0; 181 - } 182 - 183 - static int rtc_release(struct inode *inode, struct file *file) 184 - { 185 - /* 186 - * Turn off all interrupts once the device is no longer 187 - * in use, and clear the data. 188 - */ 189 - 190 - spin_lock_irq(&rtc_lock); 191 - rtc_status &= ~RTC_IS_OPEN; 192 - spin_unlock_irq(&rtc_lock); 193 - 194 - return 0; 195 - } 196 - 197 - /* 198 - * The various file operations we support. 199 - */ 200 - 201 - static const struct file_operations rtc_fops = { 202 - .owner = THIS_MODULE, 203 - .unlocked_ioctl = rtc_ioctl, 204 - .open = rtc_open, 205 - .release = rtc_release, 206 - }; 207 - 208 - static struct miscdevice rtc_dev= 209 - { 210 - RTC_MINOR, 211 - "rtc", 212 - &rtc_fops 213 - }; 214 - 215 - static int __init rtc_init(void) 216 - { 217 - rtc = (struct m48t35_rtc *) 218 - (KL_CONFIG_CH_CONS_INFO(master_nasid)->memory_base + IOC3_BYTEBUS_DEV0); 219 - 220 - printk(KERN_INFO "Real Time Clock Driver v%s\n", RTC_VERSION); 221 - if (misc_register(&rtc_dev)) { 222 - printk(KERN_ERR "rtc: cannot register misc device.\n"); 223 - return -ENODEV; 224 - } 225 - if (!create_proc_read_entry("driver/rtc", 0, NULL, rtc_read_proc, NULL)) { 226 - printk(KERN_ERR "rtc: cannot create /proc/rtc.\n"); 227 - misc_deregister(&rtc_dev); 228 - return -ENOENT; 229 - } 230 - 231 - rtc_freq = 1024; 232 - 233 - return 0; 234 - } 235 - 236 - static void __exit rtc_exit (void) 237 - { 238 - /* interrupts and timer disabled at this point by rtc_release */ 239 - 240 - remove_proc_entry ("rtc", NULL); 241 - misc_deregister(&rtc_dev); 242 - } 243 - 244 - module_init(rtc_init); 245 - module_exit(rtc_exit); 246 - 247 - /* 248 - * Info exported via "/proc/rtc". 249 - */ 250 - 251 - static int rtc_get_status(char *buf) 252 - { 253 - char *p; 254 - struct rtc_time tm; 255 - 256 - /* 257 - * Just emulate the standard /proc/rtc 258 - */ 259 - 260 - p = buf; 261 - 262 - get_rtc_time(&tm); 263 - 264 - /* 265 - * There is no way to tell if the luser has the RTC set for local 266 - * time or for Universal Standard Time (GMT). Probably local though. 267 - */ 268 - p += sprintf(p, 269 - "rtc_time\t: %02d:%02d:%02d\n" 270 - "rtc_date\t: %04d-%02d-%02d\n" 271 - "rtc_epoch\t: %04lu\n" 272 - "24hr\t\t: yes\n", 273 - tm.tm_hour, tm.tm_min, tm.tm_sec, 274 - tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, epoch); 275 - 276 - return p - buf; 277 - } 278 - 279 - static int rtc_read_proc(char *page, char **start, off_t off, 280 - int count, int *eof, void *data) 281 - { 282 - int len = rtc_get_status(page); 283 - if (len <= off+count) *eof = 1; 284 - *start = page + off; 285 - len -= off; 286 - if (len>count) len = count; 287 - if (len<0) len = 0; 288 - return len; 289 - } 290 - 291 - static void get_rtc_time(struct rtc_time *rtc_tm) 292 - { 293 - /* 294 - * Do we need to wait for the last update to finish? 295 - */ 296 - 297 - /* 298 - * Only the values that we read from the RTC are set. We leave 299 - * tm_wday, tm_yday and tm_isdst untouched. Even though the 300 - * RTC has RTC_DAY_OF_WEEK, we ignore it, as it is only updated 301 - * by the RTC when initially set to a non-zero value. 302 - */ 303 - spin_lock_irq(&rtc_lock); 304 - rtc->control |= M48T35_RTC_READ; 305 - rtc_tm->tm_sec = rtc->sec; 306 - rtc_tm->tm_min = rtc->min; 307 - rtc_tm->tm_hour = rtc->hour; 308 - rtc_tm->tm_mday = rtc->date; 309 - rtc_tm->tm_mon = rtc->month; 310 - rtc_tm->tm_year = rtc->year; 311 - rtc->control &= ~M48T35_RTC_READ; 312 - spin_unlock_irq(&rtc_lock); 313 - 314 - rtc_tm->tm_sec = bcd2bin(rtc_tm->tm_sec); 315 - rtc_tm->tm_min = bcd2bin(rtc_tm->tm_min); 316 - rtc_tm->tm_hour = bcd2bin(rtc_tm->tm_hour); 317 - rtc_tm->tm_mday = bcd2bin(rtc_tm->tm_mday); 318 - rtc_tm->tm_mon = bcd2bin(rtc_tm->tm_mon); 319 - rtc_tm->tm_year = bcd2bin(rtc_tm->tm_year); 320 - 321 - /* 322 - * Account for differences between how the RTC uses the values 323 - * and how they are defined in a struct rtc_time; 324 - */ 325 - if ((rtc_tm->tm_year += (epoch - 1900)) <= 69) 326 - rtc_tm->tm_year += 100; 327 - 328 - rtc_tm->tm_mon--; 329 - }