Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * SH-Mobile Timer
0004  *
0005  * Copyright (C) 2010  Magnus Damm
0006  * Copyright (C) 2002 - 2009  Paul Mundt
0007  */
0008 #include <linux/platform_device.h>
0009 #include <linux/clocksource.h>
0010 #include <linux/delay.h>
0011 #include <linux/of_address.h>
0012 
0013 #include "common.h"
0014 
0015 void __init shmobile_init_delay(void)
0016 {
0017     struct device_node *np;
0018     u32 max_freq = 0;
0019 
0020     for_each_of_cpu_node(np) {
0021         u32 freq;
0022 
0023         if (!of_property_read_u32(np, "clock-frequency", &freq))
0024             max_freq = max(max_freq, freq);
0025     }
0026 
0027     if (!max_freq)
0028         return;
0029 
0030     /*
0031      * Calculate a worst-case loops-per-jiffy value
0032      * based on maximum cpu core hz setting and the
0033      * __delay() implementation in arch/arm/lib/delay.S.
0034      *
0035      * This will result in a longer delay than expected
0036      * when the cpu core runs on lower frequencies.
0037      */
0038 
0039     if (!preset_lpj)
0040         preset_lpj = max_freq / HZ;
0041 }