aboutsummaryrefslogtreecommitdiffstats
path: root/toolchain/uClibc/patches-0.9.31/450-powerpc_copysignl.patch
blob: ad8d6824bb3ae50f68625c1153c546c94d8af45f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
--- a/libc/sysdeps/linux/powerpc/Makefile.arch
+++ b/libc/sysdeps/linux/powerpc/Makefile.arch
@@ -5,7 +5,7 @@
 # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
 #
 
-CSRC := __syscall_error.c pread_write.c ioctl.c
+CSRC := __syscall_error.c pread_write.c ioctl.c copysignl.c
 
 ifeq ($(UCLIBC_HAS_ADVANCED_REALTIME),y)
 CSRC += posix_fadvise.c posix_fadvise64.c
--- /dev/null
+++ b/libc/sysdeps/linux/powerpc/copysignl.c
@@ -0,0 +1,89 @@
+/* s_copysignl.c -- long double version of s_copysign.c.
+ * Conversion to long double by Ulrich Drepper,
+ * Cygnus Support, drepper@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+/*
+ * copysignl(long double x, long double y)
+ * copysignl(x,y) returns a value with the magnitude of x and
+ * with the sign bit of y.
+ */
+
+#include <endian.h>
+#include <stdint.h>
+
+#if __FLOAT_WORD_ORDER == BIG_ENDIAN
+
+typedef union
+{
+  long double value;
+  struct
+  {
+    int sign_exponent:16;
+    unsigned int empty:16;
+    uint32_t msw;
+    uint32_t lsw;
+  } parts;
+} ieee_long_double_shape_type;
+
+#endif
+
+#if __FLOAT_WORD_ORDER == LITTLE_ENDIAN
+
+typedef union
+{
+  long double value;
+  struct
+  {
+    uint32_t lsw;
+    uint32_t msw;
+    int sign_exponent:16;
+    unsigned int empty:16;
+  } parts;
+} ieee_long_double_shape_type;
+
+#endif
+
+/* Get int from the exponent of a long double.  */
+
+#define GET_LDOUBLE_EXP(exp,d)					\
+do {								\
+  ieee_long_double_shape_type ge_u;				\
+  ge_u.value = (d);						\
+  (exp) = ge_u.parts.sign_exponent;				\
+} while (0)
+
+/* Set exponent of a long double from an int.  */
+
+#define SET_LDOUBLE_EXP(d,exp)					\
+do {								\
+  ieee_long_double_shape_type se_u;				\
+  se_u.value = (d);						\
+  se_u.parts.sign_exponent = (exp);				\
+  (d) = se_u.value;						\
+} while (0)
+
+long double copysignl(long double x, long double y);
+libc_hidden_proto(copysignl);
+
+long double copysignl(long double x, long double y)
+{
+	uint32_t es1,es2;
+	GET_LDOUBLE_EXP(es1,x);
+	GET_LDOUBLE_EXP(es2,y);
+	SET_LDOUBLE_EXP(x,(es1&0x7fff)|(es2&0x8000));
+        return x;
+}
+
+libc_hidden_def(copysignl);
span class="gi">+ * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Copyright (C) 2008 John Crispin <blogic@openwrt.org> + * Based on EP93xx and ifxmips wdt driver + */ + +#include <linux/interrupt.h> +#include <linux/module.h> +#include <linux/moduleparam.h> +#include <linux/types.h> +#include <linux/miscdevice.h> +#include <linux/watchdog.h> +#include <linux/fs.h> +#include <linux/ioport.h> +#include <linux/notifier.h> +#include <linux/reboot.h> +#include <linux/init.h> +#include <linux/platform_device.h> + +#include <asm/io.h> +#include <asm/uaccess.h> +#include <asm/system.h> +#include <asm/addrspace.h> +#include <ar231x_platform.h> +#include <ar2315_regs.h> +#include <ar231x.h> + +#define CLOCK_RATE 40000000 +#define HEARTBEAT(x) (x < 1 || x > 90)?(20):(x) + +static int wdt_timeout = 20; +static int started = 0; +static int in_use = 0; + +static void +ar2315_wdt_enable(void) +{ + ar231x_write_reg(AR2315_WD, wdt_timeout * CLOCK_RATE); + ar231x_write_reg(AR2315_ISR, 0x80); +} + +static ssize_t +ar2315_wdt_write(struct file *file, const char __user *data, size_t len, loff_t *ppos) +{ + if(len) + ar2315_wdt_enable(); + return len; +} + +static int +ar2315_wdt_open(struct inode *inode, struct file *file) +{ + if(in_use) + return -EBUSY; + ar2315_wdt_enable(); + in_use = started = 1; + return nonseekable_open(inode, file); +} + +static int +ar2315_wdt_release(struct inode *inode, struct file *file) +{ + in_use = 0; + return 0; +} + +static irqreturn_t +ar2315_wdt_interrupt(int irq, void *dev_id) +{ + if(started) + { + printk(KERN_CRIT "watchdog expired, rebooting system\n"); + emergency_restart(); + } else { + ar231x_write_reg(AR2315_WDC, 0); + ar231x_write_reg(AR2315_WD, 0); + ar231x_write_reg(AR2315_ISR, 0x80); + } + return IRQ_HANDLED; +} + +static struct watchdog_info ident = { + .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING, + .identity = "ar2315 Watchdog", +}; + +static int +ar2315_wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) +{ + int new_wdt_timeout; + int ret = -ENOIOCTLCMD; + + switch(cmd) + { + case WDIOC_GETSUPPORT: + ret = copy_to_user((struct watchdog_info __user *)arg, &ident, sizeof(ident)) ? -EFAULT : 0; + break; + + case WDIOC_KEEPALIVE: + ar2315_wdt_enable(); + ret = 0; + break; + + case WDIOC_SETTIMEOUT: + if((ret = get_user(new_wdt_timeout, (int __user *)arg))) + break; + wdt_timeout = HEARTBEAT(new_wdt_timeout); + ar2315_wdt_enable(); + break; + + case WDIOC_GETTIMEOUT: + ret = put_user(wdt_timeout, (int __user *)arg); + break; + } + return ret; +} + +static struct file_operations ar2315_wdt_fops = { + .owner = THIS_MODULE, + .llseek = no_llseek, + .write = ar2315_wdt_write, + .ioctl = ar2315_wdt_ioctl, + .open = ar2315_wdt_open, + .release = ar2315_wdt_release, +}; + +static struct miscdevice ar2315_wdt_miscdev = { + .minor = WATCHDOG_MINOR, + .name = "watchdog", + .fops = &ar2315_wdt_fops, +}; + +static int +ar2315_wdt_probe(struct platform_device *dev) +{ + int ret = 0; + + ar2315_wdt_enable(); + ret = request_irq(AR531X_MISC_IRQ_WATCHDOG, ar2315_wdt_interrupt, IRQF_DISABLED, "ar2315_wdt", NULL); + if(ret) + { + printk(KERN_ERR "ar2315wdt: failed to register inetrrupt\n"); + goto out; + } + + ret = misc_register(&ar2315_wdt_miscdev); + if(ret) + printk(KERN_ERR "ar2315wdt: failed to register miscdev\n"); + +out: + return ret; +} + +static int +ar2315_wdt_remove(struct platform_device *dev) +{ + misc_deregister(&ar2315_wdt_miscdev); + free_irq(AR531X_MISC_IRQ_WATCHDOG, NULL); + return 0; +} + +static struct platform_driver ar2315_wdt_driver = { + .probe = ar2315_wdt_probe, + .remove = ar2315_wdt_remove, + .driver = { + .name = "ar2315_wdt", + .owner = THIS_MODULE, + }, +}; + +static int __init +init_ar2315_wdt(void) +{ + int ret = platform_driver_register(&ar2315_wdt_driver); + if(ret) + printk(KERN_INFO "ar2315_wdt: error registering platfom driver!"); + return ret; +} + +static void __exit +exit_ar2315_wdt(void) +{ + platform_driver_unregister(&ar2315_wdt_driver); +} + +module_init(init_ar2315_wdt); +module_exit(exit_ar2315_wdt); --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -747,6 +747,12 @@ config TXX9_WDT help Hardware driver for the built-in watchdog timer on TXx9 MIPS SoCs. +config ATHEROS_WDT + tristate "Atheros wisoc Watchdog Timer" + depends on ATHEROS + help + Hardware driver for the Atheros wisoc Watchdog Timer. + # PARISC Architecture # POWERPC Architecture --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile @@ -106,6 +106,7 @@ obj-$(CONFIG_WDT_RM9K_GPI) += rm9k_wdt.o obj-$(CONFIG_SIBYTE_WDOG) += sb_wdog.o obj-$(CONFIG_AR7_WDT) += ar7_wdt.o obj-$(CONFIG_TXX9_WDT) += txx9wdt.o +obj-$(CONFIG_ATHEROS_WDT) += ar2315-wtd.o # PARISC Architecture