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