ar71xx_cpudef.h revision 211509
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 211509 2010-08-19 16:15:30Z adrian $ */ 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); 38211447Sadrian void (* ar71xx_chip_set_pll_ge0) (int); 39211447Sadrian void (* ar71xx_chip_set_pll_ge1) (int); 40211447Sadrian void (* ar71xx_chip_ddr_flush_ge0) (void); 41211447Sadrian void (* ar71xx_chip_ddr_flush_ge1) (void); 42211447Sadrian uint32_t (* ar71xx_chip_get_eth_pll) (unsigned int, int); 43211447Sadrian 44211447Sadrian /* 45211447Sadrian * From Linux - Handling this IRQ is a bit special. 46211447Sadrian * AR71xx - AR71XX_DDR_REG_FLUSH_PCI 47211447Sadrian * AR724x - AR724X_DDR_REG_FLUSH_PCIE 48211447Sadrian * AR91xx - AR91XX_DDR_REG_FLUSH_WMAC 49211447Sadrian * 50211447Sadrian * These are set when STATUSF_IP2 is set in regiser c0. 51211447Sadrian * This flush is done before the IRQ is handled to make 52211447Sadrian * sure the driver correctly sees any memory updates. 53211447Sadrian */ 54211447Sadrian void (* ar71xx_chip_irq_flush_ip2) (void); 55211447Sadrian /* 56211447Sadrian * The USB peripheral init code is subtly different for 57211447Sadrian * each chip. 58211447Sadrian */ 59211447Sadrian void (* ar71xx_chip_init_usb_peripheral) (void); 60211447Sadrian}; 61211447Sadrian 62211447Sadrianextern struct ar71xx_cpu_def * ar71xx_cpu_ops; 63211447Sadrian 64211447Sadrianstatic inline void ar71xx_detect_sys_frequency(void) 65211447Sadrian{ 66211447Sadrian ar71xx_cpu_ops->detect_sys_frequency(); 67211447Sadrian} 68211447Sadrian 69211447Sadrianstatic inline void ar71xx_device_stop(uint32_t mask) 70211447Sadrian{ 71211447Sadrian ar71xx_cpu_ops->ar71xx_chip_device_stop(mask); 72211447Sadrian} 73211447Sadrian 74211447Sadrianstatic inline void ar71xx_device_start(uint32_t mask) 75211447Sadrian{ 76211447Sadrian ar71xx_cpu_ops->ar71xx_chip_device_start(mask); 77211447Sadrian} 78211447Sadrian 79211447Sadrianstatic inline int ar71xx_device_stopped(uint32_t mask) 80211447Sadrian{ 81211447Sadrian return ar71xx_cpu_ops->ar71xx_chip_device_stopped(mask); 82211447Sadrian} 83211447Sadrian 84211509Sadrianstatic inline void ar71xx_device_set_pll_ge0(int speed) 85211509Sadrian{ 86211509Sadrian ar71xx_cpu_ops->ar71xx_chip_set_pll_ge0(speed); 87211509Sadrian} 88211509Sadrian 89211509Sadrianstatic inline void ar71xx_device_set_pll_ge1(int speed) 90211509Sadrian{ 91211509Sadrian ar71xx_cpu_ops->ar71xx_chip_set_pll_ge1(speed); 92211509Sadrian} 93211509Sadrian 94211447Sadrianstatic inline void ar71xx_device_flush_ddr_ge0(void) 95211447Sadrian{ 96211447Sadrian ar71xx_cpu_ops->ar71xx_chip_ddr_flush_ge0(); 97211447Sadrian} 98211447Sadrian 99211447Sadrianstatic inline void ar71xx_device_flush_ddr_ge1(void) 100211447Sadrian{ 101211447Sadrian ar71xx_cpu_ops->ar71xx_chip_ddr_flush_ge1(); 102211447Sadrian} 103211447Sadrian 104211447Sadrianstatic inline void ar71xx_init_usb_peripheral(void) 105211447Sadrian{ 106211447Sadrian ar71xx_cpu_ops->ar71xx_chip_init_usb_peripheral(); 107211447Sadrian} 108211447Sadrian 109211447Sadrian/* XXX shouldn't be here! */ 110211447Sadrianextern uint32_t u_ar71xx_cpu_freq; 111211447Sadrianextern uint32_t u_ar71xx_ahb_freq; 112211447Sadrianextern uint32_t u_ar71xx_ddr_freq; 113211447Sadrian 114211447Sadrianstatic inline uint64_t ar71xx_cpu_freq(void) { return u_ar71xx_cpu_freq; } 115211447Sadrianstatic inline uint64_t ar71xx_ahb_freq(void) { return u_ar71xx_ahb_freq; } 116211447Sadrianstatic inline uint64_t ar71xx_ddr_freq(void) { return u_ar71xx_ddr_freq; } 117211447Sadrian 118211447Sadrian#endif 119