| /* |
| * (C) Copyright 2010 Quantenna Communications Inc. |
| * |
| * See file CREDITS for list of people who contributed to this |
| * project. |
| * |
| * This program is free software; you can redistribute it and/or |
| * modify it under the terms of the GNU General Public License as |
| * published by the Free Software Foundation; either version 2 of |
| * the License, or (at your option) any later version. |
| * |
| * This program is distributed in the hope that it will be useful, |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| * 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 |
| */ |
| |
| #include "ruby.h" |
| |
| #ifdef TOPAZ_AMBER_IP |
| #include <amber.h> |
| #include <asm/arcregs.h> |
| #endif |
| |
| static inline void board_reset_watchdog(unsigned long delay) |
| { |
| writel(RUBY_WDT_ENABLE, RUBY_WDT_CTL); |
| writel(delay, RUBY_WDT_TIMEOUT_RANGE); |
| writel(RUBY_WDT_MAGIC_NUMBER, RUBY_WDT_COUNTER_RESTART); |
| } |
| |
| static inline void board_reset_sysctrl(unsigned long mask) |
| { |
| writel(mask, RUBY_SYS_CTL_CPU_VEC_MASK); |
| writel(0x0, RUBY_SYS_CTL_CPU_VEC); |
| writel(0x0, RUBY_SYS_CTL_CPU_VEC_MASK); |
| } |
| |
| void board_reset(const char *reason) |
| { |
| #ifndef TOPAZ_AMBER_IP |
| /* Postponed reset using watchdog - make sure that serial output will take place and be finished. */ |
| board_reset_watchdog(RUBY_WDT_RESET_TIMEOUT); |
| #endif |
| |
| /* Serial output. */ |
| puts(reason); |
| while(!serial_tx_done()); |
| |
| #ifndef TOPAZ_AMBER_IP |
| /* Force reset. */ |
| board_reset_sysctrl(RUBY_SYS_CTL_RESET_ALL); |
| #else |
| /* Tell ST HOST to reset Amber */ |
| amber_trigger_wifi2soc_interrupt(TOPAZ_AMBER_WIFI2SOC_EMERGENCY); |
| /* Halt the processor */ |
| __asm__ __volatile__("flag %0"::"i"(STATUS_H_SET)); |
| #endif |
| |
| /* Board must be resetted before this point! */ |
| while(1); |
| } |
| |
| int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| { |
| board_reset("reset command\n"); |
| return 0; |
| } |
| |