From: David Daney <ddaney@caviumnetworks.com>
To: David VomLehn <dvomlehn@cisco.com>
Cc: linux-mips@linux-mips.org, ralf@linux-mips.org
Subject: Re: [PATCH 1/3] mips:powertv: Base files for Cisco Powertv platform (resend)
Date: Tue, 05 May 2009 09:44:05 -0700 [thread overview]
Message-ID: <4A006CD5.8080401@caviumnetworks.com> (raw)
In-Reply-To: <20090504225616.GA22321@cuplxvomd02.corp.sa.net>
David VomLehn wrote:
> diff --git a/arch/mips/powertv/cevt-powertv.c b/arch/mips/powertv/cevt-powertv.c
[...]
> +static int mips_next_event(unsigned long delta,
> + struct clock_event_device *evt)
> +{
> + unsigned int cnt;
> + int res;
> +
> +#ifdef CONFIG_MIPS_MT_SMTC
> + {
> + unsigned long flags, vpflags;
> + local_irq_save(flags);
> + vpflags = dvpe();
> +#endif
> + cnt = read_c0_count();
> + cnt += delta;
> + write_c0_compare(cnt);
> + res = ((int)(read_c0_count() - cnt) > 0) ? -ETIME : 0;
> +#ifdef CONFIG_MIPS_MT_SMTC
> + evpe(vpflags);
> + local_irq_restore(flags);
> + }
> +#endif
> + return res;
Does this cpu have MIPS_MT? If not you could remove the #ifdef
(actually you could remove it in any case).
[...]
> diff --git a/arch/mips/powertv/csrc-powertv.c b/arch/mips/powertv/csrc-powertv.c
> new file mode 100644
> index 0000000..c032660
> --- /dev/null
> +++ b/arch/mips/powertv/csrc-powertv.c
> @@ -0,0 +1,84 @@
> +/*
> + * Copyright (C) 2008 Scientific-Atlanta, Inc.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation; either version 2
> + * of the License, or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
> + */
> +/*
> + * The file comes from kernel/csrc-r4k.c
> + */
Could you just use kernel/csrc-r4k.c, and move your mips_get_pll_freq()
to a different file (init.c or time.c)?
> +#include <linux/clocksource.h>
> +#include <linux/init.h>
> +
> +#include <asm/time.h> /* Not included in linux/time.h */
> +
> +#include <asm/mach-powertv/asic_regs.h>
> +#include "powertv-clock.h"
> +
> +/* MIPS PLL Register Definitions */
> +#define PLL_GET_M(x) (((x) >> 8) & 0x000000FF)
> +#define PLL_GET_N(x) (((x) >> 16) & 0x000000FF)
> +#define PLL_GET_P(x) (((x) >> 24) & 0x00000007)
> +
> +/*
> + * returns: Clock frequency in kHz
> + */
> +unsigned int __init mips_get_pll_freq(void)
> +{
> + unsigned int pll_reg, m, n, p;
> + unsigned int fin = 54000; /* Base frequency in kHz */
> + unsigned int fout;
> +
> + /* Read PLL register setting */
> + pll_reg = asic_read(MIPS_PLL_SETUP);
> + m = PLL_GET_M(pll_reg);
> + n = PLL_GET_N(pll_reg);
> + p = PLL_GET_P(pll_reg);
> + pr_info("MIPS PLL Register:0x%x M=%d N=%d P=%d\n", pll_reg, m, n, p);
> +
> + /* Calculate clock frequency = (2 * N * 54MHz) / (M * (2**P)) */
> + fout = ((2 * n * fin) / (m * (0x01 << p)));
> +
> + pr_info("MIPS Clock Freq=%d kHz\n", fout);
> +
> + return fout;
> +}
> +
> +static cycle_t c0_hpt_read(struct clocksource *cs)
> +{
> + return read_c0_count();
> +}
> +
> +static struct clocksource clocksource_mips = {
> + .name = "powertv-counter",
> + .read = c0_hpt_read,
> + .mask = CLOCKSOURCE_MASK(32),
> + .flags = CLOCK_SOURCE_IS_CONTINUOUS,
> +};
> +
> +void __init powertv_clocksource_init(void)
> +{
> + unsigned int pll_freq = mips_get_pll_freq();
> +
> + pr_info("CPU frequency %d.%02d MHz\n", pll_freq / 1000,
> + (pll_freq % 1000) * 100 / 1000);
> +
> + mips_hpt_frequency = pll_freq / 2 * 1000;
> +
> + clocksource_mips.rating = 200 + mips_hpt_frequency / 10000000;
> +
> + clocksource_set_clock(&clocksource_mips, mips_hpt_frequency);
> +
> + clocksource_register(&clocksource_mips);
> +}
next prev parent reply other threads:[~2009-05-05 16:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-04 22:56 [PATCH 1/3] mips:powertv: Base files for Cisco Powertv platform (resend) David VomLehn
2009-05-05 16:44 ` David Daney [this message]
2009-05-13 19:58 ` Paul Gortmaker
-- strict thread matches above, loose matches on Subject: below --
2009-05-29 19:35 David VomLehn
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=4A006CD5.8080401@caviumnetworks.com \
--to=ddaney@caviumnetworks.com \
--cc=dvomlehn@cisco.com \
--cc=linux-mips@linux-mips.org \
--cc=ralf@linux-mips.org \
/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.