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