2186 /*
2187 * Get/Release semaphore of SMU
2188 * For SMU enabled chipset
2189 * When nge driver is attached, driver should acquire
2190 * semaphore before PHY init and accessing MAC registers.
2191 * When nge driver is unattached, driver should release
2192 * semaphore.
2193 */
2194
2195 static int
2196 nge_smu_sema(nge_t *ngep, boolean_t acquire)
2197 {
2198 nge_tx_en tx_en;
2199 uint32_t tries;
2200
2201 if (acquire) {
2202 for (tries = 0; tries < 5; tries++) {
2203 tx_en.val = nge_reg_get32(ngep, NGE_TX_EN);
2204 if (tx_en.bits.smu2mac == NGE_SMU_FREE)
2205 break;
2206 delay(drv_usectohz(1000000));
2207 }
2208 if (tx_en.bits.smu2mac != NGE_SMU_FREE)
2209 return (DDI_FAILURE);
2210 for (tries = 0; tries < 5; tries++) {
2211 tx_en.val = nge_reg_get32(ngep, NGE_TX_EN);
2212 tx_en.bits.mac2smu = NGE_SMU_GET;
2213 nge_reg_put32(ngep, NGE_TX_EN, tx_en.val);
2214 tx_en.val = nge_reg_get32(ngep, NGE_TX_EN);
2215
2216 if (tx_en.bits.mac2smu == NGE_SMU_GET &&
2217 tx_en.bits.smu2mac == NGE_SMU_FREE)
2218 return (DDI_SUCCESS);
2219 drv_usecwait(10);
2220 }
2221 return (DDI_FAILURE);
2222 } else
2223 nge_reg_put32(ngep, NGE_TX_EN, 0x0);
2224
2225 return (DDI_SUCCESS);
2226
|
2186 /*
2187 * Get/Release semaphore of SMU
2188 * For SMU enabled chipset
2189 * When nge driver is attached, driver should acquire
2190 * semaphore before PHY init and accessing MAC registers.
2191 * When nge driver is unattached, driver should release
2192 * semaphore.
2193 */
2194
2195 static int
2196 nge_smu_sema(nge_t *ngep, boolean_t acquire)
2197 {
2198 nge_tx_en tx_en;
2199 uint32_t tries;
2200
2201 if (acquire) {
2202 for (tries = 0; tries < 5; tries++) {
2203 tx_en.val = nge_reg_get32(ngep, NGE_TX_EN);
2204 if (tx_en.bits.smu2mac == NGE_SMU_FREE)
2205 break;
2206 delay(drv_sectohz(1));
2207 }
2208 if (tx_en.bits.smu2mac != NGE_SMU_FREE)
2209 return (DDI_FAILURE);
2210 for (tries = 0; tries < 5; tries++) {
2211 tx_en.val = nge_reg_get32(ngep, NGE_TX_EN);
2212 tx_en.bits.mac2smu = NGE_SMU_GET;
2213 nge_reg_put32(ngep, NGE_TX_EN, tx_en.val);
2214 tx_en.val = nge_reg_get32(ngep, NGE_TX_EN);
2215
2216 if (tx_en.bits.mac2smu == NGE_SMU_GET &&
2217 tx_en.bits.smu2mac == NGE_SMU_FREE)
2218 return (DDI_SUCCESS);
2219 drv_usecwait(10);
2220 }
2221 return (DDI_FAILURE);
2222 } else
2223 nge_reg_put32(ngep, NGE_TX_EN, 0x0);
2224
2225 return (DDI_SUCCESS);
2226
|