mirror of
git://projects.qi-hardware.com/openwrt-xburst.git
synced 2024-12-26 01:33:20 +02:00
cleanup danube watchdog timer
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@9728 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
5bd4ae6802
commit
bb4717095c
@ -50,40 +50,12 @@ danube_wdt_enable (unsigned int timeout)
|
|||||||
{
|
{
|
||||||
unsigned int wdt_cr = 0;
|
unsigned int wdt_cr = 0;
|
||||||
unsigned int wdt_reload = 0;
|
unsigned int wdt_reload = 0;
|
||||||
unsigned int wdt_clkdiv, clkdiv, wdt_pwl, pwl, ffpi;
|
unsigned int wdt_clkdiv, wdt_pwl, ffpi;
|
||||||
|
int retval = 0;
|
||||||
|
|
||||||
/* clock divider & prewarning limit */
|
/* clock divider & prewarning limit */
|
||||||
switch (clkdiv = DANUBE_BIU_WDT_CR_CLKDIV_GET(readl(DANUBE_BIU_WDT_CR)))
|
wdt_clkdiv = 1 << (7 * DANUBE_BIU_WDT_CR_CLKDIV_GET(readl(DANUBE_BIU_WDT_CR)));
|
||||||
{
|
wdt_pwl = 0x8000 >> DANUBE_BIU_WDT_CR_PWL_GET(readl(DANUBE_BIU_WDT_CR));
|
||||||
case 0:
|
|
||||||
wdt_clkdiv = 1;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
wdt_clkdiv = 64;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
wdt_clkdiv = 4096;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
wdt_clkdiv = 262144;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (pwl = DANUBE_BIU_WDT_CR_PWL_GET (readl(DANUBE_BIU_WDT_CR)))
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
wdt_pwl = 0x8000;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
wdt_pwl = 0x4000;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
wdt_pwl = 0x2000;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
wdt_pwl = 0x1000;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO
|
//TODO
|
||||||
printk("WARNING FUNCTION CALL MISSING!!!");
|
printk("WARNING FUNCTION CALL MISSING!!!");
|
||||||
@ -96,30 +68,34 @@ danube_wdt_enable (unsigned int timeout)
|
|||||||
printk("wdt_pwl=0x%x, wdt_clkdiv=%d, ffpi=%d, wdt_reload = 0x%x\n",
|
printk("wdt_pwl=0x%x, wdt_clkdiv=%d, ffpi=%d, wdt_reload = 0x%x\n",
|
||||||
wdt_pwl, wdt_clkdiv, ffpi, wdt_reload);
|
wdt_pwl, wdt_clkdiv, ffpi, wdt_reload);
|
||||||
|
|
||||||
if (wdt_reload > 0xFFFF) {
|
if (wdt_reload > 0xFFFF)
|
||||||
|
{
|
||||||
printk ("timeout too large %d\n", timeout);
|
printk ("timeout too large %d\n", timeout);
|
||||||
return -EINVAL;
|
retval = -EINVAL;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write first part of password access */
|
/* Write first part of password access */
|
||||||
*DANUBE_BIU_WDT_CR = DANUBE_BIU_WDT_CR_PW_SET (DANUBE_WDT_PW1);
|
writel(DANUBE_BIU_WDT_CR_PW_SET(DANUBE_WDT_PW1), DANUBE_BIU_WDT_CR);
|
||||||
|
|
||||||
wdt_cr = *DANUBE_BIU_WDT_CR;
|
wdt_cr = readl(DANUBE_BIU_WDT_CR);
|
||||||
wdt_cr &= (!DANUBE_BIU_WDT_CR_PW_SET (0xff) &
|
wdt_cr &= (!DANUBE_BIU_WDT_CR_PW_SET(0xff) &
|
||||||
!DANUBE_BIU_WDT_CR_PWL_SET (0x3) &
|
!DANUBE_BIU_WDT_CR_PWL_SET(0x3) &
|
||||||
!DANUBE_BIU_WDT_CR_CLKDIV_SET (0x3) &
|
!DANUBE_BIU_WDT_CR_CLKDIV_SET(0x3) &
|
||||||
!DANUBE_BIU_WDT_CR_RELOAD_SET (0xffff));
|
!DANUBE_BIU_WDT_CR_RELOAD_SET(0xffff));
|
||||||
|
|
||||||
wdt_cr |= (DANUBE_BIU_WDT_CR_PW_SET (DANUBE_WDT_PW2) |
|
wdt_cr |= (DANUBE_BIU_WDT_CR_PW_SET(DANUBE_WDT_PW2) |
|
||||||
DANUBE_BIU_WDT_CR_PWL_SET (pwl) |
|
DANUBE_BIU_WDT_CR_PWL_SET(DANUBE_BIU_WDT_CR_PWL_GET(readl(DANUBE_BIU_WDT_CR))) |
|
||||||
DANUBE_BIU_WDT_CR_CLKDIV_SET (clkdiv) |
|
DANUBE_BIU_WDT_CR_CLKDIV_SET(DANUBE_BIU_WDT_CR_CLKDIV_GET(readl(DANUBE_BIU_WDT_CR))) |
|
||||||
DANUBE_BIU_WDT_CR_RELOAD_SET (wdt_reload) |
|
DANUBE_BIU_WDT_CR_RELOAD_SET(wdt_reload) |
|
||||||
DANUBE_BIU_WDT_CR_GEN);
|
DANUBE_BIU_WDT_CR_GEN);
|
||||||
|
|
||||||
/* Set reload value in second password access */
|
/* Set reload value in second password access */
|
||||||
*DANUBE_BIU_WDT_CR = wdt_cr;
|
writel(wdt_cr, DANUBE_BIU_WDT_CR);
|
||||||
printk ("enabled\n");
|
printk("watchdog enabled\n");
|
||||||
return 0;
|
|
||||||
|
out:
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -132,8 +108,9 @@ danube_wdt_disable (void)
|
|||||||
writel(DANUBE_BIU_WDT_CR_PW_SET(DANUBE_WDT_PW2), DANUBE_BIU_WDT_CR);
|
writel(DANUBE_BIU_WDT_CR_PW_SET(DANUBE_WDT_PW2), DANUBE_BIU_WDT_CR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* passed LPEN or DSEN */
|
||||||
void
|
void
|
||||||
danube_wdt_low_power (int en)
|
danube_wdt_low_power_or_debug (int en, int type)
|
||||||
{
|
{
|
||||||
unsigned int wdt_cr = 0;
|
unsigned int wdt_cr = 0;
|
||||||
|
|
||||||
@ -143,40 +120,11 @@ danube_wdt_low_power (int en)
|
|||||||
|
|
||||||
if (en)
|
if (en)
|
||||||
{
|
{
|
||||||
wdt_cr &= (!DANUBE_BIU_WDT_CR_PW_SET(0xff));
|
wdt_cr &= (~DANUBE_BIU_WDT_CR_PW_SET(0xff));
|
||||||
wdt_cr |=
|
wdt_cr |= (DANUBE_BIU_WDT_CR_PW_SET(DANUBE_WDT_PW2) | type);
|
||||||
(DANUBE_BIU_WDT_CR_PW_SET (DANUBE_WDT_PW2) |
|
} else {
|
||||||
DANUBE_BIU_WDT_CR_LPEN);
|
wdt_cr &= (~DANUBE_BIU_WDT_CR_PW_SET(0xff) & ~type);
|
||||||
}
|
wdt_cr |= DANUBE_BIU_WDT_CR_PW_SET(DANUBE_WDT_PW2);
|
||||||
else {
|
|
||||||
wdt_cr &= (!DANUBE_BIU_WDT_CR_PW_SET (0xff) &
|
|
||||||
!DANUBE_BIU_WDT_CR_LPEN);
|
|
||||||
wdt_cr |= DANUBE_BIU_WDT_CR_PW_SET (DANUBE_WDT_PW2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set reload value in second password access */
|
|
||||||
writel(wdt_cr, DANUBE_BIU_WDT_CR);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
danube_wdt_debug_suspend (int en)
|
|
||||||
{
|
|
||||||
unsigned int wdt_cr = 0;
|
|
||||||
|
|
||||||
writel(DANUBE_BIU_WDT_CR_PW_SET(DANUBE_WDT_PW1), DANUBE_BIU_WDT_CR);
|
|
||||||
|
|
||||||
wdt_cr = readl(DANUBE_BIU_WDT_CR);
|
|
||||||
if (en)
|
|
||||||
{
|
|
||||||
wdt_cr &= (!DANUBE_BIU_WDT_CR_PW_SET (0xff));
|
|
||||||
wdt_cr |=
|
|
||||||
(DANUBE_BIU_WDT_CR_PW_SET (DANUBE_WDT_PW2) |
|
|
||||||
DANUBE_BIU_WDT_CR_DSEN);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
wdt_cr &= (!DANUBE_BIU_WDT_CR_PW_SET (0xff) &
|
|
||||||
!DANUBE_BIU_WDT_CR_DSEN);
|
|
||||||
wdt_cr |= DANUBE_BIU_WDT_CR_PW_SET (DANUBE_WDT_PW2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set reload value in second password access */
|
/* Set reload value in second password access */
|
||||||
@ -191,10 +139,9 @@ danube_wdt_prewarning_limit (int pwl)
|
|||||||
wdt_cr = readl(DANUBE_BIU_WDT_CR);
|
wdt_cr = readl(DANUBE_BIU_WDT_CR);
|
||||||
writel(DANUBE_BIU_WDT_CR_PW_SET(DANUBE_WDT_PW1), DANUBE_BIU_WDT_CR);
|
writel(DANUBE_BIU_WDT_CR_PW_SET(DANUBE_WDT_PW1), DANUBE_BIU_WDT_CR);
|
||||||
|
|
||||||
wdt_cr &= 0xff00ffff; //(!DANUBE_BIU_WDT_CR_PW_SET(0xff));
|
wdt_cr &= 0xf300ffff;
|
||||||
wdt_cr &= 0xf3ffffff; //(!DANUBE_BIU_WDT_CR_PWL_SET(3));
|
wdt_cr |= (DANUBE_BIU_WDT_CR_PW_SET(DANUBE_WDT_PW2) |
|
||||||
wdt_cr |= (DANUBE_BIU_WDT_CR_PW_SET (DANUBE_WDT_PW2) |
|
DANUBE_BIU_WDT_CR_PWL_SET(pwl));
|
||||||
DANUBE_BIU_WDT_CR_PWL_SET (pwl));
|
|
||||||
|
|
||||||
/* Set reload value in second password access */
|
/* Set reload value in second password access */
|
||||||
writel(wdt_cr, DANUBE_BIU_WDT_CR);
|
writel(wdt_cr, DANUBE_BIU_WDT_CR);
|
||||||
@ -208,10 +155,9 @@ danube_wdt_set_clkdiv (int clkdiv)
|
|||||||
wdt_cr = readl(DANUBE_BIU_WDT_CR);
|
wdt_cr = readl(DANUBE_BIU_WDT_CR);
|
||||||
writel(DANUBE_BIU_WDT_CR_PW_SET(DANUBE_WDT_PW1), DANUBE_BIU_WDT_CR);
|
writel(DANUBE_BIU_WDT_CR_PW_SET(DANUBE_WDT_PW1), DANUBE_BIU_WDT_CR);
|
||||||
|
|
||||||
wdt_cr &= 0xff00ffff; //(!DANUBE_BIU_WDT_CR_PW_SET(0xff));
|
wdt_cr &= 0xfc00ffff;
|
||||||
wdt_cr &= 0xfcffffff; //(!DANUBE_BIU_WDT_CR_CLKDIV_SET(3));
|
wdt_cr |= (DANUBE_BIU_WDT_CR_PW_SET(DANUBE_WDT_PW2) |
|
||||||
wdt_cr |= (DANUBE_BIU_WDT_CR_PW_SET (DANUBE_WDT_PW2) |
|
DANUBE_BIU_WDT_CR_CLKDIV_SET(clkdiv));
|
||||||
DANUBE_BIU_WDT_CR_CLKDIV_SET (clkdiv));
|
|
||||||
|
|
||||||
/* Set reload value in second password access */
|
/* Set reload value in second password access */
|
||||||
writel(wdt_cr, DANUBE_BIU_WDT_CR);
|
writel(wdt_cr, DANUBE_BIU_WDT_CR);
|
||||||
@ -254,6 +200,11 @@ danube_wdt_ioctl (struct inode *inode, struct file *file, unsigned int cmd,
|
|||||||
result = danube_wdt_enable(timeout);
|
result = danube_wdt_enable(timeout);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case DANUBE_WDT_IOC_GET_STATUS:
|
||||||
|
istatus = readl(DANUBE_BIU_WDT_SR);
|
||||||
|
copy_to_user((int *) arg, (int *) &istatus, sizeof (int));
|
||||||
|
break;
|
||||||
|
|
||||||
case DANUBE_WDT_IOC_SET_PWL:
|
case DANUBE_WDT_IOC_SET_PWL:
|
||||||
if (copy_from_user((void *) &pwl, (void *) arg, sizeof (int)))
|
if (copy_from_user((void *) &pwl, (void *) arg, sizeof (int)))
|
||||||
result = -EINVAL;
|
result = -EINVAL;
|
||||||
@ -263,24 +214,19 @@ danube_wdt_ioctl (struct inode *inode, struct file *file, unsigned int cmd,
|
|||||||
case DANUBE_WDT_IOC_SET_DSEN:
|
case DANUBE_WDT_IOC_SET_DSEN:
|
||||||
if (copy_from_user((void *) &en, (void *) arg, sizeof (int)))
|
if (copy_from_user((void *) &en, (void *) arg, sizeof (int)))
|
||||||
result = -EINVAL;
|
result = -EINVAL;
|
||||||
danube_wdt_debug_suspend (en);
|
danube_wdt_low_power_or_debug(en, DANUBE_BIU_WDT_CR_DSEN);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DANUBE_WDT_IOC_SET_LPEN:
|
case DANUBE_WDT_IOC_SET_LPEN:
|
||||||
if (copy_from_user((void *) &en, (void *) arg, sizeof (int)))
|
if (copy_from_user((void *) &en, (void *) arg, sizeof (int)))
|
||||||
result = -EINVAL;
|
result = -EINVAL;
|
||||||
danube_wdt_low_power(en);
|
danube_wdt_low_power_or_debug(en, DANUBE_BIU_WDT_CR_LPEN);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DANUBE_WDT_IOC_SET_CLKDIV:
|
case DANUBE_WDT_IOC_SET_CLKDIV:
|
||||||
if (copy_from_user((void *) &clkdiv, (void *) arg, sizeof (int)))
|
if (copy_from_user((void *) &clkdiv, (void *) arg, sizeof (int)))
|
||||||
result = -EINVAL;
|
result = -EINVAL;
|
||||||
danube_wdt_set_clkdiv (clkdiv);
|
danube_wdt_set_clkdiv(clkdiv);
|
||||||
break;
|
|
||||||
|
|
||||||
case DANUBE_WDT_IOC_GET_STATUS:
|
|
||||||
istatus = readl(DANUBE_BIU_WDT_SR);
|
|
||||||
copy_to_user((int *) arg, (int *) &istatus, sizeof (int));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,6 +238,7 @@ danube_wdt_open (struct inode *inode, struct file *file)
|
|||||||
{
|
{
|
||||||
if (danube_wdt_inuse)
|
if (danube_wdt_inuse)
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
|
|
||||||
danube_wdt_inuse = 1;
|
danube_wdt_inuse = 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -310,14 +257,12 @@ danube_wdt_register_proc_read (char *buf, char **start, off_t offset, int count,
|
|||||||
int *eof, void *data)
|
int *eof, void *data)
|
||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
len += sprintf (buf + len, "DANUBE_BIU_WDT_PROC_READ\n");
|
|
||||||
|
|
||||||
|
len += sprintf (buf + len, "DANUBE_BIU_WDT_PROC_READ\n");
|
||||||
len += sprintf (buf + len, "DANUBE_BIU_WDT_CR(0x%08x) : 0x%08x\n",
|
len += sprintf (buf + len, "DANUBE_BIU_WDT_CR(0x%08x) : 0x%08x\n",
|
||||||
(unsigned int)DANUBE_BIU_WDT_CR,
|
(unsigned int)DANUBE_BIU_WDT_CR, readl(DANUBE_BIU_WDT_CR));
|
||||||
readl(DANUBE_BIU_WDT_CR));
|
|
||||||
len += sprintf (buf + len, "DANUBE_BIU_WDT_SR(0x%08x) : 0x%08x\n",
|
len += sprintf (buf + len, "DANUBE_BIU_WDT_SR(0x%08x) : 0x%08x\n",
|
||||||
(unsigned int)DANUBE_BIU_WDT_SR,
|
(unsigned int)DANUBE_BIU_WDT_SR, readl(DANUBE_BIU_WDT_SR));
|
||||||
readl(DANUBE_BIU_WDT_SR));
|
|
||||||
|
|
||||||
*eof = 1;
|
*eof = 1;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user