ar71xx_cpudef.h revision 228018
1211447Sadrian/*- 2211447Sadrian * Copyright (c) 2010 Adrian Chadd 3211447Sadrian * All rights reserved. 4211447Sadrian * 5211447Sadrian * Redistribution and use in source and binary forms, with or without 6211447Sadrian * modification, are permitted provided that the following conditions 7211447Sadrian * are met: 8211447Sadrian * 1. Redistributions of source code must retain the above copyright 9211447Sadrian * notice, this list of conditions and the following disclaimer. 10211447Sadrian * 2. Redistributions in binary form must reproduce the above copyright 11211447Sadrian * notice, this list of conditions and the following disclaimer in the 12211447Sadrian * documentation and/or other materials provided with the distribution. 13211447Sadrian * 14211447Sadrian * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15211447Sadrian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16211447Sadrian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17211447Sadrian * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18211447Sadrian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19211447Sadrian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20211447Sadrian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21211447Sadrian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22211447Sadrian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23211447Sadrian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24211447Sadrian * SUCH DAMAGE. 25211447Sadrian */ 26211447Sadrian 27211447Sadrian/* $FreeBSD: head/sys/mips/atheros/ar71xx_cpudef.h 228018 2011-11-27 11:15:59Z ray $ */ 28211447Sadrian 29211447Sadrian#ifndef __AR71XX_CPUDEF_H__ 30211447Sadrian#define __AR71XX_CPUDEF_H__ 31211447Sadrian 32211447Sadrianstruct ar71xx_cpu_def { 33211447Sadrian void (* detect_mem_size) (void); 34211447Sadrian void (* detect_sys_frequency) (void); 35211447Sadrian void (* ar71xx_chip_device_stop) (uint32_t); 36211447Sadrian void (* ar71xx_chip_device_start) (uint32_t); 37211447Sadrian int (* ar71xx_chip_device_stopped) (uint32_t); 38228018Sray void (* ar71xx_chip_set_pll_ge) (int, int); 39228018Sray void (* ar71xx_chip_ddr_flush_ge) (int); 40211447Sadrian uint32_t (* ar71xx_chip_get_eth_pll) (unsigned int, int); 41211447Sadrian 42211447Sadrian /* 43211447Sadrian * From Linux - Handling this IRQ is a bit special. 44211447Sadrian * AR71xx - AR71XX_DDR_REG_FLUSH_PCI 45211447Sadrian * AR724x - AR724X_DDR_REG_FLUSH_PCIE 46211447Sadrian * AR91xx - AR91XX_DDR_REG_FLUSH_WMAC 47211447Sadrian * 48211447Sadrian * These are set when STATUSF_IP2 is set in regiser c0. 49211447Sadrian * This flush is done before the IRQ is handled to make 50211447Sadrian * sure the driver correctly sees any memory updates. 51211447Sadrian */ 52221198Sadrian void (* ar71xx_chip_ddr_flush_ip2) (void); 53211447Sadrian /* 54211447Sadrian * The USB peripheral init code is subtly different for 55211447Sadrian * each chip. 56211447Sadrian */ 57211447Sadrian void (* ar71xx_chip_init_usb_peripheral) (void); 58211447Sadrian}; 59211447Sadrian 60211447Sadrianextern struct ar71xx_cpu_def * ar71xx_cpu_ops; 61211447Sadrian 62211447Sadrianstatic inline void ar71xx_detect_sys_frequency(void) 63211447Sadrian{ 64211447Sadrian ar71xx_cpu_ops->detect_sys_frequency(); 65211447Sadrian} 66211447Sadrian 67211447Sadrianstatic inline void ar71xx_device_stop(uint32_t mask) 68211447Sadrian{ 69211447Sadrian ar71xx_cpu_ops->ar71xx_chip_device_stop(mask); 70211447Sadrian} 71211447Sadrian 72211447Sadrianstatic inline void ar71xx_device_start(uint32_t mask) 73211447Sadrian{ 74211447Sadrian ar71xx_cpu_ops->ar71xx_chip_device_start(mask); 75211447Sadrian} 76211447Sadrian 77211447Sadrianstatic inline int ar71xx_device_stopped(uint32_t mask) 78211447Sadrian{ 79211447Sadrian return ar71xx_cpu_ops->ar71xx_chip_device_stopped(mask); 80211447Sadrian} 81211447Sadrian 82228018Sraystatic inline void ar71xx_device_set_pll_ge(int unit, int speed) 83211509Sadrian{ 84228018Sray ar71xx_cpu_ops->ar71xx_chip_set_pll_ge(unit, speed); 85211509Sadrian} 86211509Sadrian 87228018Sraystatic inline void ar71xx_device_flush_ddr_ge(int unit) 88211509Sadrian{ 89228018Sray ar71xx_cpu_ops->ar71xx_chip_ddr_flush_ge(unit); 90211509Sadrian} 91211509Sadrian 92211447Sadrianstatic inline void ar71xx_init_usb_peripheral(void) 93211447Sadrian{ 94211447Sadrian ar71xx_cpu_ops->ar71xx_chip_init_usb_peripheral(); 95211447Sadrian} 96211447Sadrian 97221198Sadrianstatic inline void ar71xx_device_ddr_flush_ip2(void) 98221198Sadrian{ 99221198Sadrian ar71xx_cpu_ops->ar71xx_chip_ddr_flush_ip2(); 100221198Sadrian} 101221198Sadrian 102211447Sadrian/* XXX shouldn't be here! */ 103211447Sadrianextern uint32_t u_ar71xx_cpu_freq; 104211447Sadrianextern uint32_t u_ar71xx_ahb_freq; 105211447Sadrianextern uint32_t u_ar71xx_ddr_freq; 106211447Sadrian 107211447Sadrianstatic inline uint64_t ar71xx_cpu_freq(void) { return u_ar71xx_cpu_freq; } 108211447Sadrianstatic inline uint64_t ar71xx_ahb_freq(void) { return u_ar71xx_ahb_freq; } 109211447Sadrianstatic inline uint64_t ar71xx_ddr_freq(void) { return u_ar71xx_ddr_freq; } 110211447Sadrian 111211447Sadrian#endif 112