Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 2 | /* |
| 3 | * |
| 4 | * (C) Copyright 2000-2003 |
| 5 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 6 | * |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 7 | * Copyright (C) 2004-2007, 2012 Freescale Semiconductor, Inc. |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 8 | * TsiChung Liew (Tsi-Chung.Liew@freescale.com) |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | #include <common.h> |
| 12 | #include <watchdog.h> |
| 13 | #include <command.h> |
Ben Warren | 2f2b6b6 | 2008-08-31 22:22:04 -0700 | [diff] [blame] | 14 | #include <netdev.h> |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 15 | |
| 16 | #include <asm/immap.h> |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 17 | #include <asm/io.h> |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 18 | |
| 19 | DECLARE_GLOBAL_DATA_PTR; |
| 20 | |
Mike Frysinger | 6d1f698 | 2010-10-20 03:41:17 -0400 | [diff] [blame] | 21 | int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 22 | { |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 23 | gptmr_t *gptmr = (gptmr_t *) (MMAP_GPTMR); |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 24 | |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 25 | out_be16(&gptmr->pre, 10); |
| 26 | out_be16(&gptmr->cnt, 1); |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 27 | |
| 28 | /* enable watchdog, set timeout to 0 and wait */ |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 29 | out_8(&gptmr->mode, GPT_TMS_SGPIO); |
| 30 | out_8(&gptmr->ctrl, GPT_CTRL_WDEN | GPT_CTRL_CE); |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 31 | |
| 32 | /* we don't return! */ |
| 33 | return 1; |
| 34 | }; |
| 35 | |
Angelo Dureghello | 3146b4d | 2017-08-20 00:01:55 +0200 | [diff] [blame] | 36 | #if defined(CONFIG_DISPLAY_CPUINFO) |
| 37 | int print_cpuinfo(void) |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 38 | { |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 39 | siu_t *siu = (siu_t *) MMAP_SIU; |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 40 | u16 id = 0; |
| 41 | |
| 42 | puts("CPU: "); |
| 43 | |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 44 | switch ((in_be32(&siu->jtagid) & 0x000FF000) >> 12) { |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 45 | case 0x0C: |
| 46 | id = 5485; |
| 47 | break; |
| 48 | case 0x0D: |
| 49 | id = 5484; |
| 50 | break; |
| 51 | case 0x0E: |
| 52 | id = 5483; |
| 53 | break; |
| 54 | case 0x0F: |
| 55 | id = 5482; |
| 56 | break; |
| 57 | case 0x10: |
| 58 | id = 5481; |
| 59 | break; |
| 60 | case 0x11: |
| 61 | id = 5480; |
| 62 | break; |
| 63 | case 0x12: |
| 64 | id = 5475; |
| 65 | break; |
| 66 | case 0x13: |
| 67 | id = 5474; |
| 68 | break; |
| 69 | case 0x14: |
| 70 | id = 5473; |
| 71 | break; |
| 72 | case 0x15: |
| 73 | id = 5472; |
| 74 | break; |
| 75 | case 0x16: |
| 76 | id = 5471; |
| 77 | break; |
| 78 | case 0x17: |
| 79 | id = 5470; |
| 80 | break; |
| 81 | } |
| 82 | |
| 83 | if (id) { |
Wolfgang Denk | 2059104 | 2008-10-19 02:35:49 +0200 | [diff] [blame] | 84 | char buf1[32], buf2[32]; |
| 85 | |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 86 | printf("Freescale MCF%d\n", id); |
Wolfgang Denk | 2059104 | 2008-10-19 02:35:49 +0200 | [diff] [blame] | 87 | printf(" CPU CLK %s MHz BUS CLK %s MHz\n", |
| 88 | strmhz(buf1, gd->cpu_clk), |
| 89 | strmhz(buf2, gd->bus_clk)); |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | return 0; |
| 93 | }; |
Angelo Dureghello | 3146b4d | 2017-08-20 00:01:55 +0200 | [diff] [blame] | 94 | #endif /* CONFIG_DISPLAY_CPUINFO */ |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 95 | |
| 96 | #if defined(CONFIG_HW_WATCHDOG) |
| 97 | /* Called by macro WATCHDOG_RESET */ |
| 98 | void hw_watchdog_reset(void) |
| 99 | { |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 100 | gptmr_t *gptmr = (gptmr_t *) (MMAP_GPTMR); |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 101 | |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 102 | out_8(&gptmr->ocpw, 0xa5); |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | int watchdog_disable(void) |
| 106 | { |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 107 | gptmr_t *gptmr = (gptmr_t *) (MMAP_GPTMR); |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 108 | |
| 109 | /* UserManual, once the wdog is disabled, wdog cannot be re-enabled */ |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 110 | out_8(&gptmr->mode, 0); |
| 111 | out_8(&gptmr->ctrl, 0); |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 112 | |
| 113 | puts("WATCHDOG:disabled\n"); |
| 114 | |
| 115 | return (0); |
| 116 | } |
| 117 | |
| 118 | int watchdog_init(void) |
| 119 | { |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 120 | gptmr_t *gptmr = (gptmr_t *) (MMAP_GPTMR); |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 121 | |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 122 | out_be16(&gptmr->pre, CONFIG_WATCHDOG_TIMEOUT); |
| 123 | out_be16(&gptmr->cnt, CONFIG_SYS_TIMER_PRESCALER * 1000); |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 124 | |
Alison Wang | 027f76f | 2012-03-26 21:49:07 +0000 | [diff] [blame] | 125 | out_8(&gptmr->mode, GPT_TMS_SGPIO); |
| 126 | out_8(&gptmr->ctrl, GPT_CTRL_CE | GPT_CTRL_WDEN); |
TsiChungLiew | 8999e6b | 2008-01-15 13:37:34 -0600 | [diff] [blame] | 127 | puts("WATCHDOG:enabled\n"); |
| 128 | |
| 129 | return (0); |
| 130 | } |
| 131 | #endif /* CONFIG_HW_WATCHDOG */ |
Ben Warren | e7edd4e | 2008-08-26 22:12:36 -0700 | [diff] [blame] | 132 | |
Ben Warren | 90c96db | 2008-08-26 22:16:25 -0700 | [diff] [blame] | 133 | #if defined(CONFIG_FSLDMAFEC) || defined(CONFIG_MCFFEC) |
| 134 | /* Default initializations for MCFFEC controllers. To override, |
| 135 | * create a board-specific function called: |
| 136 | * int board_eth_init(bd_t *bis) |
| 137 | */ |
| 138 | |
Ben Warren | e7edd4e | 2008-08-26 22:12:36 -0700 | [diff] [blame] | 139 | int cpu_eth_init(bd_t *bis) |
| 140 | { |
Ben Warren | 90c96db | 2008-08-26 22:16:25 -0700 | [diff] [blame] | 141 | #if defined(CONFIG_FSLDMAFEC) |
| 142 | mcdmafec_initialize(bis); |
| 143 | #endif |
| 144 | #if defined(CONFIG_MCFFEC) |
| 145 | mcffec_initialize(bis); |
| 146 | #endif |
| 147 | return 0; |
Ben Warren | e7edd4e | 2008-08-26 22:12:36 -0700 | [diff] [blame] | 148 | } |
| 149 | #endif |