1185377Ssam/*
2187831Ssam * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
3185377Ssam * Copyright (c) 2002-2008 Atheros Communications, Inc.
4185377Ssam *
5185377Ssam * Permission to use, copy, modify, and/or distribute this software for any
6185377Ssam * purpose with or without fee is hereby granted, provided that the above
7185377Ssam * copyright notice and this permission notice appear in all copies.
8185377Ssam *
9185377Ssam * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10185377Ssam * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11185377Ssam * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12185377Ssam * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13185377Ssam * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14185377Ssam * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15185377Ssam * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16185377Ssam *
17186014Ssam * $FreeBSD: releng/10.2/sys/dev/ath/ath_hal/ar5312/ar5312.h 188974 2009-02-24 00:12:16Z sam $
18185377Ssam */
19185377Ssam#ifndef _ATH_AR5312_H_
20185377Ssam#define _ATH_AR5312_H_
21185377Ssam
22185377Ssam#include "ah_soc.h"
23185377Ssam#include "ar5212/ar5212.h"
24185377Ssam
25185377Ssam#define AR5312_UNIT(_ah) \
26185377Ssam	(((const struct ar531x_config *)((_ah)->ah_st))->unit)
27185377Ssam#define AR5312_BOARDCONFIG(_ah) \
28185377Ssam	(((const struct ar531x_config *)((_ah)->ah_st))->board)
29185377Ssam#define AR5312_RADIOCONFIG(_ah) \
30185377Ssam	(((const struct ar531x_config *)((_ah)->ah_st))->radio)
31185377Ssam
32185377Ssam#define	IS_5312_2_X(ah) \
33185380Ssam	(AH_PRIVATE(ah)->ah_macVersion == AR_SREV_VERSION_VENICE && \
34185380Ssam	 (AH_PRIVATE(ah)->ah_macRev == 2 || AH_PRIVATE(ah)->ah_macRev == 7))
35185377Ssam#define IS_5315(ah) \
36185380Ssam	(AH_PRIVATE(ah)->ah_devid == AR5212_AR2315_REV6 || \
37185380Ssam	 AH_PRIVATE(ah)->ah_devid == AR5212_AR2315_REV7 || \
38185380Ssam	 AH_PRIVATE(ah)->ah_devid == AR5212_AR2317_REV1 || \
39185380Ssam	 AH_PRIVATE(ah)->ah_devid == AR5212_AR2317_REV2)
40185377Ssam
41185377Ssamextern  HAL_BOOL ar5312IsInterruptPending(struct ath_hal *ah);
42185377Ssam
43185377Ssam/* AR5312 */
44188974Ssamextern	HAL_BOOL ar5312GpioCfgOutput(struct ath_hal *, uint32_t gpio,
45188974Ssam		HAL_GPIO_MUX_TYPE);
46185377Ssamextern	HAL_BOOL ar5312GpioCfgInput(struct ath_hal *, uint32_t gpio);
47185377Ssamextern	HAL_BOOL ar5312GpioSet(struct ath_hal *, uint32_t gpio, uint32_t val);
48185377Ssamextern	uint32_t ar5312GpioGet(struct ath_hal *ah, uint32_t gpio);
49185377Ssamextern	void ar5312GpioSetIntr(struct ath_hal *ah, u_int, uint32_t ilevel);
50185377Ssam
51185377Ssam/* AR2315+ */
52188974Ssamextern	HAL_BOOL ar5315GpioCfgOutput(struct ath_hal *, uint32_t gpio,
53188974Ssam		HAL_GPIO_MUX_TYPE);
54185377Ssamextern	HAL_BOOL ar5315GpioCfgInput(struct ath_hal *, uint32_t gpio);
55185377Ssamextern	HAL_BOOL ar5315GpioSet(struct ath_hal *, uint32_t gpio, uint32_t val);
56185377Ssamextern	uint32_t ar5315GpioGet(struct ath_hal *ah, uint32_t gpio);
57185377Ssamextern	void ar5315GpioSetIntr(struct ath_hal *ah, u_int, uint32_t ilevel);
58185377Ssam
59185377Ssamextern  void ar5312SetLedState(struct ath_hal *ah, HAL_LED_STATE state);
60185377Ssamextern  HAL_BOOL ar5312DetectCardPresent(struct ath_hal *ah);
61185377Ssamextern  void ar5312SetupClock(struct ath_hal *ah, HAL_OPMODE opmode);
62185377Ssamextern  void ar5312RestoreClock(struct ath_hal *ah, HAL_OPMODE opmode);
63185377Ssamextern  void ar5312DumpState(struct ath_hal *ah);
64185377Ssamextern  HAL_BOOL ar5312Reset(struct ath_hal *ah, HAL_OPMODE opmode,
65187831Ssam              struct ieee80211_channel *chan,
66187831Ssam	      HAL_BOOL bChannelChange, HAL_STATUS *status);
67187831Ssamextern  HAL_BOOL ar5312ChipReset(struct ath_hal *ah,
68187831Ssam	      struct ieee80211_channel *chan);
69185377Ssamextern  HAL_BOOL ar5312SetPowerMode(struct ath_hal *ah, HAL_POWER_MODE mode,
70185377Ssam                                    int setChip);
71185377Ssamextern  HAL_BOOL ar5312PhyDisable(struct ath_hal *ah);
72185377Ssamextern  HAL_BOOL ar5312Disable(struct ath_hal *ah);
73185377Ssamextern  HAL_BOOL ar5312MacReset(struct ath_hal *ah, unsigned int RCMask);
74185377Ssamextern  uint32_t ar5312GetPowerMode(struct ath_hal *ah);
75185377Ssamextern  HAL_BOOL ar5312GetPowerStatus(struct ath_hal *ah);
76185377Ssam
77185377Ssam/* BSP functions */
78185377Ssamextern	HAL_BOOL ar5312EepromRead(struct ath_hal *, u_int off, uint16_t *data);
79185380Ssamextern	HAL_BOOL ar5312EepromWrite(struct ath_hal *, u_int off, uint16_t data);
80185377Ssam
81185377Ssam#endif	/* _ATH_AR3212_H_ */
82