1*6e778a7eSPedro F. Giffuni /*-
2*6e778a7eSPedro F. Giffuni * SPDX-License-Identifier: ISC
3*6e778a7eSPedro F. Giffuni *
414779705SSam Leffler * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting
514779705SSam Leffler * Copyright (c) 2002-2008 Atheros Communications, Inc.
614779705SSam Leffler *
714779705SSam Leffler * Permission to use, copy, modify, and/or distribute this software for any
814779705SSam Leffler * purpose with or without fee is hereby granted, provided that the above
914779705SSam Leffler * copyright notice and this permission notice appear in all copies.
1014779705SSam Leffler *
1114779705SSam Leffler * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
1214779705SSam Leffler * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1314779705SSam Leffler * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1414779705SSam Leffler * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1514779705SSam Leffler * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1614779705SSam Leffler * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1714779705SSam Leffler * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1814779705SSam Leffler */
1914779705SSam Leffler #include "opt_ah.h"
2014779705SSam Leffler
2114779705SSam Leffler #include "ah.h"
2214779705SSam Leffler #include "ah_internal.h"
2314779705SSam Leffler #include "ah_devid.h"
2414779705SSam Leffler
2514779705SSam Leffler #include "ah_eeprom_v14.h"
2614779705SSam Leffler
2714779705SSam Leffler #include "ar5416/ar5416.h"
2814779705SSam Leffler #include "ar5416/ar5416reg.h"
2914779705SSam Leffler #include "ar5416/ar5416phy.h"
3014779705SSam Leffler
3114779705SSam Leffler /*
3214779705SSam Leffler * Read 16 bits of data from offset into *data
3314779705SSam Leffler */
3414779705SSam Leffler HAL_BOOL
ar5416EepromRead(struct ath_hal * ah,u_int off,uint16_t * data)3514779705SSam Leffler ar5416EepromRead(struct ath_hal *ah, u_int off, uint16_t *data)
3614779705SSam Leffler {
3714779705SSam Leffler OS_REG_READ(ah, AR5416_EEPROM_OFFSET + (off << AR5416_EEPROM_S));
3814779705SSam Leffler if (!ath_hal_wait(ah, AR_EEPROM_STATUS_DATA,
3914779705SSam Leffler AR_EEPROM_STATUS_DATA_BUSY | AR_EEPROM_STATUS_DATA_PROT_ACCESS, 0))
4014779705SSam Leffler return AH_FALSE;
4114779705SSam Leffler *data = MS(OS_REG_READ(ah, AR_EEPROM_STATUS_DATA),
4214779705SSam Leffler AR_EEPROM_STATUS_DATA_VAL);
4314779705SSam Leffler return AH_TRUE;
4414779705SSam Leffler }
45