Path: blob/main/sys/dev/ath/ath_hal/ar5212/ar5212_eeprom.c
39566 views
/*-1* SPDX-License-Identifier: ISC2*3* Copyright (c) 2002-2008 Sam Leffler, Errno Consulting4* Copyright (c) 2002-2008 Atheros Communications, Inc.5*6* Permission to use, copy, modify, and/or distribute this software for any7* purpose with or without fee is hereby granted, provided that the above8* copyright notice and this permission notice appear in all copies.9*10* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES11* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF12* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR13* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES14* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN15* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF16* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.17*/18#include "opt_ah.h"1920#include "ah.h"21#include "ah_internal.h"22#include "ah_devid.h"23#ifdef AH_DEBUG24#include "ah_desc.h" /* NB: for HAL_PHYERR* */25#endif2627#include "ar5212/ar5212.h"28#include "ar5212/ar5212reg.h"29#include "ar5212/ar5212phy.h"3031/*32* Read 16 bits of data from offset into *data33*/34HAL_BOOL35ar5212EepromRead(struct ath_hal *ah, u_int off, uint16_t *data)36{37OS_REG_WRITE(ah, AR_EEPROM_ADDR, off);38OS_REG_WRITE(ah, AR_EEPROM_CMD, AR_EEPROM_CMD_READ);3940if (!ath_hal_wait(ah, AR_EEPROM_STS,41AR_EEPROM_STS_READ_COMPLETE | AR_EEPROM_STS_READ_ERROR,42AR_EEPROM_STS_READ_COMPLETE)) {43HALDEBUG(ah, HAL_DEBUG_ANY, "%s: read failed for entry 0x%x\n",44__func__, off);45return AH_FALSE;46}47*data = OS_REG_READ(ah, AR_EEPROM_DATA) & 0xffff;48return AH_TRUE;49}505152