Changeset 01784d2 in mainline for uspace/drv/bus/usb/ar9271/hw.c
- Timestamp:
- 2015-01-28T18:19:30Z (9 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 462054a
- Parents:
- ef521d4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ar9271/hw.c
ref521d4 r01784d2 64 64 continue; 65 65 } 66 66 67 67 if((result & mask) == value) { 68 68 return EOK; … … 73 73 } 74 74 75 /** 76 * Hardware reset of AR9271 device. 77 *78 * @param ar9271 Device structure. 79 * 80 * @return EOK if succeed, negative error code otherwise. 81 */ 82 int hw_reset(ar9271_t *ar9271) 83 { 84 reg_buffer_t buffer[] = {75 static int hw_reset_power_on(ar9271_t *ar9271) 76 { 77 int rc = wmi_reg_write(ar9271->htc_device, AR9271_RTC_FORCE_WAKE, 78 AR9271_RTC_FORCE_WAKE_ENABLE | AR9271_RTC_FORCE_WAKE_ON_INT); 79 if(rc != EOK) { 80 usb_log_error("Failed to bring up RTC register.\n"); 81 return rc; 82 } 83 84 wmi_reg_t buffer[] = { 85 85 { 86 86 .offset = AR9271_RTC_FORCE_WAKE, … … 98 98 }; 99 99 100 intrc = wmi_reg_buffer_write(ar9271->htc_device, buffer,101 sizeof(buffer) / sizeof( reg_buffer_t));100 rc = wmi_reg_buffer_write(ar9271->htc_device, buffer, 101 sizeof(buffer) / sizeof(wmi_reg_t)); 102 102 if(rc != EOK) { 103 103 usb_log_error("Failed to set RT FORCE WAKE register.\n"); … … 128 128 } 129 129 130 /* TODO: Finish HW init. */ 130 return EOK; 131 } 132 133 static int hw_warm_reset(ar9271_t *ar9271) 134 { 135 wmi_reg_t buffer[] = { 136 { 137 .offset = AR9271_RTC_FORCE_WAKE, 138 .value = AR9271_RTC_FORCE_WAKE_ENABLE | 139 AR9271_RTC_FORCE_WAKE_ON_INT 140 }, 141 { 142 .offset = AR9271_RC, 143 .value = AR9271_RC_AHB 144 }, 145 { 146 .offset = AR9271_RTC_RC, 147 .value = 1 148 } 149 }; 150 151 int rc = wmi_reg_buffer_write(ar9271->htc_device, buffer, 152 sizeof(buffer) / sizeof(wmi_reg_t)); 153 if(rc != EOK) { 154 usb_log_error("Failed to set warm reset register.\n"); 155 return rc; 156 } 157 158 udelay(100); 159 160 rc = wmi_reg_write(ar9271->htc_device, AR9271_RTC_RC, 0); 161 if(rc != EOK) { 162 usb_log_error("Failed to reset RTC RC register.\n"); 163 return rc; 164 } 165 166 rc = hw_read_wait(ar9271, AR9271_RTC_RC, AR9271_RTC_RC_MASK, 0); 167 if(rc != EOK) { 168 usb_log_error("Failed to read RTC RC register.\n"); 169 return rc; 170 } 171 172 rc = wmi_reg_write(ar9271->htc_device, AR9271_RC, 0); 173 if(rc != EOK) { 174 usb_log_error("Failed to reset MAC AHB register.\n"); 175 return rc; 176 } 177 178 return EOK; 179 } 180 181 /** 182 * Hardware reset of AR9271 device. 183 * 184 * @param ar9271 Device structure. 185 * 186 * @return EOK if succeed, negative error code otherwise. 187 */ 188 int hw_reset(ar9271_t *ar9271) 189 { 190 int rc = hw_reset_power_on(ar9271); 191 if(rc != EOK) { 192 usb_log_error("Failed to HW reset power on.\n"); 193 return rc; 194 } 195 196 rc = hw_warm_reset(ar9271); 197 if(rc != EOK) { 198 usb_log_error("Failed to HW warm reset.\n"); 199 return rc; 200 } 201 202 /* TODO: Finish HW init (EEPROM init, MAC ADDR init). */ 131 203 132 204 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.