18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Copyright (C) 2012 Thomas Langer <thomas.langer@lantiq.com> 58c2ecf20Sopenharmony_ci * Copyright (C) 2012 John Crispin <john@phrozen.org> 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#include <linux/init.h> 98c2ecf20Sopenharmony_ci#include <linux/io.h> 108c2ecf20Sopenharmony_ci#include <linux/pm.h> 118c2ecf20Sopenharmony_ci#include <asm/reboot.h> 128c2ecf20Sopenharmony_ci#include <linux/export.h> 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#include <lantiq_soc.h> 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci/* 178c2ecf20Sopenharmony_ci * Dummy implementation. Used to allow platform code to find out what 188c2ecf20Sopenharmony_ci * source was booted from 198c2ecf20Sopenharmony_ci */ 208c2ecf20Sopenharmony_ciunsigned char ltq_boot_select(void) 218c2ecf20Sopenharmony_ci{ 228c2ecf20Sopenharmony_ci return BS_SPI; 238c2ecf20Sopenharmony_ci} 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci#define BOOT_REG_BASE (KSEG1 | 0x1F200000) 268c2ecf20Sopenharmony_ci#define BOOT_PW1_REG (BOOT_REG_BASE | 0x20) 278c2ecf20Sopenharmony_ci#define BOOT_PW2_REG (BOOT_REG_BASE | 0x24) 288c2ecf20Sopenharmony_ci#define BOOT_PW1 0x4C545100 298c2ecf20Sopenharmony_ci#define BOOT_PW2 0x0051544C 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci#define WDT_REG_BASE (KSEG1 | 0x1F8803F0) 328c2ecf20Sopenharmony_ci#define WDT_PW1 0x00BE0000 338c2ecf20Sopenharmony_ci#define WDT_PW2 0x00DC0000 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_cistatic void machine_restart(char *command) 368c2ecf20Sopenharmony_ci{ 378c2ecf20Sopenharmony_ci local_irq_disable(); 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci /* reboot magic */ 408c2ecf20Sopenharmony_ci ltq_w32(BOOT_PW1, (void *)BOOT_PW1_REG); /* 'LTQ\0' */ 418c2ecf20Sopenharmony_ci ltq_w32(BOOT_PW2, (void *)BOOT_PW2_REG); /* '\0QTL' */ 428c2ecf20Sopenharmony_ci ltq_w32(0, (void *)BOOT_REG_BASE); /* reset Bootreg RVEC */ 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci /* watchdog magic */ 458c2ecf20Sopenharmony_ci ltq_w32(WDT_PW1, (void *)WDT_REG_BASE); 468c2ecf20Sopenharmony_ci ltq_w32(WDT_PW2 | 478c2ecf20Sopenharmony_ci (0x3 << 26) | /* PWL */ 488c2ecf20Sopenharmony_ci (0x2 << 24) | /* CLKDIV */ 498c2ecf20Sopenharmony_ci (0x1 << 31) | /* enable */ 508c2ecf20Sopenharmony_ci (1), /* reload */ 518c2ecf20Sopenharmony_ci (void *)WDT_REG_BASE); 528c2ecf20Sopenharmony_ci unreachable(); 538c2ecf20Sopenharmony_ci} 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_cistatic void machine_halt(void) 568c2ecf20Sopenharmony_ci{ 578c2ecf20Sopenharmony_ci local_irq_disable(); 588c2ecf20Sopenharmony_ci unreachable(); 598c2ecf20Sopenharmony_ci} 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_cistatic void machine_power_off(void) 628c2ecf20Sopenharmony_ci{ 638c2ecf20Sopenharmony_ci local_irq_disable(); 648c2ecf20Sopenharmony_ci unreachable(); 658c2ecf20Sopenharmony_ci} 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_cistatic int __init mips_reboot_setup(void) 688c2ecf20Sopenharmony_ci{ 698c2ecf20Sopenharmony_ci _machine_restart = machine_restart; 708c2ecf20Sopenharmony_ci _machine_halt = machine_halt; 718c2ecf20Sopenharmony_ci pm_power_off = machine_power_off; 728c2ecf20Sopenharmony_ci return 0; 738c2ecf20Sopenharmony_ci} 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ciarch_initcall(mips_reboot_setup); 76