/*1* Copyright (C) 2004 Florian Schirmer <[email protected]>2*3* This program is free software; you can redistribute it and/or modify it4* under the terms of the GNU General Public License as published by the5* Free Software Foundation; either version 2 of the License, or (at your6* option) any later version.7*8* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED9* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF10* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN11* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,12* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT13* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF14* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON15* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT16* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF17* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.18*19* You should have received a copy of the GNU General Public License along20* with this program; if not, write to the Free Software Foundation, Inc.,21* 675 Mass Ave, Cambridge, MA 02139, USA.22*/2324#include <linux/init.h>25#include <linux/ssb/ssb.h>26#include <asm/time.h>27#include <bcm47xx.h>28#include <bcm47xx_board.h>2930void __init plat_time_init(void)31{32unsigned long hz = 0;33u16 chip_id = 0;34char buf[10];35int len;36enum bcm47xx_board board = bcm47xx_board_get();3738/*39* Use deterministic values for initial counter interrupt40* so that calibrate delay avoids encountering a counter wrap.41*/42write_c0_count(0);43write_c0_compare(0xffff);4445switch (bcm47xx_bus_type) {46#ifdef CONFIG_BCM47XX_SSB47case BCM47XX_BUS_TYPE_SSB:48hz = ssb_cpu_clock(&bcm47xx_bus.ssb.mipscore) / 2;49chip_id = bcm47xx_bus.ssb.chip_id;50break;51#endif52#ifdef CONFIG_BCM47XX_BCMA53case BCM47XX_BUS_TYPE_BCMA:54hz = bcma_cpu_clock(&bcm47xx_bus.bcma.bus.drv_mips) / 2;55chip_id = bcm47xx_bus.bcma.bus.chipinfo.id;56break;57#endif58}5960if (chip_id == 0x5354) {61len = bcm47xx_nvram_getenv("clkfreq", buf, sizeof(buf));62if (len >= 0 && !strncmp(buf, "200", 4))63hz = 100000000;64}6566switch (board) {67case BCM47XX_BOARD_ASUS_WL520GC:68case BCM47XX_BOARD_ASUS_WL520GU:69hz = 100000000;70break;71default:72break;73}7475if (!hz)76hz = 100000000;7778/* Set MIPS counter frequency for fixed_rate_gettimeoffset() */79mips_hpt_frequency = hz;80}818283