18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Based on Ocelot Linux port, which is 48c2ecf20Sopenharmony_ci * Copyright 2001 MontaVista Software Inc. 58c2ecf20Sopenharmony_ci * Author: jsun@mvista.com or jsun@junsun.net 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Copyright 2003 ICT CAS 88c2ecf20Sopenharmony_ci * Author: Michael Guo <guoyi@ict.ac.cn> 98c2ecf20Sopenharmony_ci * 108c2ecf20Sopenharmony_ci * Copyright (C) 2007 Lemote Inc. & Institute of Computing Technology 118c2ecf20Sopenharmony_ci * Author: Fuxin Zhang, zhangfx@lemote.com 128c2ecf20Sopenharmony_ci * 138c2ecf20Sopenharmony_ci * Copyright (C) 2009 Lemote Inc. 148c2ecf20Sopenharmony_ci * Author: Wu Zhangjin, wuzhangjin@gmail.com 158c2ecf20Sopenharmony_ci */ 168c2ecf20Sopenharmony_ci#include <linux/export.h> 178c2ecf20Sopenharmony_ci#include <asm/bootinfo.h> 188c2ecf20Sopenharmony_ci#include <asm/fw/fw.h> 198c2ecf20Sopenharmony_ci#include <loongson.h> 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ciu32 cpu_clock_freq; 228c2ecf20Sopenharmony_ciEXPORT_SYMBOL(cpu_clock_freq); 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_civoid __init prom_init_env(void) 258c2ecf20Sopenharmony_ci{ 268c2ecf20Sopenharmony_ci /* pmon passes arguments in 32bit pointers */ 278c2ecf20Sopenharmony_ci unsigned int processor_id; 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci cpu_clock_freq = fw_getenvl("cpuclock"); 308c2ecf20Sopenharmony_ci memsize = fw_getenvl("memsize"); 318c2ecf20Sopenharmony_ci highmemsize = fw_getenvl("highmemsize"); 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci if (memsize == 0) 348c2ecf20Sopenharmony_ci memsize = 256; 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci pr_info("memsize=%u, highmemsize=%u\n", memsize, highmemsize); 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci if (cpu_clock_freq == 0) { 398c2ecf20Sopenharmony_ci processor_id = (¤t_cpu_data)->processor_id; 408c2ecf20Sopenharmony_ci switch (processor_id & PRID_REV_MASK) { 418c2ecf20Sopenharmony_ci case PRID_REV_LOONGSON2E: 428c2ecf20Sopenharmony_ci cpu_clock_freq = 533080000; 438c2ecf20Sopenharmony_ci break; 448c2ecf20Sopenharmony_ci case PRID_REV_LOONGSON2F: 458c2ecf20Sopenharmony_ci cpu_clock_freq = 797000000; 468c2ecf20Sopenharmony_ci break; 478c2ecf20Sopenharmony_ci default: 488c2ecf20Sopenharmony_ci cpu_clock_freq = 100000000; 498c2ecf20Sopenharmony_ci break; 508c2ecf20Sopenharmony_ci } 518c2ecf20Sopenharmony_ci } 528c2ecf20Sopenharmony_ci pr_info("CpuClock = %u\n", cpu_clock_freq); 538c2ecf20Sopenharmony_ci} 54