diff options
Diffstat (limited to 'arch/cris/arch-v10')
-rw-r--r-- | arch/cris/arch-v10/drivers/Kconfig | 2 | ||||
-rw-r--r-- | arch/cris/arch-v10/drivers/eeprom.c | 2 | ||||
-rw-r--r-- | arch/cris/arch-v10/drivers/gpio.c | 82 | ||||
-rw-r--r-- | arch/cris/arch-v10/drivers/i2c.c | 39 | ||||
-rw-r--r-- | arch/cris/arch-v10/drivers/i2c.h | 3 | ||||
-rw-r--r-- | arch/cris/arch-v10/drivers/sync_serial.c | 30 | ||||
-rw-r--r-- | arch/cris/arch-v10/kernel/fasttimer.c | 6 | ||||
-rw-r--r-- | arch/cris/arch-v10/kernel/head.S | 2 | ||||
-rw-r--r-- | arch/cris/arch-v10/kernel/time.c | 54 |
9 files changed, 98 insertions, 122 deletions
diff --git a/arch/cris/arch-v10/drivers/Kconfig b/arch/cris/arch-v10/drivers/Kconfig index 58f5864a6680..0d7221779923 100644 --- a/arch/cris/arch-v10/drivers/Kconfig +++ b/arch/cris/arch-v10/drivers/Kconfig | |||
@@ -383,7 +383,7 @@ config ETRAX_RS485 | |||
383 | depends on ETRAX_SERIAL | 383 | depends on ETRAX_SERIAL |
384 | help | 384 | help |
385 | Enables support for RS-485 serial communication. For a primer on | 385 | Enables support for RS-485 serial communication. For a primer on |
386 | RS-485, see <http://www.hw.cz/english/docs/rs485/rs485.html>. | 386 | RS-485, see <http://en.wikipedia.org/wiki/Rs485> |
387 | 387 | ||
388 | config ETRAX_RS485_ON_PA | 388 | config ETRAX_RS485_ON_PA |
389 | bool "RS-485 mode on PA" | 389 | bool "RS-485 mode on PA" |
diff --git a/arch/cris/arch-v10/drivers/eeprom.c b/arch/cris/arch-v10/drivers/eeprom.c index c3405507a3d1..5047a33043bd 100644 --- a/arch/cris/arch-v10/drivers/eeprom.c +++ b/arch/cris/arch-v10/drivers/eeprom.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #include <linux/init.h> | 28 | #include <linux/init.h> |
29 | #include <linux/delay.h> | 29 | #include <linux/delay.h> |
30 | #include <linux/interrupt.h> | 30 | #include <linux/interrupt.h> |
31 | #include <linux/smp_lock.h> | ||
32 | #include <linux/wait.h> | 31 | #include <linux/wait.h> |
33 | #include <asm/uaccess.h> | 32 | #include <asm/uaccess.h> |
34 | #include "i2c.h" | 33 | #include "i2c.h" |
@@ -376,7 +375,6 @@ int __init eeprom_init(void) | |||
376 | /* Opens the device. */ | 375 | /* Opens the device. */ |
377 | static int eeprom_open(struct inode * inode, struct file * file) | 376 | static int eeprom_open(struct inode * inode, struct file * file) |
378 | { | 377 | { |
379 | cycle_kernel_lock(); | ||
380 | if(iminor(inode) != EEPROM_MINOR_NR) | 378 | if(iminor(inode) != EEPROM_MINOR_NR) |
381 | return -ENXIO; | 379 | return -ENXIO; |
382 | if(imajor(inode) != EEPROM_MAJOR_NR) | 380 | if(imajor(inode) != EEPROM_MAJOR_NR) |
diff --git a/arch/cris/arch-v10/drivers/gpio.c b/arch/cris/arch-v10/drivers/gpio.c index 4b0f65fac8e8..a07b6d25b0c7 100644 --- a/arch/cris/arch-v10/drivers/gpio.c +++ b/arch/cris/arch-v10/drivers/gpio.c | |||
@@ -16,7 +16,6 @@ | |||
16 | #include <linux/errno.h> | 16 | #include <linux/errno.h> |
17 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
18 | #include <linux/fs.h> | 18 | #include <linux/fs.h> |
19 | #include <linux/smp_lock.h> | ||
20 | #include <linux/string.h> | 19 | #include <linux/string.h> |
21 | #include <linux/poll.h> | 20 | #include <linux/poll.h> |
22 | #include <linux/init.h> | 21 | #include <linux/init.h> |
@@ -46,8 +45,7 @@ static char gpio_name[] = "etrax gpio"; | |||
46 | static wait_queue_head_t *gpio_wq; | 45 | static wait_queue_head_t *gpio_wq; |
47 | #endif | 46 | #endif |
48 | 47 | ||
49 | static int gpio_ioctl(struct inode *inode, struct file *file, | 48 | static long gpio_ioctl(struct file *file, unsigned int cmd, unsigned long arg); |
50 | unsigned int cmd, unsigned long arg); | ||
51 | static ssize_t gpio_write(struct file *file, const char __user *buf, | 49 | static ssize_t gpio_write(struct file *file, const char __user *buf, |
52 | size_t count, loff_t *off); | 50 | size_t count, loff_t *off); |
53 | static int gpio_open(struct inode *inode, struct file *filp); | 51 | static int gpio_open(struct inode *inode, struct file *filp); |
@@ -324,7 +322,6 @@ gpio_open(struct inode *inode, struct file *filp) | |||
324 | if (!priv) | 322 | if (!priv) |
325 | return -ENOMEM; | 323 | return -ENOMEM; |
326 | 324 | ||
327 | lock_kernel(); | ||
328 | priv->minor = p; | 325 | priv->minor = p; |
329 | 326 | ||
330 | /* initialize the io/alarm struct */ | 327 | /* initialize the io/alarm struct */ |
@@ -359,7 +356,6 @@ gpio_open(struct inode *inode, struct file *filp) | |||
359 | alarmlist = priv; | 356 | alarmlist = priv; |
360 | spin_unlock_irqrestore(&gpio_lock, flags); | 357 | spin_unlock_irqrestore(&gpio_lock, flags); |
361 | 358 | ||
362 | unlock_kernel(); | ||
363 | return 0; | 359 | return 0; |
364 | } | 360 | } |
365 | 361 | ||
@@ -504,9 +500,7 @@ unsigned long inline setget_output(struct gpio_private *priv, unsigned long arg) | |||
504 | static int | 500 | static int |
505 | gpio_leds_ioctl(unsigned int cmd, unsigned long arg); | 501 | gpio_leds_ioctl(unsigned int cmd, unsigned long arg); |
506 | 502 | ||
507 | static int | 503 | static long gpio_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
508 | gpio_ioctl(struct inode *inode, struct file *file, | ||
509 | unsigned int cmd, unsigned long arg) | ||
510 | { | 504 | { |
511 | unsigned long flags; | 505 | unsigned long flags; |
512 | unsigned long val; | 506 | unsigned long val; |
@@ -516,54 +510,65 @@ gpio_ioctl(struct inode *inode, struct file *file, | |||
516 | if (_IOC_TYPE(cmd) != ETRAXGPIO_IOCTYPE) | 510 | if (_IOC_TYPE(cmd) != ETRAXGPIO_IOCTYPE) |
517 | return -EINVAL; | 511 | return -EINVAL; |
518 | 512 | ||
519 | spin_lock_irqsave(&gpio_lock, flags); | ||
520 | |||
521 | switch (_IOC_NR(cmd)) { | 513 | switch (_IOC_NR(cmd)) { |
522 | case IO_READBITS: /* Use IO_READ_INBITS and IO_READ_OUTBITS instead */ | 514 | case IO_READBITS: /* Use IO_READ_INBITS and IO_READ_OUTBITS instead */ |
523 | // read the port | 515 | // read the port |
516 | spin_lock_irqsave(&gpio_lock, flags); | ||
524 | if (USE_PORTS(priv)) { | 517 | if (USE_PORTS(priv)) { |
525 | ret = *priv->port; | 518 | ret = *priv->port; |
526 | } else if (priv->minor == GPIO_MINOR_G) { | 519 | } else if (priv->minor == GPIO_MINOR_G) { |
527 | ret = (*R_PORT_G_DATA) & 0x7FFFFFFF; | 520 | ret = (*R_PORT_G_DATA) & 0x7FFFFFFF; |
528 | } | 521 | } |
522 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
523 | |||
529 | break; | 524 | break; |
530 | case IO_SETBITS: | 525 | case IO_SETBITS: |
531 | // set changeable bits with a 1 in arg | 526 | // set changeable bits with a 1 in arg |
527 | spin_lock_irqsave(&gpio_lock, flags); | ||
528 | |||
532 | if (USE_PORTS(priv)) { | 529 | if (USE_PORTS(priv)) { |
533 | *priv->port = *priv->shadow |= | 530 | *priv->port = *priv->shadow |= |
534 | ((unsigned char)arg & priv->changeable_bits); | 531 | ((unsigned char)arg & priv->changeable_bits); |
535 | } else if (priv->minor == GPIO_MINOR_G) { | 532 | } else if (priv->minor == GPIO_MINOR_G) { |
536 | *R_PORT_G_DATA = port_g_data_shadow |= (arg & dir_g_out_bits); | 533 | *R_PORT_G_DATA = port_g_data_shadow |= (arg & dir_g_out_bits); |
537 | } | 534 | } |
535 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
536 | |||
538 | break; | 537 | break; |
539 | case IO_CLRBITS: | 538 | case IO_CLRBITS: |
540 | // clear changeable bits with a 1 in arg | 539 | // clear changeable bits with a 1 in arg |
540 | spin_lock_irqsave(&gpio_lock, flags); | ||
541 | if (USE_PORTS(priv)) { | 541 | if (USE_PORTS(priv)) { |
542 | *priv->port = *priv->shadow &= | 542 | *priv->port = *priv->shadow &= |
543 | ~((unsigned char)arg & priv->changeable_bits); | 543 | ~((unsigned char)arg & priv->changeable_bits); |
544 | } else if (priv->minor == GPIO_MINOR_G) { | 544 | } else if (priv->minor == GPIO_MINOR_G) { |
545 | *R_PORT_G_DATA = port_g_data_shadow &= ~((unsigned long)arg & dir_g_out_bits); | 545 | *R_PORT_G_DATA = port_g_data_shadow &= ~((unsigned long)arg & dir_g_out_bits); |
546 | } | 546 | } |
547 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
547 | break; | 548 | break; |
548 | case IO_HIGHALARM: | 549 | case IO_HIGHALARM: |
549 | // set alarm when bits with 1 in arg go high | 550 | // set alarm when bits with 1 in arg go high |
551 | spin_lock_irqsave(&gpio_lock, flags); | ||
550 | priv->highalarm |= arg; | 552 | priv->highalarm |= arg; |
551 | gpio_some_alarms = 1; | 553 | gpio_some_alarms = 1; |
554 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
552 | break; | 555 | break; |
553 | case IO_LOWALARM: | 556 | case IO_LOWALARM: |
554 | // set alarm when bits with 1 in arg go low | 557 | // set alarm when bits with 1 in arg go low |
558 | spin_lock_irqsave(&gpio_lock, flags); | ||
555 | priv->lowalarm |= arg; | 559 | priv->lowalarm |= arg; |
556 | gpio_some_alarms = 1; | 560 | gpio_some_alarms = 1; |
561 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
557 | break; | 562 | break; |
558 | case IO_CLRALARM: | 563 | case IO_CLRALARM: |
559 | // clear alarm for bits with 1 in arg | 564 | /* clear alarm for bits with 1 in arg */ |
565 | spin_lock_irqsave(&gpio_lock, flags); | ||
560 | priv->highalarm &= ~arg; | 566 | priv->highalarm &= ~arg; |
561 | priv->lowalarm &= ~arg; | 567 | priv->lowalarm &= ~arg; |
562 | { | 568 | { |
563 | /* Must update gpio_some_alarms */ | 569 | /* Must update gpio_some_alarms */ |
564 | struct gpio_private *p = alarmlist; | 570 | struct gpio_private *p = alarmlist; |
565 | int some_alarms; | 571 | int some_alarms; |
566 | spin_lock_irq(&gpio_lock); | ||
567 | p = alarmlist; | 572 | p = alarmlist; |
568 | some_alarms = 0; | 573 | some_alarms = 0; |
569 | while (p) { | 574 | while (p) { |
@@ -574,11 +579,12 @@ gpio_ioctl(struct inode *inode, struct file *file, | |||
574 | p = p->next; | 579 | p = p->next; |
575 | } | 580 | } |
576 | gpio_some_alarms = some_alarms; | 581 | gpio_some_alarms = some_alarms; |
577 | spin_unlock_irq(&gpio_lock); | ||
578 | } | 582 | } |
583 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
579 | break; | 584 | break; |
580 | case IO_READDIR: /* Use IO_SETGET_INPUT/OUTPUT instead! */ | 585 | case IO_READDIR: /* Use IO_SETGET_INPUT/OUTPUT instead! */ |
581 | /* Read direction 0=input 1=output */ | 586 | /* Read direction 0=input 1=output */ |
587 | spin_lock_irqsave(&gpio_lock, flags); | ||
582 | if (USE_PORTS(priv)) { | 588 | if (USE_PORTS(priv)) { |
583 | ret = *priv->dir_shadow; | 589 | ret = *priv->dir_shadow; |
584 | } else if (priv->minor == GPIO_MINOR_G) { | 590 | } else if (priv->minor == GPIO_MINOR_G) { |
@@ -587,30 +593,40 @@ gpio_ioctl(struct inode *inode, struct file *file, | |||
587 | */ | 593 | */ |
588 | ret = (dir_g_shadow | dir_g_out_bits) & 0x7FFFFFFF; | 594 | ret = (dir_g_shadow | dir_g_out_bits) & 0x7FFFFFFF; |
589 | } | 595 | } |
596 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
590 | break; | 597 | break; |
591 | case IO_SETINPUT: /* Use IO_SETGET_INPUT instead! */ | 598 | case IO_SETINPUT: /* Use IO_SETGET_INPUT instead! */ |
592 | /* Set direction 0=unchanged 1=input, | 599 | /* Set direction 0=unchanged 1=input, |
593 | * return mask with 1=input | 600 | * return mask with 1=input |
594 | */ | 601 | */ |
602 | spin_lock_irqsave(&gpio_lock, flags); | ||
595 | ret = setget_input(priv, arg) & 0x7FFFFFFF; | 603 | ret = setget_input(priv, arg) & 0x7FFFFFFF; |
604 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
596 | break; | 605 | break; |
597 | case IO_SETOUTPUT: /* Use IO_SETGET_OUTPUT instead! */ | 606 | case IO_SETOUTPUT: /* Use IO_SETGET_OUTPUT instead! */ |
598 | /* Set direction 0=unchanged 1=output, | 607 | /* Set direction 0=unchanged 1=output, |
599 | * return mask with 1=output | 608 | * return mask with 1=output |
600 | */ | 609 | */ |
610 | spin_lock_irqsave(&gpio_lock, flags); | ||
601 | ret = setget_output(priv, arg) & 0x7FFFFFFF; | 611 | ret = setget_output(priv, arg) & 0x7FFFFFFF; |
612 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
602 | break; | 613 | break; |
603 | case IO_SHUTDOWN: | 614 | case IO_SHUTDOWN: |
615 | spin_lock_irqsave(&gpio_lock, flags); | ||
604 | SOFT_SHUTDOWN(); | 616 | SOFT_SHUTDOWN(); |
617 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
605 | break; | 618 | break; |
606 | case IO_GET_PWR_BT: | 619 | case IO_GET_PWR_BT: |
620 | spin_lock_irqsave(&gpio_lock, flags); | ||
607 | #if defined (CONFIG_ETRAX_SOFT_SHUTDOWN) | 621 | #if defined (CONFIG_ETRAX_SOFT_SHUTDOWN) |
608 | ret = (*R_PORT_G_DATA & ( 1 << CONFIG_ETRAX_POWERBUTTON_BIT)); | 622 | ret = (*R_PORT_G_DATA & ( 1 << CONFIG_ETRAX_POWERBUTTON_BIT)); |
609 | #else | 623 | #else |
610 | ret = 0; | 624 | ret = 0; |
611 | #endif | 625 | #endif |
626 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
612 | break; | 627 | break; |
613 | case IO_CFG_WRITE_MODE: | 628 | case IO_CFG_WRITE_MODE: |
629 | spin_lock_irqsave(&gpio_lock, flags); | ||
614 | priv->clk_mask = arg & 0xFF; | 630 | priv->clk_mask = arg & 0xFF; |
615 | priv->data_mask = (arg >> 8) & 0xFF; | 631 | priv->data_mask = (arg >> 8) & 0xFF; |
616 | priv->write_msb = (arg >> 16) & 0x01; | 632 | priv->write_msb = (arg >> 16) & 0x01; |
@@ -626,28 +642,33 @@ gpio_ioctl(struct inode *inode, struct file *file, | |||
626 | priv->data_mask = 0; | 642 | priv->data_mask = 0; |
627 | ret = -EPERM; | 643 | ret = -EPERM; |
628 | } | 644 | } |
645 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
629 | break; | 646 | break; |
630 | case IO_READ_INBITS: | 647 | case IO_READ_INBITS: |
631 | /* *arg is result of reading the input pins */ | 648 | /* *arg is result of reading the input pins */ |
649 | spin_lock_irqsave(&gpio_lock, flags); | ||
632 | if (USE_PORTS(priv)) { | 650 | if (USE_PORTS(priv)) { |
633 | val = *priv->port; | 651 | val = *priv->port; |
634 | } else if (priv->minor == GPIO_MINOR_G) { | 652 | } else if (priv->minor == GPIO_MINOR_G) { |
635 | val = *R_PORT_G_DATA; | 653 | val = *R_PORT_G_DATA; |
636 | } | 654 | } |
655 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
637 | if (copy_to_user((void __user *)arg, &val, sizeof(val))) | 656 | if (copy_to_user((void __user *)arg, &val, sizeof(val))) |
638 | ret = -EFAULT; | 657 | ret = -EFAULT; |
639 | break; | 658 | break; |
640 | case IO_READ_OUTBITS: | 659 | case IO_READ_OUTBITS: |
641 | /* *arg is result of reading the output shadow */ | 660 | /* *arg is result of reading the output shadow */ |
661 | spin_lock_irqsave(&gpio_lock, flags); | ||
642 | if (USE_PORTS(priv)) { | 662 | if (USE_PORTS(priv)) { |
643 | val = *priv->shadow; | 663 | val = *priv->shadow; |
644 | } else if (priv->minor == GPIO_MINOR_G) { | 664 | } else if (priv->minor == GPIO_MINOR_G) { |
645 | val = port_g_data_shadow; | 665 | val = port_g_data_shadow; |
646 | } | 666 | } |
667 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
647 | if (copy_to_user((void __user *)arg, &val, sizeof(val))) | 668 | if (copy_to_user((void __user *)arg, &val, sizeof(val))) |
648 | ret = -EFAULT; | 669 | ret = -EFAULT; |
649 | break; | 670 | break; |
650 | case IO_SETGET_INPUT: | 671 | case IO_SETGET_INPUT: |
651 | /* bits set in *arg is set to input, | 672 | /* bits set in *arg is set to input, |
652 | * *arg updated with current input pins. | 673 | * *arg updated with current input pins. |
653 | */ | 674 | */ |
@@ -656,7 +677,9 @@ gpio_ioctl(struct inode *inode, struct file *file, | |||
656 | ret = -EFAULT; | 677 | ret = -EFAULT; |
657 | break; | 678 | break; |
658 | } | 679 | } |
680 | spin_lock_irqsave(&gpio_lock, flags); | ||
659 | val = setget_input(priv, val); | 681 | val = setget_input(priv, val); |
682 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
660 | if (copy_to_user((void __user *)arg, &val, sizeof(val))) | 683 | if (copy_to_user((void __user *)arg, &val, sizeof(val))) |
661 | ret = -EFAULT; | 684 | ret = -EFAULT; |
662 | break; | 685 | break; |
@@ -668,18 +691,21 @@ gpio_ioctl(struct inode *inode, struct file *file, | |||
668 | ret = -EFAULT; | 691 | ret = -EFAULT; |
669 | break; | 692 | break; |
670 | } | 693 | } |
694 | spin_lock_irqsave(&gpio_lock, flags); | ||
671 | val = setget_output(priv, val); | 695 | val = setget_output(priv, val); |
696 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
672 | if (copy_to_user((void __user *)arg, &val, sizeof(val))) | 697 | if (copy_to_user((void __user *)arg, &val, sizeof(val))) |
673 | ret = -EFAULT; | 698 | ret = -EFAULT; |
674 | break; | 699 | break; |
675 | default: | 700 | default: |
701 | spin_lock_irqsave(&gpio_lock, flags); | ||
676 | if (priv->minor == GPIO_MINOR_LEDS) | 702 | if (priv->minor == GPIO_MINOR_LEDS) |
677 | ret = gpio_leds_ioctl(cmd, arg); | 703 | ret = gpio_leds_ioctl(cmd, arg); |
678 | else | 704 | else |
679 | ret = -EINVAL; | 705 | ret = -EINVAL; |
706 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
680 | } /* switch */ | 707 | } /* switch */ |
681 | 708 | ||
682 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
683 | return ret; | 709 | return ret; |
684 | } | 710 | } |
685 | 711 | ||
@@ -713,12 +739,12 @@ gpio_leds_ioctl(unsigned int cmd, unsigned long arg) | |||
713 | } | 739 | } |
714 | 740 | ||
715 | static const struct file_operations gpio_fops = { | 741 | static const struct file_operations gpio_fops = { |
716 | .owner = THIS_MODULE, | 742 | .owner = THIS_MODULE, |
717 | .poll = gpio_poll, | 743 | .poll = gpio_poll, |
718 | .ioctl = gpio_ioctl, | 744 | .unlocked_ioctl = gpio_ioctl, |
719 | .write = gpio_write, | 745 | .write = gpio_write, |
720 | .open = gpio_open, | 746 | .open = gpio_open, |
721 | .release = gpio_release, | 747 | .release = gpio_release, |
722 | }; | 748 | }; |
723 | 749 | ||
724 | static void ioif_watcher(const unsigned int gpio_in_available, | 750 | static void ioif_watcher(const unsigned int gpio_in_available, |
diff --git a/arch/cris/arch-v10/drivers/i2c.c b/arch/cris/arch-v10/drivers/i2c.c index a8737a8eb229..77a941813819 100644 --- a/arch/cris/arch-v10/drivers/i2c.c +++ b/arch/cris/arch-v10/drivers/i2c.c | |||
@@ -14,7 +14,6 @@ | |||
14 | 14 | ||
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/sched.h> | 16 | #include <linux/sched.h> |
17 | #include <linux/smp_lock.h> | ||
18 | #include <linux/errno.h> | 17 | #include <linux/errno.h> |
19 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
20 | #include <linux/fs.h> | 19 | #include <linux/fs.h> |
@@ -60,8 +59,8 @@ static const char i2c_name[] = "i2c"; | |||
60 | 59 | ||
61 | #define SDABIT CONFIG_ETRAX_I2C_DATA_PORT | 60 | #define SDABIT CONFIG_ETRAX_I2C_DATA_PORT |
62 | #define SCLBIT CONFIG_ETRAX_I2C_CLK_PORT | 61 | #define SCLBIT CONFIG_ETRAX_I2C_CLK_PORT |
63 | #define i2c_enable() | 62 | #define i2c_enable() |
64 | #define i2c_disable() | 63 | #define i2c_disable() |
65 | 64 | ||
66 | /* enable or disable output-enable, to select output or input on the i2c bus */ | 65 | /* enable or disable output-enable, to select output or input on the i2c bus */ |
67 | 66 | ||
@@ -91,7 +90,7 @@ static const char i2c_name[] = "i2c"; | |||
91 | 90 | ||
92 | #define i2c_dir_out() \ | 91 | #define i2c_dir_out() \ |
93 | *R_PORT_PB_I2C = (port_pb_i2c_shadow &= ~IO_MASK(R_PORT_PB_I2C, i2c_oe_)); \ | 92 | *R_PORT_PB_I2C = (port_pb_i2c_shadow &= ~IO_MASK(R_PORT_PB_I2C, i2c_oe_)); \ |
94 | REG_SHADOW_SET(R_PORT_PB_DIR, port_pb_dir_shadow, 0, 1); | 93 | REG_SHADOW_SET(R_PORT_PB_DIR, port_pb_dir_shadow, 0, 1); |
95 | #define i2c_dir_in() \ | 94 | #define i2c_dir_in() \ |
96 | *R_PORT_PB_I2C = (port_pb_i2c_shadow |= IO_MASK(R_PORT_PB_I2C, i2c_oe_)); \ | 95 | *R_PORT_PB_I2C = (port_pb_i2c_shadow |= IO_MASK(R_PORT_PB_I2C, i2c_oe_)); \ |
97 | REG_SHADOW_SET(R_PORT_PB_DIR, port_pb_dir_shadow, 0, 0); | 96 | REG_SHADOW_SET(R_PORT_PB_DIR, port_pb_dir_shadow, 0, 0); |
@@ -189,7 +188,7 @@ i2c_outbyte(unsigned char x) | |||
189 | } else { | 188 | } else { |
190 | i2c_data(I2C_DATA_LOW); | 189 | i2c_data(I2C_DATA_LOW); |
191 | } | 190 | } |
192 | 191 | ||
193 | i2c_delay(CLOCK_LOW_TIME/2); | 192 | i2c_delay(CLOCK_LOW_TIME/2); |
194 | i2c_clk(I2C_CLOCK_HIGH); | 193 | i2c_clk(I2C_CLOCK_HIGH); |
195 | i2c_delay(CLOCK_HIGH_TIME); | 194 | i2c_delay(CLOCK_HIGH_TIME); |
@@ -416,7 +415,7 @@ i2c_sendnack(void) | |||
416 | *# | 415 | *# |
417 | *#--------------------------------------------------------------------------*/ | 416 | *#--------------------------------------------------------------------------*/ |
418 | int | 417 | int |
419 | i2c_writereg(unsigned char theSlave, unsigned char theReg, | 418 | i2c_writereg(unsigned char theSlave, unsigned char theReg, |
420 | unsigned char theValue) | 419 | unsigned char theValue) |
421 | { | 420 | { |
422 | int error, cntr = 3; | 421 | int error, cntr = 3; |
@@ -468,7 +467,7 @@ i2c_writereg(unsigned char theSlave, unsigned char theReg, | |||
468 | * enable interrupt again | 467 | * enable interrupt again |
469 | */ | 468 | */ |
470 | local_irq_restore(flags); | 469 | local_irq_restore(flags); |
471 | 470 | ||
472 | } while(error && cntr--); | 471 | } while(error && cntr--); |
473 | 472 | ||
474 | i2c_delay(CLOCK_LOW_TIME); | 473 | i2c_delay(CLOCK_LOW_TIME); |
@@ -504,7 +503,7 @@ i2c_readreg(unsigned char theSlave, unsigned char theReg) | |||
504 | * generate start condition | 503 | * generate start condition |
505 | */ | 504 | */ |
506 | i2c_start(); | 505 | i2c_start(); |
507 | 506 | ||
508 | /* | 507 | /* |
509 | * send slave address | 508 | * send slave address |
510 | */ | 509 | */ |
@@ -555,7 +554,7 @@ i2c_readreg(unsigned char theSlave, unsigned char theReg) | |||
555 | * enable interrupt again | 554 | * enable interrupt again |
556 | */ | 555 | */ |
557 | local_irq_restore(flags); | 556 | local_irq_restore(flags); |
558 | 557 | ||
559 | } while(error && cntr--); | 558 | } while(error && cntr--); |
560 | 559 | ||
561 | spin_unlock(&i2c_lock); | 560 | spin_unlock(&i2c_lock); |
@@ -566,7 +565,6 @@ i2c_readreg(unsigned char theSlave, unsigned char theReg) | |||
566 | static int | 565 | static int |
567 | i2c_open(struct inode *inode, struct file *filp) | 566 | i2c_open(struct inode *inode, struct file *filp) |
568 | { | 567 | { |
569 | cycle_kernel_lock(); | ||
570 | return 0; | 568 | return 0; |
571 | } | 569 | } |
572 | 570 | ||
@@ -579,9 +577,7 @@ i2c_release(struct inode *inode, struct file *filp) | |||
579 | /* Main device API. ioctl's to write or read to/from i2c registers. | 577 | /* Main device API. ioctl's to write or read to/from i2c registers. |
580 | */ | 578 | */ |
581 | 579 | ||
582 | static int | 580 | static long i2c_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
583 | i2c_ioctl(struct inode *inode, struct file *file, | ||
584 | unsigned int cmd, unsigned long arg) | ||
585 | { | 581 | { |
586 | if(_IOC_TYPE(cmd) != ETRAXI2C_IOCTYPE) { | 582 | if(_IOC_TYPE(cmd) != ETRAXI2C_IOCTYPE) { |
587 | return -EINVAL; | 583 | return -EINVAL; |
@@ -590,7 +586,7 @@ i2c_ioctl(struct inode *inode, struct file *file, | |||
590 | switch (_IOC_NR(cmd)) { | 586 | switch (_IOC_NR(cmd)) { |
591 | case I2C_WRITEREG: | 587 | case I2C_WRITEREG: |
592 | /* write to an i2c slave */ | 588 | /* write to an i2c slave */ |
593 | D(printk("i2cw %d %d %d\n", | 589 | D(printk(KERN_DEBUG "i2cw %d %d %d\n", |
594 | I2C_ARGSLAVE(arg), | 590 | I2C_ARGSLAVE(arg), |
595 | I2C_ARGREG(arg), | 591 | I2C_ARGREG(arg), |
596 | I2C_ARGVALUE(arg))); | 592 | I2C_ARGVALUE(arg))); |
@@ -602,26 +598,25 @@ i2c_ioctl(struct inode *inode, struct file *file, | |||
602 | { | 598 | { |
603 | unsigned char val; | 599 | unsigned char val; |
604 | /* read from an i2c slave */ | 600 | /* read from an i2c slave */ |
605 | D(printk("i2cr %d %d ", | 601 | D(printk(KERN_DEBUG "i2cr %d %d ", |
606 | I2C_ARGSLAVE(arg), | 602 | I2C_ARGSLAVE(arg), |
607 | I2C_ARGREG(arg))); | 603 | I2C_ARGREG(arg))); |
608 | val = i2c_readreg(I2C_ARGSLAVE(arg), I2C_ARGREG(arg)); | 604 | val = i2c_readreg(I2C_ARGSLAVE(arg), I2C_ARGREG(arg)); |
609 | D(printk("= %d\n", val)); | 605 | D(printk(KERN_DEBUG "= %d\n", val)); |
610 | return val; | 606 | return val; |
611 | } | 607 | } |
612 | default: | 608 | default: |
613 | return -EINVAL; | 609 | return -EINVAL; |
614 | 610 | ||
615 | } | 611 | } |
616 | |||
617 | return 0; | 612 | return 0; |
618 | } | 613 | } |
619 | 614 | ||
620 | static const struct file_operations i2c_fops = { | 615 | static const struct file_operations i2c_fops = { |
621 | .owner = THIS_MODULE, | 616 | .owner = THIS_MODULE, |
622 | .ioctl = i2c_ioctl, | 617 | .unlocked_ioctl = i2c_ioctl, |
623 | .open = i2c_open, | 618 | .open = i2c_open, |
624 | .release = i2c_release, | 619 | .release = i2c_release, |
625 | }; | 620 | }; |
626 | 621 | ||
627 | int __init | 622 | int __init |
diff --git a/arch/cris/arch-v10/drivers/i2c.h b/arch/cris/arch-v10/drivers/i2c.h index 4ee91426bd40..e36c96276478 100644 --- a/arch/cris/arch-v10/drivers/i2c.h +++ b/arch/cris/arch-v10/drivers/i2c.h | |||
@@ -1,5 +1,4 @@ | |||
1 | /* $Id: i2c.h,v 1.3 2004/05/28 09:26:59 starvik Exp $ */ | 1 | /* i2c.h */ |
2 | |||
3 | int i2c_init(void); | 2 | int i2c_init(void); |
4 | 3 | ||
5 | /* High level I2C actions */ | 4 | /* High level I2C actions */ |
diff --git a/arch/cris/arch-v10/drivers/sync_serial.c b/arch/cris/arch-v10/drivers/sync_serial.c index 109dcd826d17..ee2dd4323daf 100644 --- a/arch/cris/arch-v10/drivers/sync_serial.c +++ b/arch/cris/arch-v10/drivers/sync_serial.c | |||
@@ -157,7 +157,7 @@ static int sync_serial_open(struct inode *inode, struct file *file); | |||
157 | static int sync_serial_release(struct inode *inode, struct file *file); | 157 | static int sync_serial_release(struct inode *inode, struct file *file); |
158 | static unsigned int sync_serial_poll(struct file *filp, poll_table *wait); | 158 | static unsigned int sync_serial_poll(struct file *filp, poll_table *wait); |
159 | 159 | ||
160 | static int sync_serial_ioctl(struct inode *inode, struct file *file, | 160 | static int sync_serial_ioctl(struct file *file, |
161 | unsigned int cmd, unsigned long arg); | 161 | unsigned int cmd, unsigned long arg); |
162 | static ssize_t sync_serial_write(struct file *file, const char *buf, | 162 | static ssize_t sync_serial_write(struct file *file, const char *buf, |
163 | size_t count, loff_t *ppos); | 163 | size_t count, loff_t *ppos); |
@@ -244,13 +244,13 @@ static unsigned sync_serial_prescale_shadow; | |||
244 | #define NUMBER_OF_PORTS 2 | 244 | #define NUMBER_OF_PORTS 2 |
245 | 245 | ||
246 | static const struct file_operations sync_serial_fops = { | 246 | static const struct file_operations sync_serial_fops = { |
247 | .owner = THIS_MODULE, | 247 | .owner = THIS_MODULE, |
248 | .write = sync_serial_write, | 248 | .write = sync_serial_write, |
249 | .read = sync_serial_read, | 249 | .read = sync_serial_read, |
250 | .poll = sync_serial_poll, | 250 | .poll = sync_serial_poll, |
251 | .ioctl = sync_serial_ioctl, | 251 | .unlocked_ioctl = sync_serial_ioctl, |
252 | .open = sync_serial_open, | 252 | .open = sync_serial_open, |
253 | .release = sync_serial_release | 253 | .release = sync_serial_release |
254 | }; | 254 | }; |
255 | 255 | ||
256 | static int __init etrax_sync_serial_init(void) | 256 | static int __init etrax_sync_serial_init(void) |
@@ -678,7 +678,7 @@ static unsigned int sync_serial_poll(struct file *file, poll_table *wait) | |||
678 | return mask; | 678 | return mask; |
679 | } | 679 | } |
680 | 680 | ||
681 | static int sync_serial_ioctl(struct inode *inode, struct file *file, | 681 | static int sync_serial_ioctl_unlocked(struct file *file, |
682 | unsigned int cmd, unsigned long arg) | 682 | unsigned int cmd, unsigned long arg) |
683 | { | 683 | { |
684 | int return_val = 0; | 684 | int return_val = 0; |
@@ -956,6 +956,18 @@ static int sync_serial_ioctl(struct inode *inode, struct file *file, | |||
956 | return return_val; | 956 | return return_val; |
957 | } | 957 | } |
958 | 958 | ||
959 | static long sync_serial_ioctl(struct file *file, | ||
960 | unsigned int cmd, unsigned long arg) | ||
961 | { | ||
962 | long ret; | ||
963 | |||
964 | lock_kernel(); | ||
965 | ret = sync_serial_ioctl_unlocked(file, cmd, arg); | ||
966 | unlock_kernel(); | ||
967 | |||
968 | return ret; | ||
969 | } | ||
970 | |||
959 | 971 | ||
960 | static ssize_t sync_serial_write(struct file *file, const char *buf, | 972 | static ssize_t sync_serial_write(struct file *file, const char *buf, |
961 | size_t count, loff_t *ppos) | 973 | size_t count, loff_t *ppos) |
diff --git a/arch/cris/arch-v10/kernel/fasttimer.c b/arch/cris/arch-v10/kernel/fasttimer.c index 5ff08a8695e9..8a8196ee8ce8 100644 --- a/arch/cris/arch-v10/kernel/fasttimer.c +++ b/arch/cris/arch-v10/kernel/fasttimer.c | |||
@@ -467,11 +467,7 @@ timer1_handler(int irq, void *dev_id) | |||
467 | 467 | ||
468 | static void wake_up_func(unsigned long data) | 468 | static void wake_up_func(unsigned long data) |
469 | { | 469 | { |
470 | #ifdef DECLARE_WAITQUEUE | 470 | wait_queue_head_t *sleep_wait_p = (wait_queue_head_t *)data; |
471 | wait_queue_head_t *sleep_wait_p = (wait_queue_head_t*)data; | ||
472 | #else | ||
473 | struct wait_queue **sleep_wait_p = (struct wait_queue **)data; | ||
474 | #endif | ||
475 | wake_up(sleep_wait_p); | 471 | wake_up(sleep_wait_p); |
476 | } | 472 | } |
477 | 473 | ||
diff --git a/arch/cris/arch-v10/kernel/head.S b/arch/cris/arch-v10/kernel/head.S index fc4577102933..a1f2014b4e3b 100644 --- a/arch/cris/arch-v10/kernel/head.S +++ b/arch/cris/arch-v10/kernel/head.S | |||
@@ -280,7 +280,7 @@ _no_romfs_in_flash: | |||
280 | ;; the "rom fs" we'll possibly use in 2.4 if not JFFS (which does | 280 | ;; the "rom fs" we'll possibly use in 2.4 if not JFFS (which does |
281 | ;; not need this mechanism anyway) | 281 | ;; not need this mechanism anyway) |
282 | 282 | ||
283 | move.d __vmlinux_end, $r0; the image will be after the vmlinux end address | 283 | move.d __init_end, $r0; the image will be after the end of init |
284 | move.d [$r0], $r1 ; cramfs assumes same endian on host/target | 284 | move.d [$r0], $r1 ; cramfs assumes same endian on host/target |
285 | cmp.d CRAMFS_MAGIC, $r1; magic value in cramfs superblock | 285 | cmp.d CRAMFS_MAGIC, $r1; magic value in cramfs superblock |
286 | bne 2f | 286 | bne 2f |
diff --git a/arch/cris/arch-v10/kernel/time.c b/arch/cris/arch-v10/kernel/time.c index 30adae594aef..00eb36f8debf 100644 --- a/arch/cris/arch-v10/kernel/time.c +++ b/arch/cris/arch-v10/kernel/time.c | |||
@@ -61,66 +61,16 @@ unsigned long get_ns_in_jiffie(void) | |||
61 | 61 | ||
62 | unsigned long do_slow_gettimeoffset(void) | 62 | unsigned long do_slow_gettimeoffset(void) |
63 | { | 63 | { |
64 | unsigned long count, t1; | 64 | unsigned long count; |
65 | unsigned long usec_count = 0; | ||
66 | unsigned short presc_count; | ||
67 | |||
68 | static unsigned long count_p = TIMER0_DIV;/* for the first call after boot */ | ||
69 | static unsigned long jiffies_p = 0; | ||
70 | |||
71 | /* | ||
72 | * cache volatile jiffies temporarily; we have IRQs turned off. | ||
73 | */ | ||
74 | unsigned long jiffies_t; | ||
75 | 65 | ||
76 | /* The timer interrupt comes from Etrax timer 0. In order to get | 66 | /* The timer interrupt comes from Etrax timer 0. In order to get |
77 | * better precision, we check the current value. It might have | 67 | * better precision, we check the current value. It might have |
78 | * underflowed already though. | 68 | * underflowed already though. |
79 | */ | 69 | */ |
80 | |||
81 | #ifndef CONFIG_SVINTO_SIM | ||
82 | /* Not available in the xsim simulator. */ | ||
83 | count = *R_TIMER0_DATA; | 70 | count = *R_TIMER0_DATA; |
84 | presc_count = *R_TIM_PRESC_STATUS; | ||
85 | /* presc_count might be wrapped */ | ||
86 | t1 = *R_TIMER0_DATA; | ||
87 | if (count != t1){ | ||
88 | /* it wrapped, read prescaler again... */ | ||
89 | presc_count = *R_TIM_PRESC_STATUS; | ||
90 | count = t1; | ||
91 | } | ||
92 | #else | ||
93 | count = 0; | ||
94 | presc_count = 0; | ||
95 | #endif | ||
96 | |||
97 | jiffies_t = jiffies; | ||
98 | 71 | ||
99 | /* | ||
100 | * avoiding timer inconsistencies (they are rare, but they happen)... | ||
101 | * there are one problem that must be avoided here: | ||
102 | * 1. the timer counter underflows | ||
103 | */ | ||
104 | if( jiffies_t == jiffies_p ) { | ||
105 | if( count > count_p ) { | ||
106 | /* Timer wrapped, use new count and prescale | ||
107 | * increase the time corresponding to one jiffie | ||
108 | */ | ||
109 | usec_count = 1000000/HZ; | ||
110 | } | ||
111 | } else | ||
112 | jiffies_p = jiffies_t; | ||
113 | count_p = count; | ||
114 | if (presc_count >= PRESCALE_VALUE/2 ){ | ||
115 | presc_count = PRESCALE_VALUE - presc_count + PRESCALE_VALUE/2; | ||
116 | } else { | ||
117 | presc_count = PRESCALE_VALUE - presc_count - PRESCALE_VALUE/2; | ||
118 | } | ||
119 | /* Convert timer value to usec */ | 72 | /* Convert timer value to usec */ |
120 | usec_count += ( (TIMER0_DIV - count) * (1000000/HZ)/TIMER0_DIV ) + | 73 | return (TIMER0_DIV - count) * ((NSEC_PER_SEC/1000)/HZ)/TIMER0_DIV; |
121 | (( (presc_count) * (1000000000/PRESCALE_FREQ))/1000); | ||
122 | |||
123 | return usec_count; | ||
124 | } | 74 | } |
125 | 75 | ||
126 | /* Excerpt from the Etrax100 HSDD about the built-in watchdog: | 76 | /* Excerpt from the Etrax100 HSDD about the built-in watchdog: |