xref: /freebsd/sys/dev/ath/ath_hal/ar5312/ar5312_eeprom.c (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
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 #ifdef AH_SUPPORT_AR5312
2214779705SSam Leffler 
2314779705SSam Leffler #include "ah.h"
2414779705SSam Leffler #include "ah_internal.h"
2514779705SSam Leffler 
2614779705SSam Leffler #include "ar5312/ar5312.h"
2714779705SSam Leffler #include "ar5312/ar5312reg.h"
2814779705SSam Leffler #include "ar5212/ar5212desc.h"
2914779705SSam Leffler 
3014779705SSam Leffler /*
3114779705SSam Leffler  * Read 16 bits of data from offset into *data
3214779705SSam Leffler  */
3314779705SSam Leffler HAL_BOOL
ar5312EepromRead(struct ath_hal * ah,u_int off,uint16_t * dataIn)3414779705SSam Leffler ar5312EepromRead(struct ath_hal *ah, u_int off, uint16_t *dataIn)
3514779705SSam Leffler {
3614779705SSam Leffler         int i,offset;
3714779705SSam Leffler 	const char *eepromAddr = AR5312_RADIOCONFIG(ah);
3814779705SSam Leffler 	uint8_t *data;
3914779705SSam Leffler 
4014779705SSam Leffler 	data = (uint8_t *) dataIn;
4114779705SSam Leffler 	for (i=0,offset=2*off; i<2; i++,offset++) {
4214779705SSam Leffler 		data[i] = eepromAddr[offset];
4314779705SSam Leffler 	}
4414779705SSam Leffler         return AH_TRUE;
4514779705SSam Leffler }
4614779705SSam Leffler #endif /* AH_SUPPORT_AR5312 */
47