ar5416_gpio.c (228836) | ar5416_gpio.c (237611) |
---|---|
1/* 2 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting 3 * Copyright (c) 2002-2008 Atheros Communications, Inc. 4 * 5 * Permission to use, copy, modify, and/or distribute this software for any 6 * purpose with or without fee is hereby granted, provided that the above 7 * copyright notice and this permission notice appear in all copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 * | 1/* 2 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting 3 * Copyright (c) 2002-2008 Atheros Communications, Inc. 4 * 5 * Permission to use, copy, modify, and/or distribute this software for any 6 * purpose with or without fee is hereby granted, provided that the above 7 * copyright notice and this permission notice appear in all copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 * |
17 * $FreeBSD: head/sys/dev/ath/ath_hal/ar5416/ar5416_gpio.c 228836 2011-12-23 08:53:22Z adrian $ | 17 * $FreeBSD: head/sys/dev/ath/ath_hal/ar5416/ar5416_gpio.c 237611 2012-06-26 22:16:53Z adrian $ |
18 */ 19#include "opt_ah.h" 20 21#include "ah.h" 22#include "ah_internal.h" 23#include "ah_devid.h" 24 25#include "ar5416/ar5416.h" --- 54 unchanged lines hidden (view full) --- 80/* 81 * Configure GPIO Output lines 82 */ 83HAL_BOOL 84ar5416GpioCfgOutput(struct ath_hal *ah, uint32_t gpio, HAL_GPIO_MUX_TYPE type) 85{ 86 uint32_t gpio_shift, reg; 87 | 18 */ 19#include "opt_ah.h" 20 21#include "ah.h" 22#include "ah_internal.h" 23#include "ah_devid.h" 24 25#include "ar5416/ar5416.h" --- 54 unchanged lines hidden (view full) --- 80/* 81 * Configure GPIO Output lines 82 */ 83HAL_BOOL 84ar5416GpioCfgOutput(struct ath_hal *ah, uint32_t gpio, HAL_GPIO_MUX_TYPE type) 85{ 86 uint32_t gpio_shift, reg; 87 |
88#define N(a) (sizeof(a) / sizeof(a[0])) 89 |
|
88 HALASSERT(gpio < AH_PRIVATE(ah)->ah_caps.halNumGpioPins); 89 | 90 HALASSERT(gpio < AH_PRIVATE(ah)->ah_caps.halNumGpioPins); 91 |
92 /* 93 * This table maps the HAL GPIO pins to the actual hardware 94 * values. 95 */ 96 static const u_int32_t MuxSignalConversionTable[] = { 97 AR_GPIO_OUTPUT_MUX_AS_OUTPUT, 98 AR_GPIO_OUTPUT_MUX_AS_PCIE_ATTENTION_LED, 99 AR_GPIO_OUTPUT_MUX_AS_PCIE_POWER_LED, 100 AR_GPIO_OUTPUT_MUX_AS_MAC_NETWORK_LED, 101 AR_GPIO_OUTPUT_MUX_AS_PCIE_POWER_LED, 102 AR_GPIO_OUTPUT_MUX_AS_RX_CLEAR_EXTERNAL, 103 AR_GPIO_OUTPUT_MUX_AS_TX_FRAME, 104 }; 105 |
|
90 HALDEBUG(ah, HAL_DEBUG_GPIO, 91 "%s: gpio=%d, type=%d\n", __func__, gpio, type); 92 | 106 HALDEBUG(ah, HAL_DEBUG_GPIO, 107 "%s: gpio=%d, type=%d\n", __func__, gpio, type); 108 |
93 /* NB: type maps directly to hardware */ 94 /* XXX this may not actually be the case, for anything but output */ 95 cfgOutputMux(ah, gpio, type); 96 gpio_shift = gpio << 1; /* 2 bits per output mode */ | 109 /* 110 * Convert HAL signal type definitions to hardware-specific values. 111 */ 112 if (type >= N(MuxSignalConversionTable)) { 113 ath_hal_printf(ah, "%s: mux %d is invalid!\n", 114 __func__, 115 type); 116 return AH_FALSE; 117 } 118 cfgOutputMux(ah, gpio, MuxSignalConversionTable[type]); |
97 | 119 |
120 /* 2 bits per output mode */ 121 gpio_shift = gpio << 1; 122 123 /* Always drive, rather than tristate/drive low/drive high */ |
|
98 reg = OS_REG_READ(ah, AR_GPIO_OE_OUT); 99 reg &= ~(AR_GPIO_OE_OUT_DRV << gpio_shift); | 124 reg = OS_REG_READ(ah, AR_GPIO_OE_OUT); 125 reg &= ~(AR_GPIO_OE_OUT_DRV << gpio_shift); |
100 /* Always drive, rather than tristate/drive low/drive high */ | |
101 reg |= AR_GPIO_OE_OUT_DRV_ALL << gpio_shift; 102 OS_REG_WRITE(ah, AR_GPIO_OE_OUT, reg); 103 104 return AH_TRUE; | 126 reg |= AR_GPIO_OE_OUT_DRV_ALL << gpio_shift; 127 OS_REG_WRITE(ah, AR_GPIO_OE_OUT, reg); 128 129 return AH_TRUE; |
130#undef N |
|
105} 106 107/* 108 * Configure GPIO Input lines 109 */ 110HAL_BOOL 111ar5416GpioCfgInput(struct ath_hal *ah, uint32_t gpio) 112{ --- 140 unchanged lines hidden --- | 131} 132 133/* 134 * Configure GPIO Input lines 135 */ 136HAL_BOOL 137ar5416GpioCfgInput(struct ath_hal *ah, uint32_t gpio) 138{ --- 140 unchanged lines hidden --- |