All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ralf Baechle <ralf@linux-mips.org>
To: Wu Zhangjin <wuzhangjin@gmail.com>
Cc: linux-mips@linux-mips.org, cpufreq@vger.kernel.org,
	Dave Jones <davej@redhat.com>,
	yanh@lemote.com, huhb@lemote.com
Subject: Re: [PATCH -queue 1/3] [loongson] lemote-2f: add cs5536 MFGPT timer support
Date: Thu, 12 Nov 2009 21:17:35 +0100	[thread overview]
Message-ID: <20091112201735.GA25435@linux-mips.org> (raw)
In-Reply-To: <de82733902e9549883b840f082a67b9edaa32c45.1257923011.git.wuzhangjin@gmail.com>

On Wed, Nov 11, 2009 at 03:09:57PM +0800, Wu Zhangjin wrote:

> When Oprofile is used, it's better not to use the MIPS Timer, but use an
> external timer, in Lemote loongson2f family machines, there is a cs5536
> mfgpt timer, this patch add support for it.
> 
> And also, this external timer is also needed by the next Cpufreq support,
> 'Cause the frequency of the MIPS Timer is half of the cpu frequency, if
> we use it with Cpufreq support, the sytem time will become not accuracy.
> 
> And we export the mfgpt0 counter disable/enable operations for the
> coming suspend support to suspend/resume the timer.
> 
> Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
> ---
>  .../asm/mach-loongson/cs5536/cs5536_mfgpt.h        |   35 +++
>  arch/mips/loongson/Kconfig                         |   11 +-
>  arch/mips/loongson/common/cs5536/Makefile          |    5 +
>  arch/mips/loongson/common/cs5536/cs5536_mfgpt.c    |  217 ++++++++++++++++++++
>  arch/mips/loongson/common/time.c                   |    3 +
>  5 files changed, 269 insertions(+), 2 deletions(-)
>  create mode 100644 arch/mips/include/asm/mach-loongson/cs5536/cs5536_mfgpt.h
>  create mode 100644 arch/mips/loongson/common/cs5536/cs5536_mfgpt.c
> 
> diff --git a/arch/mips/include/asm/mach-loongson/cs5536/cs5536_mfgpt.h b/arch/mips/include/asm/mach-loongson/cs5536/cs5536_mfgpt.h
> new file mode 100644
> index 0000000..8d45945
> --- /dev/null
> +++ b/arch/mips/include/asm/mach-loongson/cs5536/cs5536_mfgpt.h
> @@ -0,0 +1,35 @@
> +/*
> + * cs5536 mfgpt header file
> + */
> +
> +#ifndef _CS5536_MFGPT_H
> +#define _CS5536_MFGPT_H
> +
> +#include <cs5536/cs5536.h>
> +#include <cs5536/cs5536_pci.h>
> +
> +#ifdef CONFIG_CS5536_MFGPT
> +extern void setup_mfgpt_timer(void);
> +extern void disable_mfgpt0_counter(void);
> +extern void enable_mfgpt0_counter(void);
> +#else
> +static inline void __maybe_unused setup_mfgpt0_timer(void)
> +{
> +}
> +static inline void __maybe_unused disable_mfgpt0_counter(void)
> +{
> +}
> +static inline void __maybe_unused enable_mfgpt0_counter(void)
> +{
> +}
> +#endif
> +
> +#define MFGPT_TICK_RATE 14318000
> +#define COMPARE  ((MFGPT_TICK_RATE + HZ/2) / HZ)
> +
> +#define MFGPT_BASE	mfgpt_base
> +#define MFGPT0_CMP2	(MFGPT_BASE + 2)
> +#define MFGPT0_CNT	(MFGPT_BASE + 4)
> +#define MFGPT0_SETUP	(MFGPT_BASE + 6)
> +
> +#endif /*!_CS5536_MFGPT_H */
> diff --git a/arch/mips/loongson/Kconfig b/arch/mips/loongson/Kconfig
> index 029360f..648c47d 100644
> --- a/arch/mips/loongson/Kconfig
> +++ b/arch/mips/loongson/Kconfig
> @@ -34,10 +34,10 @@ config LEMOTE_MACH2F
>  	select ARCH_SPARSEMEM_ENABLE
>  	select BOARD_SCACHE
>  	select BOOT_ELF32
> -	select CEVT_R4K
> +	select CEVT_R4K if !CS5536_MFGPT
>  	select CPU_HAS_WB
>  	select CS5536
> -	select CSRC_R4K
> +	select CSRC_R4K if !CS5536_MFGPT

A bit inelegant to trust on a user to pick the right value for CS5536_MFGPT.

A non-fixed clock for c0_count is an obvious reason to avoid using CEVT_R4K
and CSRC_R4K; we probably need something like cpu_has_fixed_c0_count_clock
to make that decission at runtime.

>  	select DMA_NONCOHERENT
>  	select GENERIC_HARDIRQS_NO__DO_IRQ
>  	select GENERIC_ISA_DMA_SUPPORT_BROKEN
> @@ -62,6 +62,13 @@ endchoice
>  config CS5536
>  	bool
>  
> +config CS5536_MFGPT
> +	bool "Using cs5536's MFGPT as system clock"
> +	depends on CS5536
> +	help
> +	  This is needed when cpufreq or oprofile is enabled in Lemote Loongson2F
> +	  family machines

A patch to deal with interaction between oprofile and the cp0 count / compare
was queued recently.  So is there any remaining issue or is the comment here
just outdated?

  Ralf

  parent reply	other threads:[~2009-11-12 20:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-11  7:09 [PATCH -queue 0/3] add CPUFreq support for loongson2f Wu Zhangjin
2009-11-11  7:09 ` [PATCH -queue 1/3] [loongson] lemote-2f: add cs5536 MFGPT timer support Wu Zhangjin
2009-11-11 13:41   ` Wu Zhangjin
2009-11-12 20:17   ` Ralf Baechle [this message]
2009-11-13  6:16     ` Wu Zhangjin
2009-11-11  7:09 ` [PATCH -queue 2/3] MIPS: add basic options for CPUFreq support Wu Zhangjin
2009-11-11  7:09 ` [PATCH -queue 3/3] [loongson] 2f: add Cpufreq support Wu Zhangjin
2009-11-11 18:21   ` Dominik Brodowski
2009-11-12  1:47     ` Wu Zhangjin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091112201735.GA25435@linux-mips.org \
    --to=ralf@linux-mips.org \
    --cc=cpufreq@vger.kernel.org \
    --cc=davej@redhat.com \
    --cc=huhb@lemote.com \
    --cc=linux-mips@linux-mips.org \
    --cc=wuzhangjin@gmail.com \
    --cc=yanh@lemote.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.