forked from linux4sam/at91bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request linux4sam#51 from alexandrebelloni/backup_mode
Backup mode
- Loading branch information
Showing
9 changed files
with
305 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* ---------------------------------------------------------------------------- | ||
* ATMEL Microcontroller Software Support | ||
* ---------------------------------------------------------------------------- | ||
* Copyright (c) 2016, Atmel Corporation | ||
* | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* - Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the disclaimer below. | ||
* | ||
* Atmel's name may not be used to endorse or promote products derived from | ||
* this software without specific prior written permission. | ||
* | ||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR | ||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE | ||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, | ||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, | ||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
#include "backup.h" | ||
#include "debug.h" | ||
#include "hardware.h" | ||
#include "rstc.h" | ||
#include "arch/at91_sfrbu.h" | ||
|
||
static struct at91_pm_bu { | ||
int suspended; | ||
unsigned long *reserved; | ||
unsigned long *canary; | ||
unsigned long resume; | ||
} *pm_bu; | ||
|
||
static int resuming = -1; | ||
|
||
static int backup_mode(void) | ||
{ | ||
int ret; | ||
|
||
resuming = 0; | ||
|
||
ret = readl(AT91C_BASE_SFRBU + SFRBU_DDRBUMCR); | ||
if (ret == 0) | ||
return 0; | ||
|
||
do { | ||
ret = readl(AT91C_BASE_SECUMOD + 0x14); | ||
} while (ret == 0); | ||
|
||
pm_bu = (struct at91_pm_bu *)AT91C_BASE_SECURAM; | ||
if (!pm_bu->suspended) | ||
return 0; | ||
|
||
resuming = 1; | ||
return 1; | ||
} | ||
|
||
int backup_resume(void) | ||
{ | ||
if (resuming == -1) | ||
backup_mode(); | ||
|
||
return resuming; | ||
} | ||
|
||
unsigned long backup_mode_resume(void) | ||
{ | ||
if (!backup_resume()) | ||
return 0; | ||
|
||
writel(0, AT91C_BASE_SFRBU + SFRBU_DDRBUMCR); | ||
|
||
if (*pm_bu->canary != 0xa5a5a5a5) { | ||
cpu_reset(); | ||
return 0; | ||
} | ||
|
||
return pm_bu->resume; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* ---------------------------------------------------------------------------- | ||
* ATMEL Microcontroller Software Support | ||
* ---------------------------------------------------------------------------- | ||
* Copyright (c) 2016, Atmel Corporation | ||
* | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* - Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the disclaimer below. | ||
* | ||
* Atmel's name may not be used to endorse or promote products derived from | ||
* this software without specific prior written permission. | ||
* | ||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR | ||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE | ||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, | ||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, | ||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
#ifndef __AT91_SFRBU_H__ | ||
#define __AT91_SFRBU_H__ | ||
|
||
/* | ||
* Register Offset | ||
*/ | ||
#define SFRBU_DDRBUMCR 0x10 /* DDR BU Mode Control Register */ | ||
|
||
/* | ||
* Register Fields | ||
*/ | ||
|
||
/*--- SFRBU_DDRMCR: (offset: 0x10) DDR BU Mode Control Register ---*/ | ||
#define AT91C_DDRBUMCR_BUMEN (0x01 /* Force DDR_DQ Input Buffer Always On */ | ||
|
||
#endif /* #ifndef __AT91_SFRBU_H__ */ |
Oops, something went wrong.