mips: convert to clocksource_register_hz/khz
This converts the mips clocksources to use clocksource_register_hz/khz CC: Ralf Baechle <ralf@linux-mips.org> CC: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: John Stultz <johnstul@us.ibm.com>
This commit is contained in:
@@ -141,8 +141,7 @@ static int __init alchemy_time_init(unsigned int m2int)
|
|||||||
goto cntr_err;
|
goto cntr_err;
|
||||||
|
|
||||||
/* register counter1 clocksource and event device */
|
/* register counter1 clocksource and event device */
|
||||||
clocksource_set_clock(&au1x_counter1_clocksource, 32768);
|
clocksource_register_hz(&au1x_counter1_clocksource, 32768);
|
||||||
clocksource_register(&au1x_counter1_clocksource);
|
|
||||||
|
|
||||||
cd->shift = 32;
|
cd->shift = 32;
|
||||||
cd->mult = div_sc(32768, NSEC_PER_SEC, cd->shift);
|
cd->mult = div_sc(32768, NSEC_PER_SEC, cd->shift);
|
||||||
|
|||||||
@@ -105,8 +105,7 @@ unsigned long long notrace sched_clock(void)
|
|||||||
void __init plat_time_init(void)
|
void __init plat_time_init(void)
|
||||||
{
|
{
|
||||||
clocksource_mips.rating = 300;
|
clocksource_mips.rating = 300;
|
||||||
clocksource_set_clock(&clocksource_mips, octeon_get_clock_rate());
|
clocksource_register_hz(&clocksource_mips, octeon_get_clock_rate());
|
||||||
clocksource_register(&clocksource_mips);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static u64 octeon_udelay_factor;
|
static u64 octeon_udelay_factor;
|
||||||
|
|||||||
@@ -84,12 +84,6 @@ static inline int init_mips_clocksource(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void clocksource_set_clock(struct clocksource *cs,
|
|
||||||
unsigned int clock)
|
|
||||||
{
|
|
||||||
clocksource_calc_mult_shift(cs, clock, 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void clockevent_set_clock(struct clock_event_device *cd,
|
static inline void clockevent_set_clock(struct clock_event_device *cd,
|
||||||
unsigned int clock)
|
unsigned int clock)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -121,8 +121,7 @@ void __init plat_time_init(void)
|
|||||||
|
|
||||||
clockevents_register_device(&jz4740_clockevent);
|
clockevents_register_device(&jz4740_clockevent);
|
||||||
|
|
||||||
clocksource_set_clock(&jz4740_clocksource, clk_rate);
|
ret = clocksource_register_hz(&jz4740_clocksource, clk_rate);
|
||||||
ret = clocksource_register(&jz4740_clocksource);
|
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
printk(KERN_ERR "Failed to register clocksource: %d\n", ret);
|
printk(KERN_ERR "Failed to register clocksource: %d\n", ret);
|
||||||
|
|||||||
@@ -51,8 +51,7 @@ void __init txx9_clocksource_init(unsigned long baseaddr,
|
|||||||
{
|
{
|
||||||
struct txx9_tmr_reg __iomem *tmrptr;
|
struct txx9_tmr_reg __iomem *tmrptr;
|
||||||
|
|
||||||
clocksource_set_clock(&txx9_clocksource.cs, TIMER_CLK(imbusclk));
|
clocksource_register_hz(&txx9_clocksource.cs, TIMER_CLK(imbusclk));
|
||||||
clocksource_register(&txx9_clocksource.cs);
|
|
||||||
|
|
||||||
tmrptr = ioremap(baseaddr, sizeof(struct txx9_tmr_reg));
|
tmrptr = ioremap(baseaddr, sizeof(struct txx9_tmr_reg));
|
||||||
__raw_writel(TCR_BASE, &tmrptr->tcr);
|
__raw_writel(TCR_BASE, &tmrptr->tcr);
|
||||||
|
|||||||
@@ -49,6 +49,5 @@ void __init sb1480_clocksource_init(void)
|
|||||||
|
|
||||||
plldiv = G_BCM1480_SYS_PLL_DIV(__raw_readq(IOADDR(A_SCD_SYSTEM_CFG)));
|
plldiv = G_BCM1480_SYS_PLL_DIV(__raw_readq(IOADDR(A_SCD_SYSTEM_CFG)));
|
||||||
zbbus = ((plldiv >> 1) * 50000000) + ((plldiv & 1) * 25000000);
|
zbbus = ((plldiv >> 1) * 50000000) + ((plldiv & 1) * 25000000);
|
||||||
clocksource_set_clock(cs, zbbus);
|
clocksource_register_hz(cs, zbbus);
|
||||||
clocksource_register(cs);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,5 @@ void __init dec_ioasic_clocksource_init(void)
|
|||||||
printk(KERN_INFO "I/O ASIC clock frequency %dHz\n", freq);
|
printk(KERN_INFO "I/O ASIC clock frequency %dHz\n", freq);
|
||||||
|
|
||||||
clocksource_dec.rating = 200 + freq / 10000000;
|
clocksource_dec.rating = 200 + freq / 10000000;
|
||||||
clocksource_set_clock(&clocksource_dec, freq);
|
clocksource_register_hz(&clocksource_dec, freq);
|
||||||
|
|
||||||
clocksource_register(&clocksource_dec);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,9 +78,7 @@ static void __init powertv_c0_hpt_clocksource_init(void)
|
|||||||
|
|
||||||
clocksource_mips.rating = 200 + mips_hpt_frequency / 10000000;
|
clocksource_mips.rating = 200 + mips_hpt_frequency / 10000000;
|
||||||
|
|
||||||
clocksource_set_clock(&clocksource_mips, mips_hpt_frequency);
|
clocksource_register_hz(&clocksource_mips, mips_hpt_frequency);
|
||||||
|
|
||||||
clocksource_register(&clocksource_mips);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -130,43 +128,16 @@ static struct clocksource clocksource_tim_c = {
|
|||||||
/**
|
/**
|
||||||
* powertv_tim_c_clocksource_init - set up a clock source for the TIM_C clock
|
* powertv_tim_c_clocksource_init - set up a clock source for the TIM_C clock
|
||||||
*
|
*
|
||||||
* The hard part here is coming up with a constant k and shift s such that
|
|
||||||
* the 48-bit TIM_C value multiplied by k doesn't overflow and that value,
|
|
||||||
* when shifted right by s, yields the corresponding number of nanoseconds.
|
|
||||||
* We know that TIM_C counts at 27 MHz/8, so each cycle corresponds to
|
* We know that TIM_C counts at 27 MHz/8, so each cycle corresponds to
|
||||||
* 1 / (27,000,000/8) seconds. Multiply that by a billion and you get the
|
* 1 / (27,000,000/8) seconds.
|
||||||
* number of nanoseconds. Since the TIM_C value has 48 bits and the math is
|
|
||||||
* done in 64 bits, avoiding an overflow means that k must be less than
|
|
||||||
* 64 - 48 = 16 bits.
|
|
||||||
*/
|
*/
|
||||||
static void __init powertv_tim_c_clocksource_init(void)
|
static void __init powertv_tim_c_clocksource_init(void)
|
||||||
{
|
{
|
||||||
int prescale;
|
|
||||||
unsigned long dividend;
|
|
||||||
unsigned long k;
|
|
||||||
int s;
|
|
||||||
const int max_k_bits = (64 - 48) - 1;
|
|
||||||
const unsigned long billion = 1000000000;
|
|
||||||
const unsigned long counts_per_second = 27000000 / 8;
|
const unsigned long counts_per_second = 27000000 / 8;
|
||||||
|
|
||||||
prescale = BITS_PER_LONG - ilog2(billion) - 1;
|
|
||||||
dividend = billion << prescale;
|
|
||||||
k = dividend / counts_per_second;
|
|
||||||
s = ilog2(k) - max_k_bits;
|
|
||||||
|
|
||||||
if (s < 0)
|
|
||||||
s = prescale;
|
|
||||||
|
|
||||||
else {
|
|
||||||
k >>= s;
|
|
||||||
s += prescale;
|
|
||||||
}
|
|
||||||
|
|
||||||
clocksource_tim_c.mult = k;
|
|
||||||
clocksource_tim_c.shift = s;
|
|
||||||
clocksource_tim_c.rating = 200;
|
clocksource_tim_c.rating = 200;
|
||||||
|
|
||||||
clocksource_register(&clocksource_tim_c);
|
clocksource_register_hz(&clocksource_tim_c, counts_per_second);
|
||||||
tim_c = (struct tim_c *) asic_reg_addr(tim_ch);
|
tim_c = (struct tim_c *) asic_reg_addr(tim_ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,9 +30,7 @@ int __init init_r4k_clocksource(void)
|
|||||||
/* Calculate a somewhat reasonable rating value */
|
/* Calculate a somewhat reasonable rating value */
|
||||||
clocksource_mips.rating = 200 + mips_hpt_frequency / 10000000;
|
clocksource_mips.rating = 200 + mips_hpt_frequency / 10000000;
|
||||||
|
|
||||||
clocksource_set_clock(&clocksource_mips, mips_hpt_frequency);
|
clocksource_register_hz(&clocksource_mips, mips_hpt_frequency);
|
||||||
|
|
||||||
clocksource_register(&clocksource_mips);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,6 +65,5 @@ void __init sb1250_clocksource_init(void)
|
|||||||
IOADDR(A_SCD_TIMER_REGISTER(SB1250_HPT_NUM,
|
IOADDR(A_SCD_TIMER_REGISTER(SB1250_HPT_NUM,
|
||||||
R_SCD_TIMER_CFG)));
|
R_SCD_TIMER_CFG)));
|
||||||
|
|
||||||
clocksource_set_clock(cs, V_SCD_TIMER_FREQ);
|
clocksource_register_hz(cs, V_SCD_TIMER_FREQ);
|
||||||
clocksource_register(cs);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -196,8 +196,6 @@ static struct clocksource clocksource_pit = {
|
|||||||
.rating = 110,
|
.rating = 110,
|
||||||
.read = pit_read,
|
.read = pit_read,
|
||||||
.mask = CLOCKSOURCE_MASK(32),
|
.mask = CLOCKSOURCE_MASK(32),
|
||||||
.mult = 0,
|
|
||||||
.shift = 20,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static int __init init_pit_clocksource(void)
|
static int __init init_pit_clocksource(void)
|
||||||
@@ -205,7 +203,6 @@ static int __init init_pit_clocksource(void)
|
|||||||
if (num_possible_cpus() > 1) /* PIT does not scale! */
|
if (num_possible_cpus() > 1) /* PIT does not scale! */
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
clocksource_pit.mult = clocksource_hz2mult(CLOCK_TICK_RATE, 20);
|
return clocksource_register_hz(&clocksource_pit, CLOCK_TICK_RATE);
|
||||||
return clocksource_register(&clocksource_pit);
|
|
||||||
}
|
}
|
||||||
arch_initcall(init_pit_clocksource);
|
arch_initcall(init_pit_clocksource);
|
||||||
|
|||||||
@@ -201,8 +201,6 @@ static struct clocksource clocksource_mfgpt = {
|
|||||||
.rating = 120, /* Functional for real use, but not desired */
|
.rating = 120, /* Functional for real use, but not desired */
|
||||||
.read = mfgpt_read,
|
.read = mfgpt_read,
|
||||||
.mask = CLOCKSOURCE_MASK(32),
|
.mask = CLOCKSOURCE_MASK(32),
|
||||||
.mult = 0,
|
|
||||||
.shift = 22,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int __init init_mfgpt_clocksource(void)
|
int __init init_mfgpt_clocksource(void)
|
||||||
@@ -210,8 +208,7 @@ int __init init_mfgpt_clocksource(void)
|
|||||||
if (num_possible_cpus() > 1) /* MFGPT does not scale! */
|
if (num_possible_cpus() > 1) /* MFGPT does not scale! */
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
clocksource_mfgpt.mult = clocksource_hz2mult(MFGPT_TICK_RATE, 22);
|
return clocksource_register_hz(&clocksource_mfgpt, MFGPT_TICK_RATE);
|
||||||
return clocksource_register(&clocksource_mfgpt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
arch_initcall(init_mfgpt_clocksource);
|
arch_initcall(init_mfgpt_clocksource);
|
||||||
|
|||||||
@@ -177,8 +177,7 @@ static void __init hub_rt_clocksource_init(void)
|
|||||||
{
|
{
|
||||||
struct clocksource *cs = &hub_rt_clocksource;
|
struct clocksource *cs = &hub_rt_clocksource;
|
||||||
|
|
||||||
clocksource_set_clock(cs, CYCLES_PER_SEC);
|
clocksource_register_hz(cs, CYCLES_PER_SEC);
|
||||||
clocksource_register(cs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void __init plat_time_init(void)
|
void __init plat_time_init(void)
|
||||||
|
|||||||
Reference in New Issue
Block a user