Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | |
| 3 | AudioScience HPI driver |
| 4 | Copyright (C) 1997-2010 AudioScience Inc. <support@audioscience.com> |
| 5 | |
| 6 | This program is free software; you can redistribute it and/or modify |
| 7 | it under the terms of version 2 of the GNU General Public License as |
| 8 | published by the Free Software Foundation; |
| 9 | |
| 10 | This program is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | GNU General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU General Public License |
| 16 | along with this program; if not, write to the Free Software |
| 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 | |
| 19 | Hardware Programming Interface (HPI) for AudioScience |
| 20 | ASI50xx, AS51xx, ASI6xxx, ASI87xx ASI89xx series adapters. |
| 21 | These PCI and PCIe bus adapters are based on a |
| 22 | TMS320C6205 PCI bus mastering DSP, |
| 23 | and (except ASI50xx) TI TMS320C6xxx floating point DSP |
| 24 | |
| 25 | Exported function: |
| 26 | void HPI_6205(struct hpi_message *phm, struct hpi_response *phr) |
| 27 | |
| 28 | (C) Copyright AudioScience Inc. 1998-2010 |
| 29 | *******************************************************************************/ |
| 30 | #define SOURCEFILE_NAME "hpi6205.c" |
| 31 | |
| 32 | #include "hpi_internal.h" |
| 33 | #include "hpimsginit.h" |
| 34 | #include "hpidebug.h" |
| 35 | #include "hpi6205.h" |
| 36 | #include "hpidspcd.h" |
| 37 | #include "hpicmn.h" |
| 38 | |
| 39 | /*****************************************************************************/ |
| 40 | /* HPI6205 specific error codes */ |
Eliot Blennerhassett | deb21a2 | 2011-02-10 17:26:03 +1300 | [diff] [blame] | 41 | #define HPI6205_ERROR_BASE 1000 /* not actually used anywhere */ |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 42 | |
| 43 | /* operational/messaging errors */ |
| 44 | #define HPI6205_ERROR_MSG_RESP_IDLE_TIMEOUT 1015 |
| 45 | #define HPI6205_ERROR_MSG_RESP_TIMEOUT 1016 |
| 46 | |
| 47 | /* initialization/bootload errors */ |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 48 | #define HPI6205_ERROR_6205_NO_IRQ 1002 |
| 49 | #define HPI6205_ERROR_6205_INIT_FAILED 1003 |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 50 | #define HPI6205_ERROR_6205_REG 1006 |
| 51 | #define HPI6205_ERROR_6205_DSPPAGE 1007 |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 52 | #define HPI6205_ERROR_C6713_HPIC 1009 |
| 53 | #define HPI6205_ERROR_C6713_HPIA 1010 |
| 54 | #define HPI6205_ERROR_C6713_PLL 1011 |
| 55 | #define HPI6205_ERROR_DSP_INTMEM 1012 |
| 56 | #define HPI6205_ERROR_DSP_EXTMEM 1013 |
| 57 | #define HPI6205_ERROR_DSP_PLD 1014 |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 58 | #define HPI6205_ERROR_6205_EEPROM 1017 |
| 59 | #define HPI6205_ERROR_DSP_EMIF 1018 |
| 60 | |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 61 | /*****************************************************************************/ |
| 62 | /* for C6205 PCI i/f */ |
| 63 | /* Host Status Register (HSR) bitfields */ |
| 64 | #define C6205_HSR_INTSRC 0x01 |
| 65 | #define C6205_HSR_INTAVAL 0x02 |
| 66 | #define C6205_HSR_INTAM 0x04 |
| 67 | #define C6205_HSR_CFGERR 0x08 |
| 68 | #define C6205_HSR_EEREAD 0x10 |
| 69 | /* Host-to-DSP Control Register (HDCR) bitfields */ |
| 70 | #define C6205_HDCR_WARMRESET 0x01 |
| 71 | #define C6205_HDCR_DSPINT 0x02 |
| 72 | #define C6205_HDCR_PCIBOOT 0x04 |
| 73 | /* DSP Page Register (DSPP) bitfields, */ |
| 74 | /* defines 4 Mbyte page that BAR0 points to */ |
| 75 | #define C6205_DSPP_MAP1 0x400 |
| 76 | |
| 77 | /* BAR0 maps to prefetchable 4 Mbyte memory block set by DSPP. |
| 78 | * BAR1 maps to non-prefetchable 8 Mbyte memory block |
| 79 | * of DSP memory mapped registers (starting at 0x01800000). |
| 80 | * 0x01800000 is hardcoded in the PCI i/f, so that only the offset from this |
| 81 | * needs to be added to the BAR1 base address set in the PCI config reg |
| 82 | */ |
| 83 | #define C6205_BAR1_PCI_IO_OFFSET (0x027FFF0L) |
| 84 | #define C6205_BAR1_HSR (C6205_BAR1_PCI_IO_OFFSET) |
| 85 | #define C6205_BAR1_HDCR (C6205_BAR1_PCI_IO_OFFSET+4) |
| 86 | #define C6205_BAR1_DSPP (C6205_BAR1_PCI_IO_OFFSET+8) |
| 87 | |
| 88 | /* used to control LED (revA) and reset C6713 (revB) */ |
| 89 | #define C6205_BAR0_TIMER1_CTL (0x01980000L) |
| 90 | |
| 91 | /* For first 6713 in CE1 space, using DA17,16,2 */ |
| 92 | #define HPICL_ADDR 0x01400000L |
| 93 | #define HPICH_ADDR 0x01400004L |
| 94 | #define HPIAL_ADDR 0x01410000L |
| 95 | #define HPIAH_ADDR 0x01410004L |
| 96 | #define HPIDIL_ADDR 0x01420000L |
| 97 | #define HPIDIH_ADDR 0x01420004L |
| 98 | #define HPIDL_ADDR 0x01430000L |
| 99 | #define HPIDH_ADDR 0x01430004L |
| 100 | |
| 101 | #define C6713_EMIF_GCTL 0x01800000 |
| 102 | #define C6713_EMIF_CE1 0x01800004 |
| 103 | #define C6713_EMIF_CE0 0x01800008 |
| 104 | #define C6713_EMIF_CE2 0x01800010 |
| 105 | #define C6713_EMIF_CE3 0x01800014 |
| 106 | #define C6713_EMIF_SDRAMCTL 0x01800018 |
| 107 | #define C6713_EMIF_SDRAMTIMING 0x0180001C |
| 108 | #define C6713_EMIF_SDRAMEXT 0x01800020 |
| 109 | |
| 110 | struct hpi_hw_obj { |
| 111 | /* PCI registers */ |
| 112 | __iomem u32 *prHSR; |
| 113 | __iomem u32 *prHDCR; |
| 114 | __iomem u32 *prDSPP; |
| 115 | |
| 116 | u32 dsp_page; |
| 117 | |
| 118 | struct consistent_dma_area h_locked_mem; |
| 119 | struct bus_master_interface *p_interface_buffer; |
| 120 | |
| 121 | u16 flag_outstream_just_reset[HPI_MAX_STREAMS]; |
| 122 | /* a non-NULL handle means there is an HPI allocated buffer */ |
| 123 | struct consistent_dma_area instream_host_buffers[HPI_MAX_STREAMS]; |
| 124 | struct consistent_dma_area outstream_host_buffers[HPI_MAX_STREAMS]; |
| 125 | /* non-zero size means a buffer exists, may be external */ |
| 126 | u32 instream_host_buffer_size[HPI_MAX_STREAMS]; |
| 127 | u32 outstream_host_buffer_size[HPI_MAX_STREAMS]; |
| 128 | |
| 129 | struct consistent_dma_area h_control_cache; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 130 | struct hpi_control_cache *p_cache; |
| 131 | }; |
| 132 | |
| 133 | /*****************************************************************************/ |
| 134 | /* local prototypes */ |
| 135 | |
| 136 | #define check_before_bbm_copy(status, p_bbm_data, l_first_write, l_second_write) |
| 137 | |
| 138 | static int wait_dsp_ack(struct hpi_hw_obj *phw, int state, int timeout_us); |
| 139 | |
| 140 | static void send_dsp_command(struct hpi_hw_obj *phw, int cmd); |
| 141 | |
| 142 | static u16 adapter_boot_load_dsp(struct hpi_adapter_obj *pao, |
| 143 | u32 *pos_error_code); |
| 144 | |
| 145 | static u16 message_response_sequence(struct hpi_adapter_obj *pao, |
| 146 | struct hpi_message *phm, struct hpi_response *phr); |
| 147 | |
| 148 | static void hw_message(struct hpi_adapter_obj *pao, struct hpi_message *phm, |
| 149 | struct hpi_response *phr); |
| 150 | |
| 151 | #define HPI6205_TIMEOUT 1000000 |
| 152 | |
| 153 | static void subsys_create_adapter(struct hpi_message *phm, |
| 154 | struct hpi_response *phr); |
Eliot Blennerhassett | 6d0b898 | 2011-04-05 20:55:47 +1200 | [diff] [blame] | 155 | static void adapter_delete(struct hpi_adapter_obj *pao, |
| 156 | struct hpi_message *phm, struct hpi_response *phr); |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 157 | |
| 158 | static u16 create_adapter_obj(struct hpi_adapter_obj *pao, |
| 159 | u32 *pos_error_code); |
| 160 | |
| 161 | static void delete_adapter_obj(struct hpi_adapter_obj *pao); |
| 162 | |
| 163 | static void outstream_host_buffer_allocate(struct hpi_adapter_obj *pao, |
| 164 | struct hpi_message *phm, struct hpi_response *phr); |
| 165 | |
| 166 | static void outstream_host_buffer_get_info(struct hpi_adapter_obj *pao, |
| 167 | struct hpi_message *phm, struct hpi_response *phr); |
| 168 | |
| 169 | static void outstream_host_buffer_free(struct hpi_adapter_obj *pao, |
| 170 | struct hpi_message *phm, struct hpi_response *phr); |
| 171 | static void outstream_write(struct hpi_adapter_obj *pao, |
| 172 | struct hpi_message *phm, struct hpi_response *phr); |
| 173 | |
| 174 | static void outstream_get_info(struct hpi_adapter_obj *pao, |
| 175 | struct hpi_message *phm, struct hpi_response *phr); |
| 176 | |
| 177 | static void outstream_start(struct hpi_adapter_obj *pao, |
| 178 | struct hpi_message *phm, struct hpi_response *phr); |
| 179 | |
| 180 | static void outstream_open(struct hpi_adapter_obj *pao, |
| 181 | struct hpi_message *phm, struct hpi_response *phr); |
| 182 | |
| 183 | static void outstream_reset(struct hpi_adapter_obj *pao, |
| 184 | struct hpi_message *phm, struct hpi_response *phr); |
| 185 | |
| 186 | static void instream_host_buffer_allocate(struct hpi_adapter_obj *pao, |
| 187 | struct hpi_message *phm, struct hpi_response *phr); |
| 188 | |
| 189 | static void instream_host_buffer_get_info(struct hpi_adapter_obj *pao, |
| 190 | struct hpi_message *phm, struct hpi_response *phr); |
| 191 | |
| 192 | static void instream_host_buffer_free(struct hpi_adapter_obj *pao, |
| 193 | struct hpi_message *phm, struct hpi_response *phr); |
| 194 | |
| 195 | static void instream_read(struct hpi_adapter_obj *pao, |
| 196 | struct hpi_message *phm, struct hpi_response *phr); |
| 197 | |
| 198 | static void instream_get_info(struct hpi_adapter_obj *pao, |
| 199 | struct hpi_message *phm, struct hpi_response *phr); |
| 200 | |
| 201 | static void instream_start(struct hpi_adapter_obj *pao, |
| 202 | struct hpi_message *phm, struct hpi_response *phr); |
| 203 | |
| 204 | static u32 boot_loader_read_mem32(struct hpi_adapter_obj *pao, int dsp_index, |
| 205 | u32 address); |
| 206 | |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 207 | static void boot_loader_write_mem32(struct hpi_adapter_obj *pao, |
| 208 | int dsp_index, u32 address, u32 data); |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 209 | |
| 210 | static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, |
| 211 | int dsp_index); |
| 212 | |
| 213 | static u16 boot_loader_test_memory(struct hpi_adapter_obj *pao, int dsp_index, |
| 214 | u32 address, u32 length); |
| 215 | |
| 216 | static u16 boot_loader_test_internal_memory(struct hpi_adapter_obj *pao, |
| 217 | int dsp_index); |
| 218 | |
| 219 | static u16 boot_loader_test_external_memory(struct hpi_adapter_obj *pao, |
| 220 | int dsp_index); |
| 221 | |
| 222 | static u16 boot_loader_test_pld(struct hpi_adapter_obj *pao, int dsp_index); |
| 223 | |
| 224 | /*****************************************************************************/ |
| 225 | |
Eliot Blennerhassett | 6d0b898 | 2011-04-05 20:55:47 +1200 | [diff] [blame] | 226 | static void subsys_message(struct hpi_adapter_obj *pao, |
| 227 | struct hpi_message *phm, struct hpi_response *phr) |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 228 | { |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 229 | switch (phm->function) { |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 230 | case HPI_SUBSYS_CREATE_ADAPTER: |
| 231 | subsys_create_adapter(phm, phr); |
| 232 | break; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 233 | default: |
| 234 | phr->error = HPI_ERROR_INVALID_FUNC; |
| 235 | break; |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | static void control_message(struct hpi_adapter_obj *pao, |
| 240 | struct hpi_message *phm, struct hpi_response *phr) |
| 241 | { |
| 242 | |
| 243 | struct hpi_hw_obj *phw = pao->priv; |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 244 | u16 pending_cache_error = 0; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 245 | |
| 246 | switch (phm->function) { |
| 247 | case HPI_CONTROL_GET_STATE: |
| 248 | if (pao->has_control_cache) { |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 249 | rmb(); /* make sure we see updates DMAed from DSP */ |
| 250 | if (hpi_check_control_cache(phw->p_cache, phm, phr)) { |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 251 | break; |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 252 | } else if (phm->u.c.attribute == HPI_METER_PEAK) { |
| 253 | pending_cache_error = |
| 254 | HPI_ERROR_CONTROL_CACHING; |
| 255 | } |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 256 | } |
| 257 | hw_message(pao, phm, phr); |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 258 | if (pending_cache_error && !phr->error) |
| 259 | phr->error = pending_cache_error; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 260 | break; |
| 261 | case HPI_CONTROL_GET_INFO: |
| 262 | hw_message(pao, phm, phr); |
| 263 | break; |
| 264 | case HPI_CONTROL_SET_STATE: |
| 265 | hw_message(pao, phm, phr); |
| 266 | if (pao->has_control_cache) |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 267 | hpi_cmn_control_cache_sync_to_msg(phw->p_cache, phm, |
| 268 | phr); |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 269 | break; |
| 270 | default: |
| 271 | phr->error = HPI_ERROR_INVALID_FUNC; |
| 272 | break; |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | static void adapter_message(struct hpi_adapter_obj *pao, |
| 277 | struct hpi_message *phm, struct hpi_response *phr) |
| 278 | { |
| 279 | switch (phm->function) { |
Eliot Blennerhassett | 6d0b898 | 2011-04-05 20:55:47 +1200 | [diff] [blame] | 280 | case HPI_ADAPTER_DELETE: |
| 281 | adapter_delete(pao, phm, phr); |
| 282 | break; |
| 283 | |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 284 | default: |
| 285 | hw_message(pao, phm, phr); |
| 286 | break; |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | static void outstream_message(struct hpi_adapter_obj *pao, |
| 291 | struct hpi_message *phm, struct hpi_response *phr) |
| 292 | { |
| 293 | |
| 294 | if (phm->obj_index >= HPI_MAX_STREAMS) { |
Eliot Blennerhassett | deb21a2 | 2011-02-10 17:26:03 +1300 | [diff] [blame] | 295 | phr->error = HPI_ERROR_INVALID_OBJ_INDEX; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 296 | HPI_DEBUG_LOG(WARNING, |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 297 | "Message referencing invalid stream %d " |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 298 | "on adapter index %d\n", phm->obj_index, |
| 299 | phm->adapter_index); |
| 300 | return; |
| 301 | } |
| 302 | |
| 303 | switch (phm->function) { |
| 304 | case HPI_OSTREAM_WRITE: |
| 305 | outstream_write(pao, phm, phr); |
| 306 | break; |
| 307 | case HPI_OSTREAM_GET_INFO: |
| 308 | outstream_get_info(pao, phm, phr); |
| 309 | break; |
| 310 | case HPI_OSTREAM_HOSTBUFFER_ALLOC: |
| 311 | outstream_host_buffer_allocate(pao, phm, phr); |
| 312 | break; |
| 313 | case HPI_OSTREAM_HOSTBUFFER_GET_INFO: |
| 314 | outstream_host_buffer_get_info(pao, phm, phr); |
| 315 | break; |
| 316 | case HPI_OSTREAM_HOSTBUFFER_FREE: |
| 317 | outstream_host_buffer_free(pao, phm, phr); |
| 318 | break; |
| 319 | case HPI_OSTREAM_START: |
| 320 | outstream_start(pao, phm, phr); |
| 321 | break; |
| 322 | case HPI_OSTREAM_OPEN: |
| 323 | outstream_open(pao, phm, phr); |
| 324 | break; |
| 325 | case HPI_OSTREAM_RESET: |
| 326 | outstream_reset(pao, phm, phr); |
| 327 | break; |
| 328 | default: |
| 329 | hw_message(pao, phm, phr); |
| 330 | break; |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | static void instream_message(struct hpi_adapter_obj *pao, |
| 335 | struct hpi_message *phm, struct hpi_response *phr) |
| 336 | { |
| 337 | |
| 338 | if (phm->obj_index >= HPI_MAX_STREAMS) { |
Eliot Blennerhassett | deb21a2 | 2011-02-10 17:26:03 +1300 | [diff] [blame] | 339 | phr->error = HPI_ERROR_INVALID_OBJ_INDEX; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 340 | HPI_DEBUG_LOG(WARNING, |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 341 | "Message referencing invalid stream %d " |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 342 | "on adapter index %d\n", phm->obj_index, |
| 343 | phm->adapter_index); |
| 344 | return; |
| 345 | } |
| 346 | |
| 347 | switch (phm->function) { |
| 348 | case HPI_ISTREAM_READ: |
| 349 | instream_read(pao, phm, phr); |
| 350 | break; |
| 351 | case HPI_ISTREAM_GET_INFO: |
| 352 | instream_get_info(pao, phm, phr); |
| 353 | break; |
| 354 | case HPI_ISTREAM_HOSTBUFFER_ALLOC: |
| 355 | instream_host_buffer_allocate(pao, phm, phr); |
| 356 | break; |
| 357 | case HPI_ISTREAM_HOSTBUFFER_GET_INFO: |
| 358 | instream_host_buffer_get_info(pao, phm, phr); |
| 359 | break; |
| 360 | case HPI_ISTREAM_HOSTBUFFER_FREE: |
| 361 | instream_host_buffer_free(pao, phm, phr); |
| 362 | break; |
| 363 | case HPI_ISTREAM_START: |
| 364 | instream_start(pao, phm, phr); |
| 365 | break; |
| 366 | default: |
| 367 | hw_message(pao, phm, phr); |
| 368 | break; |
| 369 | } |
| 370 | } |
| 371 | |
| 372 | /*****************************************************************************/ |
| 373 | /** Entry point to this HPI backend |
| 374 | * All calls to the HPI start here |
| 375 | */ |
Eliot Blennerhassett | 6d0b898 | 2011-04-05 20:55:47 +1200 | [diff] [blame] | 376 | void _HPI_6205(struct hpi_adapter_obj *pao, struct hpi_message *phm, |
| 377 | struct hpi_response *phr) |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 378 | { |
Eliot Blennerhassett | 6d0b898 | 2011-04-05 20:55:47 +1200 | [diff] [blame] | 379 | if (pao && (pao->dsp_crashed >= 10) |
| 380 | && (phm->function != HPI_ADAPTER_DEBUG_READ)) { |
| 381 | /* allow last resort debug read even after crash */ |
| 382 | hpi_init_response(phr, phm->object, phm->function, |
| 383 | HPI_ERROR_DSP_HARDWARE); |
| 384 | HPI_DEBUG_LOG(WARNING, " %d,%d dsp crashed.\n", phm->object, |
| 385 | phm->function); |
| 386 | return; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 387 | } |
| 388 | |
| 389 | /* Init default response */ |
| 390 | if (phm->function != HPI_SUBSYS_CREATE_ADAPTER) |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 391 | phr->error = HPI_ERROR_PROCESSING_MESSAGE; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 392 | |
| 393 | HPI_DEBUG_LOG(VERBOSE, "start of switch\n"); |
| 394 | switch (phm->type) { |
Eliot Blennerhassett | 82b5774 | 2011-07-22 15:52:36 +1200 | [diff] [blame] | 395 | case HPI_TYPE_REQUEST: |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 396 | switch (phm->object) { |
| 397 | case HPI_OBJ_SUBSYSTEM: |
Eliot Blennerhassett | 6d0b898 | 2011-04-05 20:55:47 +1200 | [diff] [blame] | 398 | subsys_message(pao, phm, phr); |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 399 | break; |
| 400 | |
| 401 | case HPI_OBJ_ADAPTER: |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 402 | adapter_message(pao, phm, phr); |
| 403 | break; |
| 404 | |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 405 | case HPI_OBJ_CONTROL: |
| 406 | control_message(pao, phm, phr); |
| 407 | break; |
| 408 | |
| 409 | case HPI_OBJ_OSTREAM: |
| 410 | outstream_message(pao, phm, phr); |
| 411 | break; |
| 412 | |
| 413 | case HPI_OBJ_ISTREAM: |
| 414 | instream_message(pao, phm, phr); |
| 415 | break; |
| 416 | |
| 417 | default: |
| 418 | hw_message(pao, phm, phr); |
| 419 | break; |
| 420 | } |
| 421 | break; |
| 422 | |
| 423 | default: |
| 424 | phr->error = HPI_ERROR_INVALID_TYPE; |
| 425 | break; |
| 426 | } |
| 427 | } |
| 428 | |
Eliot Blennerhassett | 6d0b898 | 2011-04-05 20:55:47 +1200 | [diff] [blame] | 429 | void HPI_6205(struct hpi_message *phm, struct hpi_response *phr) |
| 430 | { |
| 431 | struct hpi_adapter_obj *pao = NULL; |
| 432 | |
| 433 | if (phm->object != HPI_OBJ_SUBSYSTEM) { |
| 434 | /* normal messages must have valid adapter index */ |
| 435 | pao = hpi_find_adapter(phm->adapter_index); |
| 436 | } else { |
| 437 | /* subsys messages don't address an adapter */ |
| 438 | _HPI_6205(NULL, phm, phr); |
| 439 | return; |
| 440 | } |
| 441 | |
| 442 | if (pao) |
| 443 | _HPI_6205(pao, phm, phr); |
| 444 | else |
| 445 | hpi_init_response(phr, phm->object, phm->function, |
| 446 | HPI_ERROR_BAD_ADAPTER_NUMBER); |
| 447 | } |
| 448 | |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 449 | /*****************************************************************************/ |
| 450 | /* SUBSYSTEM */ |
| 451 | |
| 452 | /** Create an adapter object and initialise it based on resource information |
| 453 | * passed in in the message |
| 454 | * *** NOTE - you cannot use this function AND the FindAdapters function at the |
| 455 | * same time, the application must use only one of them to get the adapters *** |
| 456 | */ |
| 457 | static void subsys_create_adapter(struct hpi_message *phm, |
| 458 | struct hpi_response *phr) |
| 459 | { |
| 460 | /* create temp adapter obj, because we don't know what index yet */ |
| 461 | struct hpi_adapter_obj ao; |
| 462 | u32 os_error_code; |
| 463 | u16 err; |
| 464 | |
| 465 | HPI_DEBUG_LOG(DEBUG, " subsys_create_adapter\n"); |
| 466 | |
| 467 | memset(&ao, 0, sizeof(ao)); |
| 468 | |
Julia Lawall | 550a8b6 | 2010-05-13 21:58:37 +0200 | [diff] [blame] | 469 | ao.priv = kzalloc(sizeof(struct hpi_hw_obj), GFP_KERNEL); |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 470 | if (!ao.priv) { |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 471 | HPI_DEBUG_LOG(ERROR, "can't get mem for adapter object\n"); |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 472 | phr->error = HPI_ERROR_MEMORY_ALLOC; |
| 473 | return; |
| 474 | } |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 475 | |
| 476 | ao.pci = *phm->u.s.resource.r.pci; |
| 477 | err = create_adapter_obj(&ao, &os_error_code); |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 478 | if (err) { |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 479 | delete_adapter_obj(&ao); |
Eliot Blennerhassett | 0a00044 | 2011-02-10 17:26:05 +1300 | [diff] [blame] | 480 | if (err >= HPI_ERROR_BACKEND_BASE) { |
| 481 | phr->error = HPI_ERROR_DSP_BOOTLOAD; |
| 482 | phr->specific_error = err; |
| 483 | } else { |
| 484 | phr->error = err; |
| 485 | } |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 486 | phr->u.s.data = os_error_code; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 487 | return; |
| 488 | } |
| 489 | |
Eliot Blennerhassett | 2f918a6 | 2011-02-10 17:26:09 +1300 | [diff] [blame] | 490 | phr->u.s.adapter_type = ao.adapter_type; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 491 | phr->u.s.adapter_index = ao.index; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 492 | phr->error = 0; |
| 493 | } |
| 494 | |
| 495 | /** delete an adapter - required by WDM driver */ |
Eliot Blennerhassett | 6d0b898 | 2011-04-05 20:55:47 +1200 | [diff] [blame] | 496 | static void adapter_delete(struct hpi_adapter_obj *pao, |
| 497 | struct hpi_message *phm, struct hpi_response *phr) |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 498 | { |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 499 | struct hpi_hw_obj *phw; |
| 500 | |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 501 | if (!pao) { |
| 502 | phr->error = HPI_ERROR_INVALID_OBJ_INDEX; |
| 503 | return; |
| 504 | } |
| 505 | phw = (struct hpi_hw_obj *)pao->priv; |
| 506 | /* reset adapter h/w */ |
| 507 | /* Reset C6713 #1 */ |
| 508 | boot_loader_write_mem32(pao, 0, C6205_BAR0_TIMER1_CTL, 0); |
| 509 | /* reset C6205 */ |
| 510 | iowrite32(C6205_HDCR_WARMRESET, phw->prHDCR); |
| 511 | |
| 512 | delete_adapter_obj(pao); |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 513 | hpi_delete_adapter(pao); |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 514 | phr->error = 0; |
| 515 | } |
| 516 | |
| 517 | /** Create adapter object |
| 518 | allocate buffers, bootload DSPs, initialise control cache |
| 519 | */ |
| 520 | static u16 create_adapter_obj(struct hpi_adapter_obj *pao, |
| 521 | u32 *pos_error_code) |
| 522 | { |
| 523 | struct hpi_hw_obj *phw = pao->priv; |
| 524 | struct bus_master_interface *interface; |
| 525 | u32 phys_addr; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 526 | int i; |
| 527 | u16 err; |
| 528 | |
| 529 | /* init error reporting */ |
| 530 | pao->dsp_crashed = 0; |
| 531 | |
| 532 | for (i = 0; i < HPI_MAX_STREAMS; i++) |
| 533 | phw->flag_outstream_just_reset[i] = 1; |
| 534 | |
| 535 | /* The C6205 memory area 1 is 8Mbyte window into DSP registers */ |
| 536 | phw->prHSR = |
| 537 | pao->pci.ap_mem_base[1] + |
| 538 | C6205_BAR1_HSR / sizeof(*pao->pci.ap_mem_base[1]); |
| 539 | phw->prHDCR = |
| 540 | pao->pci.ap_mem_base[1] + |
| 541 | C6205_BAR1_HDCR / sizeof(*pao->pci.ap_mem_base[1]); |
| 542 | phw->prDSPP = |
| 543 | pao->pci.ap_mem_base[1] + |
| 544 | C6205_BAR1_DSPP / sizeof(*pao->pci.ap_mem_base[1]); |
| 545 | |
| 546 | pao->has_control_cache = 0; |
| 547 | |
| 548 | if (hpios_locked_mem_alloc(&phw->h_locked_mem, |
| 549 | sizeof(struct bus_master_interface), |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 550 | pao->pci.pci_dev)) |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 551 | phw->p_interface_buffer = NULL; |
| 552 | else if (hpios_locked_mem_get_virt_addr(&phw->h_locked_mem, |
| 553 | (void *)&phw->p_interface_buffer)) |
| 554 | phw->p_interface_buffer = NULL; |
| 555 | |
| 556 | HPI_DEBUG_LOG(DEBUG, "interface buffer address %p\n", |
| 557 | phw->p_interface_buffer); |
| 558 | |
| 559 | if (phw->p_interface_buffer) { |
| 560 | memset((void *)phw->p_interface_buffer, 0, |
| 561 | sizeof(struct bus_master_interface)); |
| 562 | phw->p_interface_buffer->dsp_ack = H620_HIF_UNKNOWN; |
| 563 | } |
| 564 | |
| 565 | err = adapter_boot_load_dsp(pao, pos_error_code); |
Eliot Blennerhassett | 6d0b898 | 2011-04-05 20:55:47 +1200 | [diff] [blame] | 566 | if (err) { |
| 567 | HPI_DEBUG_LOG(ERROR, "DSP code load failed\n"); |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 568 | /* no need to clean up as SubSysCreateAdapter */ |
| 569 | /* calls DeleteAdapter on error. */ |
| 570 | return err; |
Eliot Blennerhassett | 6d0b898 | 2011-04-05 20:55:47 +1200 | [diff] [blame] | 571 | } |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 572 | HPI_DEBUG_LOG(INFO, "load DSP code OK\n"); |
| 573 | |
| 574 | /* allow boot load even if mem alloc wont work */ |
| 575 | if (!phw->p_interface_buffer) |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 576 | return HPI_ERROR_MEMORY_ALLOC; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 577 | |
| 578 | interface = phw->p_interface_buffer; |
| 579 | |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 580 | /* make sure the DSP has started ok */ |
| 581 | if (!wait_dsp_ack(phw, H620_HIF_RESET, HPI6205_TIMEOUT * 10)) { |
| 582 | HPI_DEBUG_LOG(ERROR, "timed out waiting reset state \n"); |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 583 | return HPI6205_ERROR_6205_INIT_FAILED; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 584 | } |
| 585 | /* Note that *pao, *phw are zeroed after allocation, |
| 586 | * so pointers and flags are NULL by default. |
| 587 | * Allocate bus mastering control cache buffer and tell the DSP about it |
| 588 | */ |
| 589 | if (interface->control_cache.number_of_controls) { |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 590 | u8 *p_control_cache_virtual; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 591 | |
| 592 | err = hpios_locked_mem_alloc(&phw->h_control_cache, |
| 593 | interface->control_cache.size_in_bytes, |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 594 | pao->pci.pci_dev); |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 595 | if (!err) |
| 596 | err = hpios_locked_mem_get_virt_addr(&phw-> |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 597 | h_control_cache, |
| 598 | (void *)&p_control_cache_virtual); |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 599 | if (!err) { |
| 600 | memset(p_control_cache_virtual, 0, |
| 601 | interface->control_cache.size_in_bytes); |
| 602 | |
| 603 | phw->p_cache = |
| 604 | hpi_alloc_control_cache(interface-> |
| 605 | control_cache.number_of_controls, |
| 606 | interface->control_cache.size_in_bytes, |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 607 | p_control_cache_virtual); |
Eliot Blennerhassett | 6d0b898 | 2011-04-05 20:55:47 +1200 | [diff] [blame] | 608 | |
Jesper Juhl | fd0977d | 2010-10-29 21:35:25 +0200 | [diff] [blame] | 609 | if (!phw->p_cache) |
| 610 | err = HPI_ERROR_MEMORY_ALLOC; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 611 | } |
| 612 | if (!err) { |
| 613 | err = hpios_locked_mem_get_phys_addr(&phw-> |
| 614 | h_control_cache, &phys_addr); |
| 615 | interface->control_cache.physical_address32 = |
| 616 | phys_addr; |
| 617 | } |
| 618 | |
| 619 | if (!err) |
| 620 | pao->has_control_cache = 1; |
| 621 | else { |
| 622 | if (hpios_locked_mem_valid(&phw->h_control_cache)) |
| 623 | hpios_locked_mem_free(&phw->h_control_cache); |
| 624 | pao->has_control_cache = 0; |
| 625 | } |
| 626 | } |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 627 | send_dsp_command(phw, H620_HIF_IDLE); |
| 628 | |
| 629 | { |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 630 | struct hpi_message hm; |
| 631 | struct hpi_response hr; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 632 | u32 max_streams; |
| 633 | |
| 634 | HPI_DEBUG_LOG(VERBOSE, "init ADAPTER_GET_INFO\n"); |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 635 | memset(&hm, 0, sizeof(hm)); |
Eliot Blennerhassett | 82b5774 | 2011-07-22 15:52:36 +1200 | [diff] [blame] | 636 | /* wAdapterIndex == version == 0 */ |
| 637 | hm.type = HPI_TYPE_REQUEST; |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 638 | hm.size = sizeof(hm); |
| 639 | hm.object = HPI_OBJ_ADAPTER; |
| 640 | hm.function = HPI_ADAPTER_GET_INFO; |
Eliot Blennerhassett | 82b5774 | 2011-07-22 15:52:36 +1200 | [diff] [blame] | 641 | |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 642 | memset(&hr, 0, sizeof(hr)); |
| 643 | hr.size = sizeof(hr); |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 644 | |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 645 | err = message_response_sequence(pao, &hm, &hr); |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 646 | if (err) { |
| 647 | HPI_DEBUG_LOG(ERROR, "message transport error %d\n", |
| 648 | err); |
| 649 | return err; |
| 650 | } |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 651 | if (hr.error) |
| 652 | return hr.error; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 653 | |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 654 | pao->adapter_type = hr.u.ax.info.adapter_type; |
| 655 | pao->index = hr.u.ax.info.adapter_index; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 656 | |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 657 | max_streams = |
| 658 | hr.u.ax.info.num_outstreams + |
| 659 | hr.u.ax.info.num_instreams; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 660 | |
| 661 | hpios_locked_mem_prepare((max_streams * 6) / 10, max_streams, |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 662 | 65536, pao->pci.pci_dev); |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 663 | |
| 664 | HPI_DEBUG_LOG(VERBOSE, |
| 665 | "got adapter info type %x index %d serial %d\n", |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 666 | hr.u.ax.info.adapter_type, hr.u.ax.info.adapter_index, |
| 667 | hr.u.ax.info.serial_number); |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 668 | } |
| 669 | |
| 670 | pao->open = 0; /* upon creation the adapter is closed */ |
| 671 | |
Eliot Blennerhassett | ffdb578 | 2011-02-10 17:26:00 +1300 | [diff] [blame] | 672 | if (phw->p_cache) |
| 673 | phw->p_cache->adap_idx = pao->index; |
| 674 | |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 675 | HPI_DEBUG_LOG(INFO, "bootload DSP OK\n"); |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 676 | |
| 677 | return hpi_add_adapter(pao); |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 678 | } |
| 679 | |
| 680 | /** Free memory areas allocated by adapter |
Eliot Blennerhassett | 6d0b898 | 2011-04-05 20:55:47 +1200 | [diff] [blame] | 681 | * this routine is called from AdapterDelete, |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 682 | * and SubSysCreateAdapter if duplicate index |
| 683 | */ |
| 684 | static void delete_adapter_obj(struct hpi_adapter_obj *pao) |
| 685 | { |
Eliot Blennerhassett | 6d0b898 | 2011-04-05 20:55:47 +1200 | [diff] [blame] | 686 | struct hpi_hw_obj *phw = pao->priv; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 687 | int i; |
| 688 | |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 689 | if (hpios_locked_mem_valid(&phw->h_control_cache)) { |
| 690 | hpios_locked_mem_free(&phw->h_control_cache); |
| 691 | hpi_free_control_cache(phw->p_cache); |
| 692 | } |
| 693 | |
| 694 | if (hpios_locked_mem_valid(&phw->h_locked_mem)) { |
| 695 | hpios_locked_mem_free(&phw->h_locked_mem); |
| 696 | phw->p_interface_buffer = NULL; |
| 697 | } |
| 698 | |
| 699 | for (i = 0; i < HPI_MAX_STREAMS; i++) |
| 700 | if (hpios_locked_mem_valid(&phw->instream_host_buffers[i])) { |
| 701 | hpios_locked_mem_free(&phw->instream_host_buffers[i]); |
| 702 | /*?phw->InStreamHostBuffers[i] = NULL; */ |
| 703 | phw->instream_host_buffer_size[i] = 0; |
| 704 | } |
| 705 | |
| 706 | for (i = 0; i < HPI_MAX_STREAMS; i++) |
| 707 | if (hpios_locked_mem_valid(&phw->outstream_host_buffers[i])) { |
| 708 | hpios_locked_mem_free(&phw->outstream_host_buffers |
| 709 | [i]); |
| 710 | phw->outstream_host_buffer_size[i] = 0; |
| 711 | } |
| 712 | |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 713 | hpios_locked_mem_unprepare(pao->pci.pci_dev); |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 714 | |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 715 | kfree(phw); |
| 716 | } |
| 717 | |
| 718 | /*****************************************************************************/ |
Eliot Blennerhassett | 1d595d2 | 2011-02-10 17:26:08 +1300 | [diff] [blame] | 719 | /* Adapter functions */ |
| 720 | |
| 721 | /*****************************************************************************/ |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 722 | /* OutStream Host buffer functions */ |
| 723 | |
| 724 | /** Allocate or attach buffer for busmastering |
| 725 | */ |
| 726 | static void outstream_host_buffer_allocate(struct hpi_adapter_obj *pao, |
| 727 | struct hpi_message *phm, struct hpi_response *phr) |
| 728 | { |
| 729 | u16 err = 0; |
| 730 | u32 command = phm->u.d.u.buffer.command; |
| 731 | struct hpi_hw_obj *phw = pao->priv; |
| 732 | struct bus_master_interface *interface = phw->p_interface_buffer; |
| 733 | |
| 734 | hpi_init_response(phr, phm->object, phm->function, 0); |
| 735 | |
| 736 | if (command == HPI_BUFFER_CMD_EXTERNAL |
| 737 | || command == HPI_BUFFER_CMD_INTERNAL_ALLOC) { |
| 738 | /* ALLOC phase, allocate a buffer with power of 2 size, |
| 739 | get its bus address for PCI bus mastering |
| 740 | */ |
| 741 | phm->u.d.u.buffer.buffer_size = |
| 742 | roundup_pow_of_two(phm->u.d.u.buffer.buffer_size); |
| 743 | /* return old size and allocated size, |
| 744 | so caller can detect change */ |
| 745 | phr->u.d.u.stream_info.data_available = |
| 746 | phw->outstream_host_buffer_size[phm->obj_index]; |
| 747 | phr->u.d.u.stream_info.buffer_size = |
| 748 | phm->u.d.u.buffer.buffer_size; |
| 749 | |
| 750 | if (phw->outstream_host_buffer_size[phm->obj_index] == |
| 751 | phm->u.d.u.buffer.buffer_size) { |
| 752 | /* Same size, no action required */ |
| 753 | return; |
| 754 | } |
| 755 | |
| 756 | if (hpios_locked_mem_valid(&phw->outstream_host_buffers[phm-> |
| 757 | obj_index])) |
| 758 | hpios_locked_mem_free(&phw->outstream_host_buffers |
| 759 | [phm->obj_index]); |
| 760 | |
| 761 | err = hpios_locked_mem_alloc(&phw->outstream_host_buffers |
| 762 | [phm->obj_index], phm->u.d.u.buffer.buffer_size, |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 763 | pao->pci.pci_dev); |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 764 | |
| 765 | if (err) { |
| 766 | phr->error = HPI_ERROR_INVALID_DATASIZE; |
| 767 | phw->outstream_host_buffer_size[phm->obj_index] = 0; |
| 768 | return; |
| 769 | } |
| 770 | |
| 771 | err = hpios_locked_mem_get_phys_addr |
| 772 | (&phw->outstream_host_buffers[phm->obj_index], |
| 773 | &phm->u.d.u.buffer.pci_address); |
| 774 | /* get the phys addr into msg for single call alloc caller |
| 775 | * needs to do this for split alloc (or use the same message) |
| 776 | * return the phy address for split alloc in the respose too |
| 777 | */ |
| 778 | phr->u.d.u.stream_info.auxiliary_data_available = |
| 779 | phm->u.d.u.buffer.pci_address; |
| 780 | |
| 781 | if (err) { |
| 782 | hpios_locked_mem_free(&phw->outstream_host_buffers |
| 783 | [phm->obj_index]); |
| 784 | phw->outstream_host_buffer_size[phm->obj_index] = 0; |
| 785 | phr->error = HPI_ERROR_MEMORY_ALLOC; |
| 786 | return; |
| 787 | } |
| 788 | } |
| 789 | |
| 790 | if (command == HPI_BUFFER_CMD_EXTERNAL |
| 791 | || command == HPI_BUFFER_CMD_INTERNAL_GRANTADAPTER) { |
| 792 | /* GRANT phase. Set up the BBM status, tell the DSP about |
| 793 | the buffer so it can start using BBM. |
| 794 | */ |
| 795 | struct hpi_hostbuffer_status *status; |
| 796 | |
| 797 | if (phm->u.d.u.buffer.buffer_size & (phm->u.d.u.buffer. |
| 798 | buffer_size - 1)) { |
| 799 | HPI_DEBUG_LOG(ERROR, |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 800 | "Buffer size must be 2^N not %d\n", |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 801 | phm->u.d.u.buffer.buffer_size); |
| 802 | phr->error = HPI_ERROR_INVALID_DATASIZE; |
| 803 | return; |
| 804 | } |
| 805 | phw->outstream_host_buffer_size[phm->obj_index] = |
| 806 | phm->u.d.u.buffer.buffer_size; |
| 807 | status = &interface->outstream_host_buffer_status[phm-> |
| 808 | obj_index]; |
| 809 | status->samples_processed = 0; |
| 810 | status->stream_state = HPI_STATE_STOPPED; |
| 811 | status->dSP_index = 0; |
| 812 | status->host_index = status->dSP_index; |
| 813 | status->size_in_bytes = phm->u.d.u.buffer.buffer_size; |
Eliot Blennerhassett | deb21a2 | 2011-02-10 17:26:03 +1300 | [diff] [blame] | 814 | status->auxiliary_data_available = 0; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 815 | |
| 816 | hw_message(pao, phm, phr); |
| 817 | |
| 818 | if (phr->error |
| 819 | && hpios_locked_mem_valid(&phw-> |
| 820 | outstream_host_buffers[phm->obj_index])) { |
| 821 | hpios_locked_mem_free(&phw->outstream_host_buffers |
| 822 | [phm->obj_index]); |
| 823 | phw->outstream_host_buffer_size[phm->obj_index] = 0; |
| 824 | } |
| 825 | } |
| 826 | } |
| 827 | |
| 828 | static void outstream_host_buffer_get_info(struct hpi_adapter_obj *pao, |
| 829 | struct hpi_message *phm, struct hpi_response *phr) |
| 830 | { |
| 831 | struct hpi_hw_obj *phw = pao->priv; |
| 832 | struct bus_master_interface *interface = phw->p_interface_buffer; |
| 833 | struct hpi_hostbuffer_status *status; |
| 834 | u8 *p_bbm_data; |
| 835 | |
| 836 | if (hpios_locked_mem_valid(&phw->outstream_host_buffers[phm-> |
| 837 | obj_index])) { |
| 838 | if (hpios_locked_mem_get_virt_addr(&phw-> |
| 839 | outstream_host_buffers[phm->obj_index], |
| 840 | (void *)&p_bbm_data)) { |
| 841 | phr->error = HPI_ERROR_INVALID_OPERATION; |
| 842 | return; |
| 843 | } |
| 844 | status = &interface->outstream_host_buffer_status[phm-> |
| 845 | obj_index]; |
| 846 | hpi_init_response(phr, HPI_OBJ_OSTREAM, |
| 847 | HPI_OSTREAM_HOSTBUFFER_GET_INFO, 0); |
| 848 | phr->u.d.u.hostbuffer_info.p_buffer = p_bbm_data; |
| 849 | phr->u.d.u.hostbuffer_info.p_status = status; |
| 850 | } else { |
| 851 | hpi_init_response(phr, HPI_OBJ_OSTREAM, |
| 852 | HPI_OSTREAM_HOSTBUFFER_GET_INFO, |
| 853 | HPI_ERROR_INVALID_OPERATION); |
| 854 | } |
| 855 | } |
| 856 | |
| 857 | static void outstream_host_buffer_free(struct hpi_adapter_obj *pao, |
| 858 | struct hpi_message *phm, struct hpi_response *phr) |
| 859 | { |
| 860 | struct hpi_hw_obj *phw = pao->priv; |
| 861 | u32 command = phm->u.d.u.buffer.command; |
| 862 | |
| 863 | if (phw->outstream_host_buffer_size[phm->obj_index]) { |
| 864 | if (command == HPI_BUFFER_CMD_EXTERNAL |
| 865 | || command == HPI_BUFFER_CMD_INTERNAL_REVOKEADAPTER) { |
| 866 | phw->outstream_host_buffer_size[phm->obj_index] = 0; |
| 867 | hw_message(pao, phm, phr); |
| 868 | /* Tell adapter to stop using the host buffer. */ |
| 869 | } |
| 870 | if (command == HPI_BUFFER_CMD_EXTERNAL |
| 871 | || command == HPI_BUFFER_CMD_INTERNAL_FREE) |
| 872 | hpios_locked_mem_free(&phw->outstream_host_buffers |
| 873 | [phm->obj_index]); |
| 874 | } |
| 875 | /* Should HPI_ERROR_INVALID_OPERATION be returned |
| 876 | if no host buffer is allocated? */ |
| 877 | else |
| 878 | hpi_init_response(phr, HPI_OBJ_OSTREAM, |
| 879 | HPI_OSTREAM_HOSTBUFFER_FREE, 0); |
| 880 | |
| 881 | } |
| 882 | |
Eliot Blennerhassett | 60f1deb | 2010-08-28 19:52:24 +1200 | [diff] [blame] | 883 | static u32 outstream_get_space_available(struct hpi_hostbuffer_status *status) |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 884 | { |
Eliot Blennerhassett | 2a383cb | 2010-06-17 17:08:36 +1200 | [diff] [blame] | 885 | return status->size_in_bytes - (status->host_index - |
| 886 | status->dSP_index); |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 887 | } |
| 888 | |
| 889 | static void outstream_write(struct hpi_adapter_obj *pao, |
| 890 | struct hpi_message *phm, struct hpi_response *phr) |
| 891 | { |
| 892 | struct hpi_hw_obj *phw = pao->priv; |
| 893 | struct bus_master_interface *interface = phw->p_interface_buffer; |
| 894 | struct hpi_hostbuffer_status *status; |
Eliot Blennerhassett | 2a383cb | 2010-06-17 17:08:36 +1200 | [diff] [blame] | 895 | u32 space_available; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 896 | |
| 897 | if (!phw->outstream_host_buffer_size[phm->obj_index]) { |
| 898 | /* there is no BBM buffer, write via message */ |
| 899 | hw_message(pao, phm, phr); |
| 900 | return; |
| 901 | } |
| 902 | |
| 903 | hpi_init_response(phr, phm->object, phm->function, 0); |
| 904 | status = &interface->outstream_host_buffer_status[phm->obj_index]; |
| 905 | |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 906 | space_available = outstream_get_space_available(status); |
Eliot Blennerhassett | 2a383cb | 2010-06-17 17:08:36 +1200 | [diff] [blame] | 907 | if (space_available < phm->u.d.u.data.data_size) { |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 908 | phr->error = HPI_ERROR_INVALID_DATASIZE; |
| 909 | return; |
| 910 | } |
| 911 | |
| 912 | /* HostBuffers is used to indicate host buffer is internally allocated. |
| 913 | otherwise, assumed external, data written externally */ |
| 914 | if (phm->u.d.u.data.pb_data |
| 915 | && hpios_locked_mem_valid(&phw->outstream_host_buffers[phm-> |
| 916 | obj_index])) { |
| 917 | u8 *p_bbm_data; |
Eliot Blennerhassett | 2a383cb | 2010-06-17 17:08:36 +1200 | [diff] [blame] | 918 | u32 l_first_write; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 919 | u8 *p_app_data = (u8 *)phm->u.d.u.data.pb_data; |
| 920 | |
| 921 | if (hpios_locked_mem_get_virt_addr(&phw-> |
| 922 | outstream_host_buffers[phm->obj_index], |
| 923 | (void *)&p_bbm_data)) { |
| 924 | phr->error = HPI_ERROR_INVALID_OPERATION; |
| 925 | return; |
| 926 | } |
| 927 | |
| 928 | /* either all data, |
| 929 | or enough to fit from current to end of BBM buffer */ |
| 930 | l_first_write = |
| 931 | min(phm->u.d.u.data.data_size, |
| 932 | status->size_in_bytes - |
| 933 | (status->host_index & (status->size_in_bytes - 1))); |
| 934 | |
| 935 | memcpy(p_bbm_data + |
| 936 | (status->host_index & (status->size_in_bytes - 1)), |
| 937 | p_app_data, l_first_write); |
| 938 | /* remaining data if any */ |
| 939 | memcpy(p_bbm_data, p_app_data + l_first_write, |
| 940 | phm->u.d.u.data.data_size - l_first_write); |
| 941 | } |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 942 | |
| 943 | /* |
| 944 | * This version relies on the DSP code triggering an OStream buffer |
| 945 | * update immediately following a SET_FORMAT call. The host has |
Eliot Blennerhassett | deb21a2 | 2011-02-10 17:26:03 +1300 | [diff] [blame] | 946 | * already written data into the BBM buffer, but the DSP won't know |
| 947 | * about it until dwHostIndex is adjusted. |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 948 | */ |
| 949 | if (phw->flag_outstream_just_reset[phm->obj_index]) { |
| 950 | /* Format can only change after reset. Must tell DSP. */ |
| 951 | u16 function = phm->function; |
| 952 | phw->flag_outstream_just_reset[phm->obj_index] = 0; |
| 953 | phm->function = HPI_OSTREAM_SET_FORMAT; |
| 954 | hw_message(pao, phm, phr); /* send the format to the DSP */ |
| 955 | phm->function = function; |
| 956 | if (phr->error) |
| 957 | return; |
| 958 | } |
| 959 | |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 960 | status->host_index += phm->u.d.u.data.data_size; |
| 961 | } |
| 962 | |
| 963 | static void outstream_get_info(struct hpi_adapter_obj *pao, |
| 964 | struct hpi_message *phm, struct hpi_response *phr) |
| 965 | { |
| 966 | struct hpi_hw_obj *phw = pao->priv; |
| 967 | struct bus_master_interface *interface = phw->p_interface_buffer; |
| 968 | struct hpi_hostbuffer_status *status; |
| 969 | |
| 970 | if (!phw->outstream_host_buffer_size[phm->obj_index]) { |
| 971 | hw_message(pao, phm, phr); |
| 972 | return; |
| 973 | } |
| 974 | |
| 975 | hpi_init_response(phr, phm->object, phm->function, 0); |
| 976 | |
| 977 | status = &interface->outstream_host_buffer_status[phm->obj_index]; |
| 978 | |
| 979 | phr->u.d.u.stream_info.state = (u16)status->stream_state; |
| 980 | phr->u.d.u.stream_info.samples_transferred = |
| 981 | status->samples_processed; |
| 982 | phr->u.d.u.stream_info.buffer_size = status->size_in_bytes; |
| 983 | phr->u.d.u.stream_info.data_available = |
| 984 | status->size_in_bytes - outstream_get_space_available(status); |
| 985 | phr->u.d.u.stream_info.auxiliary_data_available = |
| 986 | status->auxiliary_data_available; |
| 987 | } |
| 988 | |
| 989 | static void outstream_start(struct hpi_adapter_obj *pao, |
| 990 | struct hpi_message *phm, struct hpi_response *phr) |
| 991 | { |
| 992 | hw_message(pao, phm, phr); |
| 993 | } |
| 994 | |
| 995 | static void outstream_reset(struct hpi_adapter_obj *pao, |
| 996 | struct hpi_message *phm, struct hpi_response *phr) |
| 997 | { |
| 998 | struct hpi_hw_obj *phw = pao->priv; |
| 999 | phw->flag_outstream_just_reset[phm->obj_index] = 1; |
| 1000 | hw_message(pao, phm, phr); |
| 1001 | } |
| 1002 | |
| 1003 | static void outstream_open(struct hpi_adapter_obj *pao, |
| 1004 | struct hpi_message *phm, struct hpi_response *phr) |
| 1005 | { |
| 1006 | outstream_reset(pao, phm, phr); |
| 1007 | } |
| 1008 | |
| 1009 | /*****************************************************************************/ |
| 1010 | /* InStream Host buffer functions */ |
| 1011 | |
| 1012 | static void instream_host_buffer_allocate(struct hpi_adapter_obj *pao, |
| 1013 | struct hpi_message *phm, struct hpi_response *phr) |
| 1014 | { |
| 1015 | u16 err = 0; |
| 1016 | u32 command = phm->u.d.u.buffer.command; |
| 1017 | struct hpi_hw_obj *phw = pao->priv; |
| 1018 | struct bus_master_interface *interface = phw->p_interface_buffer; |
| 1019 | |
| 1020 | hpi_init_response(phr, phm->object, phm->function, 0); |
| 1021 | |
| 1022 | if (command == HPI_BUFFER_CMD_EXTERNAL |
| 1023 | || command == HPI_BUFFER_CMD_INTERNAL_ALLOC) { |
| 1024 | |
| 1025 | phm->u.d.u.buffer.buffer_size = |
| 1026 | roundup_pow_of_two(phm->u.d.u.buffer.buffer_size); |
| 1027 | phr->u.d.u.stream_info.data_available = |
| 1028 | phw->instream_host_buffer_size[phm->obj_index]; |
| 1029 | phr->u.d.u.stream_info.buffer_size = |
| 1030 | phm->u.d.u.buffer.buffer_size; |
| 1031 | |
| 1032 | if (phw->instream_host_buffer_size[phm->obj_index] == |
| 1033 | phm->u.d.u.buffer.buffer_size) { |
| 1034 | /* Same size, no action required */ |
| 1035 | return; |
| 1036 | } |
| 1037 | |
| 1038 | if (hpios_locked_mem_valid(&phw->instream_host_buffers[phm-> |
| 1039 | obj_index])) |
| 1040 | hpios_locked_mem_free(&phw->instream_host_buffers |
| 1041 | [phm->obj_index]); |
| 1042 | |
| 1043 | err = hpios_locked_mem_alloc(&phw->instream_host_buffers[phm-> |
| 1044 | obj_index], phm->u.d.u.buffer.buffer_size, |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 1045 | pao->pci.pci_dev); |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1046 | |
| 1047 | if (err) { |
| 1048 | phr->error = HPI_ERROR_INVALID_DATASIZE; |
| 1049 | phw->instream_host_buffer_size[phm->obj_index] = 0; |
| 1050 | return; |
| 1051 | } |
| 1052 | |
| 1053 | err = hpios_locked_mem_get_phys_addr |
| 1054 | (&phw->instream_host_buffers[phm->obj_index], |
| 1055 | &phm->u.d.u.buffer.pci_address); |
| 1056 | /* get the phys addr into msg for single call alloc. Caller |
| 1057 | needs to do this for split alloc so return the phy address */ |
| 1058 | phr->u.d.u.stream_info.auxiliary_data_available = |
| 1059 | phm->u.d.u.buffer.pci_address; |
| 1060 | if (err) { |
| 1061 | hpios_locked_mem_free(&phw->instream_host_buffers |
| 1062 | [phm->obj_index]); |
| 1063 | phw->instream_host_buffer_size[phm->obj_index] = 0; |
| 1064 | phr->error = HPI_ERROR_MEMORY_ALLOC; |
| 1065 | return; |
| 1066 | } |
| 1067 | } |
| 1068 | |
| 1069 | if (command == HPI_BUFFER_CMD_EXTERNAL |
| 1070 | || command == HPI_BUFFER_CMD_INTERNAL_GRANTADAPTER) { |
| 1071 | struct hpi_hostbuffer_status *status; |
| 1072 | |
| 1073 | if (phm->u.d.u.buffer.buffer_size & (phm->u.d.u.buffer. |
| 1074 | buffer_size - 1)) { |
| 1075 | HPI_DEBUG_LOG(ERROR, |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 1076 | "Buffer size must be 2^N not %d\n", |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1077 | phm->u.d.u.buffer.buffer_size); |
| 1078 | phr->error = HPI_ERROR_INVALID_DATASIZE; |
| 1079 | return; |
| 1080 | } |
| 1081 | |
| 1082 | phw->instream_host_buffer_size[phm->obj_index] = |
| 1083 | phm->u.d.u.buffer.buffer_size; |
| 1084 | status = &interface->instream_host_buffer_status[phm-> |
| 1085 | obj_index]; |
| 1086 | status->samples_processed = 0; |
| 1087 | status->stream_state = HPI_STATE_STOPPED; |
| 1088 | status->dSP_index = 0; |
| 1089 | status->host_index = status->dSP_index; |
| 1090 | status->size_in_bytes = phm->u.d.u.buffer.buffer_size; |
Eliot Blennerhassett | deb21a2 | 2011-02-10 17:26:03 +1300 | [diff] [blame] | 1091 | status->auxiliary_data_available = 0; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1092 | |
| 1093 | hw_message(pao, phm, phr); |
Eliot Blennerhassett | ba3a909 | 2011-02-10 17:26:14 +1300 | [diff] [blame] | 1094 | |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1095 | if (phr->error |
| 1096 | && hpios_locked_mem_valid(&phw-> |
| 1097 | instream_host_buffers[phm->obj_index])) { |
| 1098 | hpios_locked_mem_free(&phw->instream_host_buffers |
| 1099 | [phm->obj_index]); |
| 1100 | phw->instream_host_buffer_size[phm->obj_index] = 0; |
| 1101 | } |
| 1102 | } |
| 1103 | } |
| 1104 | |
| 1105 | static void instream_host_buffer_get_info(struct hpi_adapter_obj *pao, |
| 1106 | struct hpi_message *phm, struct hpi_response *phr) |
| 1107 | { |
| 1108 | struct hpi_hw_obj *phw = pao->priv; |
| 1109 | struct bus_master_interface *interface = phw->p_interface_buffer; |
| 1110 | struct hpi_hostbuffer_status *status; |
| 1111 | u8 *p_bbm_data; |
| 1112 | |
| 1113 | if (hpios_locked_mem_valid(&phw->instream_host_buffers[phm-> |
| 1114 | obj_index])) { |
| 1115 | if (hpios_locked_mem_get_virt_addr(&phw-> |
| 1116 | instream_host_buffers[phm->obj_index], |
| 1117 | (void *)&p_bbm_data)) { |
| 1118 | phr->error = HPI_ERROR_INVALID_OPERATION; |
| 1119 | return; |
| 1120 | } |
| 1121 | status = &interface->instream_host_buffer_status[phm-> |
| 1122 | obj_index]; |
| 1123 | hpi_init_response(phr, HPI_OBJ_ISTREAM, |
| 1124 | HPI_ISTREAM_HOSTBUFFER_GET_INFO, 0); |
| 1125 | phr->u.d.u.hostbuffer_info.p_buffer = p_bbm_data; |
| 1126 | phr->u.d.u.hostbuffer_info.p_status = status; |
| 1127 | } else { |
| 1128 | hpi_init_response(phr, HPI_OBJ_ISTREAM, |
| 1129 | HPI_ISTREAM_HOSTBUFFER_GET_INFO, |
| 1130 | HPI_ERROR_INVALID_OPERATION); |
| 1131 | } |
| 1132 | } |
| 1133 | |
| 1134 | static void instream_host_buffer_free(struct hpi_adapter_obj *pao, |
| 1135 | struct hpi_message *phm, struct hpi_response *phr) |
| 1136 | { |
| 1137 | struct hpi_hw_obj *phw = pao->priv; |
| 1138 | u32 command = phm->u.d.u.buffer.command; |
| 1139 | |
| 1140 | if (phw->instream_host_buffer_size[phm->obj_index]) { |
| 1141 | if (command == HPI_BUFFER_CMD_EXTERNAL |
| 1142 | || command == HPI_BUFFER_CMD_INTERNAL_REVOKEADAPTER) { |
| 1143 | phw->instream_host_buffer_size[phm->obj_index] = 0; |
| 1144 | hw_message(pao, phm, phr); |
| 1145 | } |
| 1146 | |
| 1147 | if (command == HPI_BUFFER_CMD_EXTERNAL |
| 1148 | || command == HPI_BUFFER_CMD_INTERNAL_FREE) |
| 1149 | hpios_locked_mem_free(&phw->instream_host_buffers |
| 1150 | [phm->obj_index]); |
| 1151 | |
| 1152 | } else { |
| 1153 | /* Should HPI_ERROR_INVALID_OPERATION be returned |
| 1154 | if no host buffer is allocated? */ |
| 1155 | hpi_init_response(phr, HPI_OBJ_ISTREAM, |
| 1156 | HPI_ISTREAM_HOSTBUFFER_FREE, 0); |
| 1157 | |
| 1158 | } |
| 1159 | |
| 1160 | } |
| 1161 | |
| 1162 | static void instream_start(struct hpi_adapter_obj *pao, |
| 1163 | struct hpi_message *phm, struct hpi_response *phr) |
| 1164 | { |
| 1165 | hw_message(pao, phm, phr); |
| 1166 | } |
| 1167 | |
Eliot Blennerhassett | 2a383cb | 2010-06-17 17:08:36 +1200 | [diff] [blame] | 1168 | static u32 instream_get_bytes_available(struct hpi_hostbuffer_status *status) |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1169 | { |
Eliot Blennerhassett | 2a383cb | 2010-06-17 17:08:36 +1200 | [diff] [blame] | 1170 | return status->dSP_index - status->host_index; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1171 | } |
| 1172 | |
| 1173 | static void instream_read(struct hpi_adapter_obj *pao, |
| 1174 | struct hpi_message *phm, struct hpi_response *phr) |
| 1175 | { |
| 1176 | struct hpi_hw_obj *phw = pao->priv; |
| 1177 | struct bus_master_interface *interface = phw->p_interface_buffer; |
| 1178 | struct hpi_hostbuffer_status *status; |
Eliot Blennerhassett | 2a383cb | 2010-06-17 17:08:36 +1200 | [diff] [blame] | 1179 | u32 data_available; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1180 | u8 *p_bbm_data; |
Eliot Blennerhassett | 2a383cb | 2010-06-17 17:08:36 +1200 | [diff] [blame] | 1181 | u32 l_first_read; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1182 | u8 *p_app_data = (u8 *)phm->u.d.u.data.pb_data; |
| 1183 | |
| 1184 | if (!phw->instream_host_buffer_size[phm->obj_index]) { |
| 1185 | hw_message(pao, phm, phr); |
| 1186 | return; |
| 1187 | } |
| 1188 | hpi_init_response(phr, phm->object, phm->function, 0); |
| 1189 | |
| 1190 | status = &interface->instream_host_buffer_status[phm->obj_index]; |
| 1191 | data_available = instream_get_bytes_available(status); |
Eliot Blennerhassett | 2a383cb | 2010-06-17 17:08:36 +1200 | [diff] [blame] | 1192 | if (data_available < phm->u.d.u.data.data_size) { |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1193 | phr->error = HPI_ERROR_INVALID_DATASIZE; |
| 1194 | return; |
| 1195 | } |
| 1196 | |
| 1197 | if (hpios_locked_mem_valid(&phw->instream_host_buffers[phm-> |
| 1198 | obj_index])) { |
| 1199 | if (hpios_locked_mem_get_virt_addr(&phw-> |
| 1200 | instream_host_buffers[phm->obj_index], |
| 1201 | (void *)&p_bbm_data)) { |
| 1202 | phr->error = HPI_ERROR_INVALID_OPERATION; |
| 1203 | return; |
| 1204 | } |
| 1205 | |
| 1206 | /* either all data, |
| 1207 | or enough to fit from current to end of BBM buffer */ |
| 1208 | l_first_read = |
| 1209 | min(phm->u.d.u.data.data_size, |
| 1210 | status->size_in_bytes - |
| 1211 | (status->host_index & (status->size_in_bytes - 1))); |
| 1212 | |
| 1213 | memcpy(p_app_data, |
| 1214 | p_bbm_data + |
| 1215 | (status->host_index & (status->size_in_bytes - 1)), |
| 1216 | l_first_read); |
| 1217 | /* remaining data if any */ |
| 1218 | memcpy(p_app_data + l_first_read, p_bbm_data, |
| 1219 | phm->u.d.u.data.data_size - l_first_read); |
| 1220 | } |
| 1221 | status->host_index += phm->u.d.u.data.data_size; |
| 1222 | } |
| 1223 | |
| 1224 | static void instream_get_info(struct hpi_adapter_obj *pao, |
| 1225 | struct hpi_message *phm, struct hpi_response *phr) |
| 1226 | { |
| 1227 | struct hpi_hw_obj *phw = pao->priv; |
| 1228 | struct bus_master_interface *interface = phw->p_interface_buffer; |
| 1229 | struct hpi_hostbuffer_status *status; |
| 1230 | if (!phw->instream_host_buffer_size[phm->obj_index]) { |
| 1231 | hw_message(pao, phm, phr); |
| 1232 | return; |
| 1233 | } |
| 1234 | |
| 1235 | status = &interface->instream_host_buffer_status[phm->obj_index]; |
| 1236 | |
| 1237 | hpi_init_response(phr, phm->object, phm->function, 0); |
| 1238 | |
| 1239 | phr->u.d.u.stream_info.state = (u16)status->stream_state; |
| 1240 | phr->u.d.u.stream_info.samples_transferred = |
| 1241 | status->samples_processed; |
| 1242 | phr->u.d.u.stream_info.buffer_size = status->size_in_bytes; |
| 1243 | phr->u.d.u.stream_info.data_available = |
| 1244 | instream_get_bytes_available(status); |
| 1245 | phr->u.d.u.stream_info.auxiliary_data_available = |
| 1246 | status->auxiliary_data_available; |
| 1247 | } |
| 1248 | |
| 1249 | /*****************************************************************************/ |
| 1250 | /* LOW-LEVEL */ |
| 1251 | #define HPI6205_MAX_FILES_TO_LOAD 2 |
| 1252 | |
| 1253 | static u16 adapter_boot_load_dsp(struct hpi_adapter_obj *pao, |
| 1254 | u32 *pos_error_code) |
| 1255 | { |
| 1256 | struct hpi_hw_obj *phw = pao->priv; |
| 1257 | struct dsp_code dsp_code; |
| 1258 | u16 boot_code_id[HPI6205_MAX_FILES_TO_LOAD]; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1259 | u32 temp; |
| 1260 | int dsp = 0, i = 0; |
| 1261 | u16 err = 0; |
| 1262 | |
| 1263 | boot_code_id[0] = HPI_ADAPTER_ASI(0x6205); |
| 1264 | |
Eliot Blennerhassett | ee246fc | 2011-02-10 17:26:13 +1300 | [diff] [blame] | 1265 | boot_code_id[1] = pao->pci.pci_dev->subsystem_device; |
| 1266 | boot_code_id[1] = HPI_ADAPTER_FAMILY_ASI(boot_code_id[1]); |
| 1267 | |
| 1268 | /* fix up cases where bootcode id[1] != subsys id */ |
| 1269 | switch (boot_code_id[1]) { |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1270 | case HPI_ADAPTER_FAMILY_ASI(0x5000): |
Eliot Blennerhassett | ee246fc | 2011-02-10 17:26:13 +1300 | [diff] [blame] | 1271 | boot_code_id[0] = boot_code_id[1]; |
| 1272 | boot_code_id[1] = 0; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1273 | break; |
| 1274 | case HPI_ADAPTER_FAMILY_ASI(0x5300): |
| 1275 | case HPI_ADAPTER_FAMILY_ASI(0x5400): |
| 1276 | case HPI_ADAPTER_FAMILY_ASI(0x6300): |
Eliot Blennerhassett | ee246fc | 2011-02-10 17:26:13 +1300 | [diff] [blame] | 1277 | boot_code_id[1] = HPI_ADAPTER_FAMILY_ASI(0x6400); |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1278 | break; |
Eliot Blennerhassett | 6d0b898 | 2011-04-05 20:55:47 +1200 | [diff] [blame] | 1279 | case HPI_ADAPTER_FAMILY_ASI(0x5500): |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1280 | case HPI_ADAPTER_FAMILY_ASI(0x5600): |
| 1281 | case HPI_ADAPTER_FAMILY_ASI(0x6500): |
Eliot Blennerhassett | ee246fc | 2011-02-10 17:26:13 +1300 | [diff] [blame] | 1282 | boot_code_id[1] = HPI_ADAPTER_FAMILY_ASI(0x6600); |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1283 | break; |
Eliot Blennerhassett | cadae42 | 2010-05-27 17:53:54 +1200 | [diff] [blame] | 1284 | case HPI_ADAPTER_FAMILY_ASI(0x8800): |
Eliot Blennerhassett | ee246fc | 2011-02-10 17:26:13 +1300 | [diff] [blame] | 1285 | boot_code_id[1] = HPI_ADAPTER_FAMILY_ASI(0x8900); |
| 1286 | break; |
| 1287 | default: |
Eliot Blennerhassett | cadae42 | 2010-05-27 17:53:54 +1200 | [diff] [blame] | 1288 | break; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1289 | } |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1290 | |
| 1291 | /* reset DSP by writing a 1 to the WARMRESET bit */ |
| 1292 | temp = C6205_HDCR_WARMRESET; |
| 1293 | iowrite32(temp, phw->prHDCR); |
| 1294 | hpios_delay_micro_seconds(1000); |
| 1295 | |
| 1296 | /* check that PCI i/f was configured by EEPROM */ |
| 1297 | temp = ioread32(phw->prHSR); |
| 1298 | if ((temp & (C6205_HSR_CFGERR | C6205_HSR_EEREAD)) != |
| 1299 | C6205_HSR_EEREAD) |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 1300 | return HPI6205_ERROR_6205_EEPROM; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1301 | temp |= 0x04; |
| 1302 | /* disable PINTA interrupt */ |
| 1303 | iowrite32(temp, phw->prHSR); |
| 1304 | |
| 1305 | /* check control register reports PCI boot mode */ |
| 1306 | temp = ioread32(phw->prHDCR); |
| 1307 | if (!(temp & C6205_HDCR_PCIBOOT)) |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 1308 | return HPI6205_ERROR_6205_REG; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1309 | |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 1310 | /* try writing a few numbers to the DSP page register */ |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1311 | /* and reading them back. */ |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1312 | temp = 3; |
| 1313 | iowrite32(temp, phw->prDSPP); |
| 1314 | if ((temp | C6205_DSPP_MAP1) != ioread32(phw->prDSPP)) |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 1315 | return HPI6205_ERROR_6205_DSPPAGE; |
| 1316 | temp = 2; |
| 1317 | iowrite32(temp, phw->prDSPP); |
| 1318 | if ((temp | C6205_DSPP_MAP1) != ioread32(phw->prDSPP)) |
| 1319 | return HPI6205_ERROR_6205_DSPPAGE; |
| 1320 | temp = 1; |
| 1321 | iowrite32(temp, phw->prDSPP); |
| 1322 | if ((temp | C6205_DSPP_MAP1) != ioread32(phw->prDSPP)) |
| 1323 | return HPI6205_ERROR_6205_DSPPAGE; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1324 | /* reset DSP page to the correct number */ |
| 1325 | temp = 0; |
| 1326 | iowrite32(temp, phw->prDSPP); |
| 1327 | if ((temp | C6205_DSPP_MAP1) != ioread32(phw->prDSPP)) |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 1328 | return HPI6205_ERROR_6205_DSPPAGE; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1329 | phw->dsp_page = 0; |
| 1330 | |
| 1331 | /* release 6713 from reset before 6205 is bootloaded. |
| 1332 | This ensures that the EMIF is inactive, |
| 1333 | and the 6713 HPI gets the correct bootmode etc |
| 1334 | */ |
| 1335 | if (boot_code_id[1] != 0) { |
| 1336 | /* DSP 1 is a C6713 */ |
| 1337 | /* CLKX0 <- '1' release the C6205 bootmode pulldowns */ |
| 1338 | boot_loader_write_mem32(pao, 0, (0x018C0024L), 0x00002202); |
| 1339 | hpios_delay_micro_seconds(100); |
| 1340 | /* Reset the 6713 #1 - revB */ |
| 1341 | boot_loader_write_mem32(pao, 0, C6205_BAR0_TIMER1_CTL, 0); |
| 1342 | |
| 1343 | /* dummy read every 4 words for 6205 advisory 1.4.4 */ |
| 1344 | boot_loader_read_mem32(pao, 0, 0); |
| 1345 | |
| 1346 | hpios_delay_micro_seconds(100); |
| 1347 | /* Release C6713 from reset - revB */ |
| 1348 | boot_loader_write_mem32(pao, 0, C6205_BAR0_TIMER1_CTL, 4); |
| 1349 | hpios_delay_micro_seconds(100); |
| 1350 | } |
| 1351 | |
| 1352 | for (dsp = 0; dsp < HPI6205_MAX_FILES_TO_LOAD; dsp++) { |
| 1353 | /* is there a DSP to load? */ |
| 1354 | if (boot_code_id[dsp] == 0) |
| 1355 | continue; |
| 1356 | |
| 1357 | err = boot_loader_config_emif(pao, dsp); |
| 1358 | if (err) |
| 1359 | return err; |
| 1360 | |
| 1361 | err = boot_loader_test_internal_memory(pao, dsp); |
| 1362 | if (err) |
| 1363 | return err; |
| 1364 | |
| 1365 | err = boot_loader_test_external_memory(pao, dsp); |
| 1366 | if (err) |
| 1367 | return err; |
| 1368 | |
| 1369 | err = boot_loader_test_pld(pao, dsp); |
| 1370 | if (err) |
| 1371 | return err; |
| 1372 | |
| 1373 | /* write the DSP code down into the DSPs memory */ |
Eliot Blennerhassett | 95a4c6e | 2011-07-22 15:52:42 +1200 | [diff] [blame^] | 1374 | err = hpi_dsp_code_open(boot_code_id[dsp], pao->pci.pci_dev, |
| 1375 | &dsp_code, pos_error_code); |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1376 | if (err) |
| 1377 | return err; |
| 1378 | |
| 1379 | while (1) { |
| 1380 | u32 length; |
| 1381 | u32 address; |
| 1382 | u32 type; |
| 1383 | u32 *pcode; |
| 1384 | |
| 1385 | err = hpi_dsp_code_read_word(&dsp_code, &length); |
| 1386 | if (err) |
| 1387 | break; |
| 1388 | if (length == 0xFFFFFFFF) |
| 1389 | break; /* end of code */ |
| 1390 | |
| 1391 | err = hpi_dsp_code_read_word(&dsp_code, &address); |
| 1392 | if (err) |
| 1393 | break; |
| 1394 | err = hpi_dsp_code_read_word(&dsp_code, &type); |
| 1395 | if (err) |
| 1396 | break; |
| 1397 | err = hpi_dsp_code_read_block(length, &dsp_code, |
| 1398 | &pcode); |
| 1399 | if (err) |
| 1400 | break; |
| 1401 | for (i = 0; i < (int)length; i++) { |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 1402 | boot_loader_write_mem32(pao, dsp, address, |
| 1403 | *pcode); |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1404 | /* dummy read every 4 words */ |
| 1405 | /* for 6205 advisory 1.4.4 */ |
| 1406 | if (i % 4 == 0) |
| 1407 | boot_loader_read_mem32(pao, dsp, |
| 1408 | address); |
| 1409 | pcode++; |
| 1410 | address += 4; |
| 1411 | } |
| 1412 | |
| 1413 | } |
| 1414 | if (err) { |
| 1415 | hpi_dsp_code_close(&dsp_code); |
| 1416 | return err; |
| 1417 | } |
| 1418 | |
| 1419 | /* verify code */ |
| 1420 | hpi_dsp_code_rewind(&dsp_code); |
| 1421 | while (1) { |
| 1422 | u32 length = 0; |
| 1423 | u32 address = 0; |
| 1424 | u32 type = 0; |
| 1425 | u32 *pcode = NULL; |
| 1426 | u32 data = 0; |
| 1427 | |
| 1428 | hpi_dsp_code_read_word(&dsp_code, &length); |
| 1429 | if (length == 0xFFFFFFFF) |
| 1430 | break; /* end of code */ |
| 1431 | |
| 1432 | hpi_dsp_code_read_word(&dsp_code, &address); |
| 1433 | hpi_dsp_code_read_word(&dsp_code, &type); |
| 1434 | hpi_dsp_code_read_block(length, &dsp_code, &pcode); |
| 1435 | |
| 1436 | for (i = 0; i < (int)length; i++) { |
| 1437 | data = boot_loader_read_mem32(pao, dsp, |
| 1438 | address); |
| 1439 | if (data != *pcode) { |
| 1440 | err = 0; |
| 1441 | break; |
| 1442 | } |
| 1443 | pcode++; |
| 1444 | address += 4; |
| 1445 | } |
| 1446 | if (err) |
| 1447 | break; |
| 1448 | } |
| 1449 | hpi_dsp_code_close(&dsp_code); |
| 1450 | if (err) |
| 1451 | return err; |
| 1452 | } |
| 1453 | |
| 1454 | /* After bootloading all DSPs, start DSP0 running |
| 1455 | * The DSP0 code will handle starting and synchronizing with its slaves |
| 1456 | */ |
| 1457 | if (phw->p_interface_buffer) { |
| 1458 | /* we need to tell the card the physical PCI address */ |
| 1459 | u32 physicalPC_iaddress; |
| 1460 | struct bus_master_interface *interface = |
| 1461 | phw->p_interface_buffer; |
| 1462 | u32 host_mailbox_address_on_dsp; |
| 1463 | u32 physicalPC_iaddress_verify = 0; |
| 1464 | int time_out = 10; |
| 1465 | /* set ack so we know when DSP is ready to go */ |
| 1466 | /* (dwDspAck will be changed to HIF_RESET) */ |
| 1467 | interface->dsp_ack = H620_HIF_UNKNOWN; |
| 1468 | wmb(); /* ensure ack is written before dsp writes back */ |
| 1469 | |
| 1470 | err = hpios_locked_mem_get_phys_addr(&phw->h_locked_mem, |
| 1471 | &physicalPC_iaddress); |
| 1472 | |
| 1473 | /* locate the host mailbox on the DSP. */ |
| 1474 | host_mailbox_address_on_dsp = 0x80000000; |
| 1475 | while ((physicalPC_iaddress != physicalPC_iaddress_verify) |
| 1476 | && time_out--) { |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 1477 | boot_loader_write_mem32(pao, 0, |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1478 | host_mailbox_address_on_dsp, |
| 1479 | physicalPC_iaddress); |
| 1480 | physicalPC_iaddress_verify = |
| 1481 | boot_loader_read_mem32(pao, 0, |
| 1482 | host_mailbox_address_on_dsp); |
| 1483 | } |
| 1484 | } |
| 1485 | HPI_DEBUG_LOG(DEBUG, "starting DS_ps running\n"); |
| 1486 | /* enable interrupts */ |
| 1487 | temp = ioread32(phw->prHSR); |
| 1488 | temp &= ~(u32)C6205_HSR_INTAM; |
| 1489 | iowrite32(temp, phw->prHSR); |
| 1490 | |
| 1491 | /* start code running... */ |
| 1492 | temp = ioread32(phw->prHDCR); |
| 1493 | temp |= (u32)C6205_HDCR_DSPINT; |
| 1494 | iowrite32(temp, phw->prHDCR); |
| 1495 | |
| 1496 | /* give the DSP 10ms to start up */ |
| 1497 | hpios_delay_micro_seconds(10000); |
| 1498 | return err; |
| 1499 | |
| 1500 | } |
| 1501 | |
| 1502 | /*****************************************************************************/ |
| 1503 | /* Bootloader utility functions */ |
| 1504 | |
| 1505 | static u32 boot_loader_read_mem32(struct hpi_adapter_obj *pao, int dsp_index, |
| 1506 | u32 address) |
| 1507 | { |
| 1508 | struct hpi_hw_obj *phw = pao->priv; |
| 1509 | u32 data = 0; |
| 1510 | __iomem u32 *p_data; |
| 1511 | |
| 1512 | if (dsp_index == 0) { |
| 1513 | /* DSP 0 is always C6205 */ |
| 1514 | if ((address >= 0x01800000) & (address < 0x02000000)) { |
| 1515 | /* BAR1 register access */ |
| 1516 | p_data = pao->pci.ap_mem_base[1] + |
| 1517 | (address & 0x007fffff) / |
| 1518 | sizeof(*pao->pci.ap_mem_base[1]); |
| 1519 | /* HPI_DEBUG_LOG(WARNING, |
| 1520 | "BAR1 access %08x\n", dwAddress); */ |
| 1521 | } else { |
| 1522 | u32 dw4M_page = address >> 22L; |
| 1523 | if (dw4M_page != phw->dsp_page) { |
| 1524 | phw->dsp_page = dw4M_page; |
| 1525 | /* *INDENT OFF* */ |
| 1526 | iowrite32(phw->dsp_page, phw->prDSPP); |
| 1527 | /* *INDENT-ON* */ |
| 1528 | } |
| 1529 | address &= 0x3fffff; /* address within 4M page */ |
| 1530 | /* BAR0 memory access */ |
| 1531 | p_data = pao->pci.ap_mem_base[0] + |
| 1532 | address / sizeof(u32); |
| 1533 | } |
| 1534 | data = ioread32(p_data); |
| 1535 | } else if (dsp_index == 1) { |
| 1536 | /* DSP 1 is a C6713 */ |
| 1537 | u32 lsb; |
| 1538 | boot_loader_write_mem32(pao, 0, HPIAL_ADDR, address); |
| 1539 | boot_loader_write_mem32(pao, 0, HPIAH_ADDR, address >> 16); |
| 1540 | lsb = boot_loader_read_mem32(pao, 0, HPIDL_ADDR); |
| 1541 | data = boot_loader_read_mem32(pao, 0, HPIDH_ADDR); |
| 1542 | data = (data << 16) | (lsb & 0xFFFF); |
| 1543 | } |
| 1544 | return data; |
| 1545 | } |
| 1546 | |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 1547 | static void boot_loader_write_mem32(struct hpi_adapter_obj *pao, |
| 1548 | int dsp_index, u32 address, u32 data) |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1549 | { |
| 1550 | struct hpi_hw_obj *phw = pao->priv; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1551 | __iomem u32 *p_data; |
| 1552 | /* u32 dwVerifyData=0; */ |
| 1553 | |
| 1554 | if (dsp_index == 0) { |
| 1555 | /* DSP 0 is always C6205 */ |
| 1556 | if ((address >= 0x01800000) & (address < 0x02000000)) { |
| 1557 | /* BAR1 - DSP register access using */ |
| 1558 | /* Non-prefetchable PCI access */ |
| 1559 | p_data = pao->pci.ap_mem_base[1] + |
| 1560 | (address & 0x007fffff) / |
| 1561 | sizeof(*pao->pci.ap_mem_base[1]); |
| 1562 | } else { |
| 1563 | /* BAR0 access - all of DSP memory using */ |
| 1564 | /* pre-fetchable PCI access */ |
| 1565 | u32 dw4M_page = address >> 22L; |
| 1566 | if (dw4M_page != phw->dsp_page) { |
| 1567 | phw->dsp_page = dw4M_page; |
| 1568 | /* *INDENT-OFF* */ |
| 1569 | iowrite32(phw->dsp_page, phw->prDSPP); |
| 1570 | /* *INDENT-ON* */ |
| 1571 | } |
| 1572 | address &= 0x3fffff; /* address within 4M page */ |
| 1573 | p_data = pao->pci.ap_mem_base[0] + |
| 1574 | address / sizeof(u32); |
| 1575 | } |
| 1576 | iowrite32(data, p_data); |
| 1577 | } else if (dsp_index == 1) { |
| 1578 | /* DSP 1 is a C6713 */ |
| 1579 | boot_loader_write_mem32(pao, 0, HPIAL_ADDR, address); |
| 1580 | boot_loader_write_mem32(pao, 0, HPIAH_ADDR, address >> 16); |
| 1581 | |
| 1582 | /* dummy read every 4 words for 6205 advisory 1.4.4 */ |
| 1583 | boot_loader_read_mem32(pao, 0, 0); |
| 1584 | |
| 1585 | boot_loader_write_mem32(pao, 0, HPIDL_ADDR, data); |
| 1586 | boot_loader_write_mem32(pao, 0, HPIDH_ADDR, data >> 16); |
| 1587 | |
| 1588 | /* dummy read every 4 words for 6205 advisory 1.4.4 */ |
| 1589 | boot_loader_read_mem32(pao, 0, 0); |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 1590 | } |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1591 | } |
| 1592 | |
| 1593 | static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, int dsp_index) |
| 1594 | { |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1595 | if (dsp_index == 0) { |
| 1596 | u32 setting; |
| 1597 | |
| 1598 | /* DSP 0 is always C6205 */ |
| 1599 | |
| 1600 | /* Set the EMIF */ |
| 1601 | /* memory map of C6205 */ |
| 1602 | /* 00000000-0000FFFF 16Kx32 internal program */ |
| 1603 | /* 00400000-00BFFFFF CE0 2Mx32 SDRAM running @ 100MHz */ |
| 1604 | |
| 1605 | /* EMIF config */ |
| 1606 | /*------------ */ |
| 1607 | /* Global EMIF control */ |
| 1608 | boot_loader_write_mem32(pao, dsp_index, 0x01800000, 0x3779); |
| 1609 | #define WS_OFS 28 |
| 1610 | #define WST_OFS 22 |
| 1611 | #define WH_OFS 20 |
| 1612 | #define RS_OFS 16 |
| 1613 | #define RST_OFS 8 |
| 1614 | #define MTYPE_OFS 4 |
| 1615 | #define RH_OFS 0 |
| 1616 | |
| 1617 | /* EMIF CE0 setup - 2Mx32 Sync DRAM on ASI5000 cards only */ |
| 1618 | setting = 0x00000030; |
| 1619 | boot_loader_write_mem32(pao, dsp_index, 0x01800008, setting); |
| 1620 | if (setting != boot_loader_read_mem32(pao, dsp_index, |
| 1621 | 0x01800008)) |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 1622 | return HPI6205_ERROR_DSP_EMIF; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1623 | |
| 1624 | /* EMIF CE1 setup - 32 bit async. This is 6713 #1 HPI, */ |
| 1625 | /* which occupies D15..0. 6713 starts at 27MHz, so need */ |
| 1626 | /* plenty of wait states. See dsn8701.rtf, and 6713 errata. */ |
| 1627 | /* WST should be 71, but 63 is max possible */ |
| 1628 | setting = |
| 1629 | (1L << WS_OFS) | (63L << WST_OFS) | (1L << WH_OFS) | |
| 1630 | (1L << RS_OFS) | (63L << RST_OFS) | (1L << RH_OFS) | |
| 1631 | (2L << MTYPE_OFS); |
| 1632 | boot_loader_write_mem32(pao, dsp_index, 0x01800004, setting); |
| 1633 | if (setting != boot_loader_read_mem32(pao, dsp_index, |
| 1634 | 0x01800004)) |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 1635 | return HPI6205_ERROR_DSP_EMIF; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1636 | |
| 1637 | /* EMIF CE2 setup - 32 bit async. This is 6713 #2 HPI, */ |
| 1638 | /* which occupies D15..0. 6713 starts at 27MHz, so need */ |
| 1639 | /* plenty of wait states */ |
| 1640 | setting = |
| 1641 | (1L << WS_OFS) | (28L << WST_OFS) | (1L << WH_OFS) | |
| 1642 | (1L << RS_OFS) | (63L << RST_OFS) | (1L << RH_OFS) | |
| 1643 | (2L << MTYPE_OFS); |
| 1644 | boot_loader_write_mem32(pao, dsp_index, 0x01800010, setting); |
| 1645 | if (setting != boot_loader_read_mem32(pao, dsp_index, |
| 1646 | 0x01800010)) |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 1647 | return HPI6205_ERROR_DSP_EMIF; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1648 | |
| 1649 | /* EMIF CE3 setup - 32 bit async. */ |
| 1650 | /* This is the PLD on the ASI5000 cards only */ |
| 1651 | setting = |
| 1652 | (1L << WS_OFS) | (10L << WST_OFS) | (1L << WH_OFS) | |
| 1653 | (1L << RS_OFS) | (10L << RST_OFS) | (1L << RH_OFS) | |
| 1654 | (2L << MTYPE_OFS); |
| 1655 | boot_loader_write_mem32(pao, dsp_index, 0x01800014, setting); |
| 1656 | if (setting != boot_loader_read_mem32(pao, dsp_index, |
| 1657 | 0x01800014)) |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 1658 | return HPI6205_ERROR_DSP_EMIF; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1659 | |
| 1660 | /* set EMIF SDRAM control for 2Mx32 SDRAM (512x32x4 bank) */ |
| 1661 | /* need to use this else DSP code crashes? */ |
| 1662 | boot_loader_write_mem32(pao, dsp_index, 0x01800018, |
| 1663 | 0x07117000); |
| 1664 | |
| 1665 | /* EMIF SDRAM Refresh Timing */ |
| 1666 | /* EMIF SDRAM timing (orig = 0x410, emulator = 0x61a) */ |
| 1667 | boot_loader_write_mem32(pao, dsp_index, 0x0180001C, |
| 1668 | 0x00000410); |
| 1669 | |
| 1670 | } else if (dsp_index == 1) { |
| 1671 | /* test access to the C6713s HPI registers */ |
| 1672 | u32 write_data = 0, read_data = 0, i = 0; |
| 1673 | |
| 1674 | /* Set up HPIC for little endian, by setiing HPIC:HWOB=1 */ |
| 1675 | write_data = 1; |
| 1676 | boot_loader_write_mem32(pao, 0, HPICL_ADDR, write_data); |
| 1677 | boot_loader_write_mem32(pao, 0, HPICH_ADDR, write_data); |
| 1678 | /* C67 HPI is on lower 16bits of 32bit EMIF */ |
| 1679 | read_data = |
| 1680 | 0xFFF7 & boot_loader_read_mem32(pao, 0, HPICL_ADDR); |
| 1681 | if (write_data != read_data) { |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1682 | HPI_DEBUG_LOG(ERROR, "HPICL %x %x\n", write_data, |
| 1683 | read_data); |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 1684 | return HPI6205_ERROR_C6713_HPIC; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1685 | } |
| 1686 | /* HPIA - walking ones test */ |
| 1687 | write_data = 1; |
| 1688 | for (i = 0; i < 32; i++) { |
| 1689 | boot_loader_write_mem32(pao, 0, HPIAL_ADDR, |
| 1690 | write_data); |
| 1691 | boot_loader_write_mem32(pao, 0, HPIAH_ADDR, |
| 1692 | (write_data >> 16)); |
| 1693 | read_data = |
| 1694 | 0xFFFF & boot_loader_read_mem32(pao, 0, |
| 1695 | HPIAL_ADDR); |
| 1696 | read_data = |
| 1697 | read_data | ((0xFFFF & |
| 1698 | boot_loader_read_mem32(pao, 0, |
| 1699 | HPIAH_ADDR)) |
| 1700 | << 16); |
| 1701 | if (read_data != write_data) { |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1702 | HPI_DEBUG_LOG(ERROR, "HPIA %x %x\n", |
| 1703 | write_data, read_data); |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 1704 | return HPI6205_ERROR_C6713_HPIA; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1705 | } |
| 1706 | write_data = write_data << 1; |
| 1707 | } |
| 1708 | |
| 1709 | /* setup C67x PLL |
| 1710 | * ** C6713 datasheet says we cannot program PLL from HPI, |
| 1711 | * and indeed if we try to set the PLL multiply from the HPI, |
| 1712 | * the PLL does not seem to lock, so we enable the PLL and |
| 1713 | * use the default multiply of x 7, which for a 27MHz clock |
| 1714 | * gives a DSP speed of 189MHz |
| 1715 | */ |
| 1716 | /* bypass PLL */ |
| 1717 | boot_loader_write_mem32(pao, dsp_index, 0x01B7C100, 0x0000); |
| 1718 | hpios_delay_micro_seconds(1000); |
| 1719 | /* EMIF = 189/3=63MHz */ |
| 1720 | boot_loader_write_mem32(pao, dsp_index, 0x01B7C120, 0x8002); |
| 1721 | /* peri = 189/2 */ |
| 1722 | boot_loader_write_mem32(pao, dsp_index, 0x01B7C11C, 0x8001); |
| 1723 | /* cpu = 189/1 */ |
| 1724 | boot_loader_write_mem32(pao, dsp_index, 0x01B7C118, 0x8000); |
| 1725 | hpios_delay_micro_seconds(1000); |
| 1726 | /* ** SGT test to take GPO3 high when we start the PLL */ |
| 1727 | /* and low when the delay is completed */ |
| 1728 | /* FSX0 <- '1' (GPO3) */ |
| 1729 | boot_loader_write_mem32(pao, 0, (0x018C0024L), 0x00002A0A); |
| 1730 | /* PLL not bypassed */ |
| 1731 | boot_loader_write_mem32(pao, dsp_index, 0x01B7C100, 0x0001); |
| 1732 | hpios_delay_micro_seconds(1000); |
| 1733 | /* FSX0 <- '0' (GPO3) */ |
| 1734 | boot_loader_write_mem32(pao, 0, (0x018C0024L), 0x00002A02); |
| 1735 | |
| 1736 | /* 6205 EMIF CE1 resetup - 32 bit async. */ |
| 1737 | /* Now 6713 #1 is running at 189MHz can reduce waitstates */ |
| 1738 | boot_loader_write_mem32(pao, 0, 0x01800004, /* CE1 */ |
| 1739 | (1L << WS_OFS) | (8L << WST_OFS) | (1L << WH_OFS) | |
| 1740 | (1L << RS_OFS) | (12L << RST_OFS) | (1L << RH_OFS) | |
| 1741 | (2L << MTYPE_OFS)); |
| 1742 | |
| 1743 | hpios_delay_micro_seconds(1000); |
| 1744 | |
| 1745 | /* check that we can read one of the PLL registers */ |
| 1746 | /* PLL should not be bypassed! */ |
| 1747 | if ((boot_loader_read_mem32(pao, dsp_index, 0x01B7C100) & 0xF) |
| 1748 | != 0x0001) { |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 1749 | return HPI6205_ERROR_C6713_PLL; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1750 | } |
| 1751 | /* setup C67x EMIF (note this is the only use of |
| 1752 | BAR1 via BootLoader_WriteMem32) */ |
| 1753 | boot_loader_write_mem32(pao, dsp_index, C6713_EMIF_GCTL, |
| 1754 | 0x000034A8); |
Eliot Blennerhassett | 1d595d2 | 2011-02-10 17:26:08 +1300 | [diff] [blame] | 1755 | |
| 1756 | /* EMIF CE0 setup - 2Mx32 Sync DRAM |
| 1757 | 31..28 Wr setup |
| 1758 | 27..22 Wr strobe |
| 1759 | 21..20 Wr hold |
| 1760 | 19..16 Rd setup |
| 1761 | 15..14 - |
| 1762 | 13..8 Rd strobe |
| 1763 | 7..4 MTYPE 0011 Sync DRAM 32bits |
| 1764 | 3 Wr hold MSB |
| 1765 | 2..0 Rd hold |
| 1766 | */ |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1767 | boot_loader_write_mem32(pao, dsp_index, C6713_EMIF_CE0, |
| 1768 | 0x00000030); |
Eliot Blennerhassett | 1d595d2 | 2011-02-10 17:26:08 +1300 | [diff] [blame] | 1769 | |
| 1770 | /* EMIF SDRAM Extension |
| 1771 | 0x00 |
| 1772 | 31-21 0000b 0000b 000b |
| 1773 | 20 WR2RD = 2cycles-1 = 1b |
| 1774 | |
| 1775 | 19-18 WR2DEAC = 3cycle-1 = 10b |
| 1776 | 17 WR2WR = 2cycle-1 = 1b |
| 1777 | 16-15 R2WDQM = 4cycle-1 = 11b |
| 1778 | 14-12 RD2WR = 6cycles-1 = 101b |
| 1779 | |
| 1780 | 11-10 RD2DEAC = 4cycle-1 = 11b |
| 1781 | 9 RD2RD = 2cycle-1 = 1b |
| 1782 | 8-7 THZP = 3cycle-1 = 10b |
| 1783 | 6-5 TWR = 2cycle-1 = 01b (tWR = 17ns) |
| 1784 | 4 TRRD = 2cycle = 0b (tRRD = 14ns) |
| 1785 | 3-1 TRAS = 5cycle-1 = 100b (Tras=42ns) |
| 1786 | 1 CAS latency = 3cyc = 1b |
| 1787 | (for Micron 2M32-7 operating at 100MHz) |
| 1788 | */ |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1789 | boot_loader_write_mem32(pao, dsp_index, C6713_EMIF_SDRAMEXT, |
| 1790 | 0x001BDF29); |
Eliot Blennerhassett | 1d595d2 | 2011-02-10 17:26:08 +1300 | [diff] [blame] | 1791 | |
| 1792 | /* EMIF SDRAM control - set up for a 2Mx32 SDRAM (512x32x4 bank) |
| 1793 | 31 - 0b - |
| 1794 | 30 SDBSZ 1b 4 bank |
| 1795 | 29..28 SDRSZ 00b 11 row address pins |
| 1796 | |
| 1797 | 27..26 SDCSZ 01b 8 column address pins |
| 1798 | 25 RFEN 1b refersh enabled |
| 1799 | 24 INIT 1b init SDRAM! |
| 1800 | |
| 1801 | 23..20 TRCD 0001b (Trcd/Tcyc)-1 = (20/10)-1 = 1 |
| 1802 | |
| 1803 | 19..16 TRP 0001b (Trp/Tcyc)-1 = (20/10)-1 = 1 |
| 1804 | |
| 1805 | 15..12 TRC 0110b (Trc/Tcyc)-1 = (70/10)-1 = 6 |
| 1806 | |
| 1807 | 11..0 - 0000b 0000b 0000b |
| 1808 | */ |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1809 | boot_loader_write_mem32(pao, dsp_index, C6713_EMIF_SDRAMCTL, |
Eliot Blennerhassett | 1d595d2 | 2011-02-10 17:26:08 +1300 | [diff] [blame] | 1810 | 0x47116000); |
| 1811 | |
| 1812 | /* SDRAM refresh timing |
| 1813 | Need 4,096 refresh cycles every 64ms = 15.625us = 1562cycles of 100MHz = 0x61A |
| 1814 | */ |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1815 | boot_loader_write_mem32(pao, dsp_index, |
| 1816 | C6713_EMIF_SDRAMTIMING, 0x00000410); |
| 1817 | |
| 1818 | hpios_delay_micro_seconds(1000); |
| 1819 | } else if (dsp_index == 2) { |
| 1820 | /* DSP 2 is a C6713 */ |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 1821 | } |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1822 | |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 1823 | return 0; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1824 | } |
| 1825 | |
| 1826 | static u16 boot_loader_test_memory(struct hpi_adapter_obj *pao, int dsp_index, |
| 1827 | u32 start_address, u32 length) |
| 1828 | { |
| 1829 | u32 i = 0, j = 0; |
| 1830 | u32 test_addr = 0; |
| 1831 | u32 test_data = 0, data = 0; |
| 1832 | |
| 1833 | length = 1000; |
| 1834 | |
| 1835 | /* for 1st word, test each bit in the 32bit word, */ |
| 1836 | /* dwLength specifies number of 32bit words to test */ |
| 1837 | /*for(i=0; i<dwLength; i++) */ |
| 1838 | i = 0; |
| 1839 | { |
| 1840 | test_addr = start_address + i * 4; |
| 1841 | test_data = 0x00000001; |
| 1842 | for (j = 0; j < 32; j++) { |
| 1843 | boot_loader_write_mem32(pao, dsp_index, test_addr, |
| 1844 | test_data); |
| 1845 | data = boot_loader_read_mem32(pao, dsp_index, |
| 1846 | test_addr); |
| 1847 | if (data != test_data) { |
| 1848 | HPI_DEBUG_LOG(VERBOSE, |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 1849 | "Memtest error details " |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1850 | "%08x %08x %08x %i\n", test_addr, |
| 1851 | test_data, data, dsp_index); |
| 1852 | return 1; /* error */ |
| 1853 | } |
| 1854 | test_data = test_data << 1; |
| 1855 | } /* for(j) */ |
| 1856 | } /* for(i) */ |
| 1857 | |
| 1858 | /* for the next 100 locations test each location, leaving it as zero */ |
| 1859 | /* write a zero to the next word in memory before we read */ |
| 1860 | /* the previous write to make sure every memory location is unique */ |
| 1861 | for (i = 0; i < 100; i++) { |
| 1862 | test_addr = start_address + i * 4; |
| 1863 | test_data = 0xA5A55A5A; |
| 1864 | boot_loader_write_mem32(pao, dsp_index, test_addr, test_data); |
| 1865 | boot_loader_write_mem32(pao, dsp_index, test_addr + 4, 0); |
| 1866 | data = boot_loader_read_mem32(pao, dsp_index, test_addr); |
| 1867 | if (data != test_data) { |
| 1868 | HPI_DEBUG_LOG(VERBOSE, |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 1869 | "Memtest error details " |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1870 | "%08x %08x %08x %i\n", test_addr, test_data, |
| 1871 | data, dsp_index); |
| 1872 | return 1; /* error */ |
| 1873 | } |
| 1874 | /* leave location as zero */ |
| 1875 | boot_loader_write_mem32(pao, dsp_index, test_addr, 0x0); |
| 1876 | } |
| 1877 | |
| 1878 | /* zero out entire memory block */ |
| 1879 | for (i = 0; i < length; i++) { |
| 1880 | test_addr = start_address + i * 4; |
| 1881 | boot_loader_write_mem32(pao, dsp_index, test_addr, 0x0); |
| 1882 | } |
| 1883 | return 0; |
| 1884 | } |
| 1885 | |
| 1886 | static u16 boot_loader_test_internal_memory(struct hpi_adapter_obj *pao, |
| 1887 | int dsp_index) |
| 1888 | { |
| 1889 | int err = 0; |
| 1890 | if (dsp_index == 0) { |
| 1891 | /* DSP 0 is a C6205 */ |
| 1892 | /* 64K prog mem */ |
| 1893 | err = boot_loader_test_memory(pao, dsp_index, 0x00000000, |
| 1894 | 0x10000); |
| 1895 | if (!err) |
| 1896 | /* 64K data mem */ |
| 1897 | err = boot_loader_test_memory(pao, dsp_index, |
| 1898 | 0x80000000, 0x10000); |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 1899 | } else if (dsp_index == 1) { |
| 1900 | /* DSP 1 is a C6713 */ |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1901 | /* 192K internal mem */ |
| 1902 | err = boot_loader_test_memory(pao, dsp_index, 0x00000000, |
| 1903 | 0x30000); |
| 1904 | if (!err) |
| 1905 | /* 64K internal mem / L2 cache */ |
| 1906 | err = boot_loader_test_memory(pao, dsp_index, |
| 1907 | 0x00030000, 0x10000); |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 1908 | } |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1909 | |
| 1910 | if (err) |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 1911 | return HPI6205_ERROR_DSP_INTMEM; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1912 | else |
| 1913 | return 0; |
| 1914 | } |
| 1915 | |
| 1916 | static u16 boot_loader_test_external_memory(struct hpi_adapter_obj *pao, |
| 1917 | int dsp_index) |
| 1918 | { |
| 1919 | u32 dRAM_start_address = 0; |
| 1920 | u32 dRAM_size = 0; |
| 1921 | |
| 1922 | if (dsp_index == 0) { |
| 1923 | /* only test for SDRAM if an ASI5000 card */ |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 1924 | if (pao->pci.pci_dev->subsystem_device == 0x5000) { |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1925 | /* DSP 0 is always C6205 */ |
| 1926 | dRAM_start_address = 0x00400000; |
| 1927 | dRAM_size = 0x200000; |
| 1928 | /*dwDRAMinc=1024; */ |
| 1929 | } else |
| 1930 | return 0; |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 1931 | } else if (dsp_index == 1) { |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1932 | /* DSP 1 is a C6713 */ |
| 1933 | dRAM_start_address = 0x80000000; |
| 1934 | dRAM_size = 0x200000; |
| 1935 | /*dwDRAMinc=1024; */ |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 1936 | } |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1937 | |
| 1938 | if (boot_loader_test_memory(pao, dsp_index, dRAM_start_address, |
| 1939 | dRAM_size)) |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 1940 | return HPI6205_ERROR_DSP_EXTMEM; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1941 | return 0; |
| 1942 | } |
| 1943 | |
| 1944 | static u16 boot_loader_test_pld(struct hpi_adapter_obj *pao, int dsp_index) |
| 1945 | { |
| 1946 | u32 data = 0; |
| 1947 | if (dsp_index == 0) { |
| 1948 | /* only test for DSP0 PLD on ASI5000 card */ |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 1949 | if (pao->pci.pci_dev->subsystem_device == 0x5000) { |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1950 | /* PLD is located at CE3=0x03000000 */ |
| 1951 | data = boot_loader_read_mem32(pao, dsp_index, |
| 1952 | 0x03000008); |
| 1953 | if ((data & 0xF) != 0x5) |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 1954 | return HPI6205_ERROR_DSP_PLD; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1955 | data = boot_loader_read_mem32(pao, dsp_index, |
| 1956 | 0x0300000C); |
| 1957 | if ((data & 0xF) != 0xA) |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 1958 | return HPI6205_ERROR_DSP_PLD; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1959 | } |
| 1960 | } else if (dsp_index == 1) { |
| 1961 | /* DSP 1 is a C6713 */ |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 1962 | if (pao->pci.pci_dev->subsystem_device == 0x8700) { |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1963 | /* PLD is located at CE1=0x90000000 */ |
| 1964 | data = boot_loader_read_mem32(pao, dsp_index, |
| 1965 | 0x90000010); |
| 1966 | if ((data & 0xFF) != 0xAA) |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 1967 | return HPI6205_ERROR_DSP_PLD; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1968 | /* 8713 - LED on */ |
| 1969 | boot_loader_write_mem32(pao, dsp_index, 0x90000000, |
| 1970 | 0x02); |
| 1971 | } |
| 1972 | } |
| 1973 | return 0; |
| 1974 | } |
| 1975 | |
| 1976 | /** Transfer data to or from DSP |
| 1977 | nOperation = H620_H620_HIF_SEND_DATA or H620_HIF_GET_DATA |
| 1978 | */ |
| 1979 | static short hpi6205_transfer_data(struct hpi_adapter_obj *pao, u8 *p_data, |
| 1980 | u32 data_size, int operation) |
| 1981 | { |
| 1982 | struct hpi_hw_obj *phw = pao->priv; |
| 1983 | u32 data_transferred = 0; |
| 1984 | u16 err = 0; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1985 | u32 temp2; |
| 1986 | struct bus_master_interface *interface = phw->p_interface_buffer; |
| 1987 | |
| 1988 | if (!p_data) |
Eliot Blennerhassett | deb21a2 | 2011-02-10 17:26:03 +1300 | [diff] [blame] | 1989 | return HPI_ERROR_INVALID_DATA_POINTER; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 1990 | |
| 1991 | data_size &= ~3L; /* round data_size down to nearest 4 bytes */ |
| 1992 | |
| 1993 | /* make sure state is IDLE */ |
| 1994 | if (!wait_dsp_ack(phw, H620_HIF_IDLE, HPI6205_TIMEOUT)) |
| 1995 | return HPI_ERROR_DSP_HARDWARE; |
| 1996 | |
| 1997 | while (data_transferred < data_size) { |
| 1998 | u32 this_copy = data_size - data_transferred; |
| 1999 | |
| 2000 | if (this_copy > HPI6205_SIZEOF_DATA) |
| 2001 | this_copy = HPI6205_SIZEOF_DATA; |
| 2002 | |
| 2003 | if (operation == H620_HIF_SEND_DATA) |
| 2004 | memcpy((void *)&interface->u.b_data[0], |
| 2005 | &p_data[data_transferred], this_copy); |
| 2006 | |
| 2007 | interface->transfer_size_in_bytes = this_copy; |
| 2008 | |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 2009 | /* DSP must change this back to nOperation */ |
| 2010 | interface->dsp_ack = H620_HIF_IDLE; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 2011 | send_dsp_command(phw, operation); |
| 2012 | |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 2013 | temp2 = wait_dsp_ack(phw, operation, HPI6205_TIMEOUT); |
| 2014 | HPI_DEBUG_LOG(DEBUG, "spun %d times for data xfer of %d\n", |
| 2015 | HPI6205_TIMEOUT - temp2, this_copy); |
| 2016 | |
| 2017 | if (!temp2) { |
| 2018 | /* timed out */ |
| 2019 | HPI_DEBUG_LOG(ERROR, |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 2020 | "Timed out waiting for " "state %d got %d\n", |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 2021 | operation, interface->dsp_ack); |
| 2022 | |
| 2023 | break; |
| 2024 | } |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 2025 | if (operation == H620_HIF_GET_DATA) |
| 2026 | memcpy(&p_data[data_transferred], |
| 2027 | (void *)&interface->u.b_data[0], this_copy); |
| 2028 | |
| 2029 | data_transferred += this_copy; |
| 2030 | } |
| 2031 | if (interface->dsp_ack != operation) |
| 2032 | HPI_DEBUG_LOG(DEBUG, "interface->dsp_ack=%d, expected %d\n", |
| 2033 | interface->dsp_ack, operation); |
| 2034 | /* err=HPI_ERROR_DSP_HARDWARE; */ |
| 2035 | |
| 2036 | send_dsp_command(phw, H620_HIF_IDLE); |
| 2037 | |
| 2038 | return err; |
| 2039 | } |
| 2040 | |
| 2041 | /* wait for up to timeout_us microseconds for the DSP |
| 2042 | to signal state by DMA into dwDspAck |
| 2043 | */ |
| 2044 | static int wait_dsp_ack(struct hpi_hw_obj *phw, int state, int timeout_us) |
| 2045 | { |
| 2046 | struct bus_master_interface *interface = phw->p_interface_buffer; |
| 2047 | int t = timeout_us / 4; |
| 2048 | |
| 2049 | rmb(); /* ensure interface->dsp_ack is up to date */ |
| 2050 | while ((interface->dsp_ack != state) && --t) { |
| 2051 | hpios_delay_micro_seconds(4); |
| 2052 | rmb(); /* DSP changes dsp_ack by DMA */ |
| 2053 | } |
| 2054 | |
| 2055 | /*HPI_DEBUG_LOG(VERBOSE, "Spun %d for %d\n", timeout_us/4-t, state); */ |
| 2056 | return t * 4; |
| 2057 | } |
| 2058 | |
| 2059 | /* set the busmaster interface to cmd, then interrupt the DSP */ |
| 2060 | static void send_dsp_command(struct hpi_hw_obj *phw, int cmd) |
| 2061 | { |
| 2062 | struct bus_master_interface *interface = phw->p_interface_buffer; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 2063 | u32 r; |
| 2064 | |
| 2065 | interface->host_cmd = cmd; |
| 2066 | wmb(); /* DSP gets state by DMA, make sure it is written to memory */ |
| 2067 | /* before we interrupt the DSP */ |
| 2068 | r = ioread32(phw->prHDCR); |
| 2069 | r |= (u32)C6205_HDCR_DSPINT; |
| 2070 | iowrite32(r, phw->prHDCR); |
| 2071 | r &= ~(u32)C6205_HDCR_DSPINT; |
| 2072 | iowrite32(r, phw->prHDCR); |
| 2073 | } |
| 2074 | |
| 2075 | static unsigned int message_count; |
| 2076 | |
| 2077 | static u16 message_response_sequence(struct hpi_adapter_obj *pao, |
| 2078 | struct hpi_message *phm, struct hpi_response *phr) |
| 2079 | { |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 2080 | u32 time_out, time_out2; |
| 2081 | struct hpi_hw_obj *phw = pao->priv; |
| 2082 | struct bus_master_interface *interface = phw->p_interface_buffer; |
| 2083 | u16 err = 0; |
| 2084 | |
| 2085 | message_count++; |
Eliot Blennerhassett | c6c2c9a | 2011-07-22 15:52:38 +1200 | [diff] [blame] | 2086 | if (phm->size > sizeof(interface->u.message_buffer)) { |
Eliot Blennerhassett | deb21a2 | 2011-02-10 17:26:03 +1300 | [diff] [blame] | 2087 | phr->error = HPI_ERROR_MESSAGE_BUFFER_TOO_SMALL; |
Eliot Blennerhassett | c6c2c9a | 2011-07-22 15:52:38 +1200 | [diff] [blame] | 2088 | phr->specific_error = sizeof(interface->u.message_buffer); |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 2089 | phr->size = sizeof(struct hpi_response_header); |
| 2090 | HPI_DEBUG_LOG(ERROR, |
Takashi Iwai | a280030 | 2011-03-08 18:20:46 +0100 | [diff] [blame] | 2091 | "message len %d too big for buffer %zd \n", phm->size, |
Eliot Blennerhassett | c6c2c9a | 2011-07-22 15:52:38 +1200 | [diff] [blame] | 2092 | sizeof(interface->u.message_buffer)); |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 2093 | return 0; |
| 2094 | } |
| 2095 | |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 2096 | /* Assume buffer of type struct bus_master_interface |
| 2097 | is allocated "noncacheable" */ |
| 2098 | |
| 2099 | if (!wait_dsp_ack(phw, H620_HIF_IDLE, HPI6205_TIMEOUT)) { |
| 2100 | HPI_DEBUG_LOG(DEBUG, "timeout waiting for idle\n"); |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 2101 | return HPI6205_ERROR_MSG_RESP_IDLE_TIMEOUT; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 2102 | } |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 2103 | |
| 2104 | memcpy(&interface->u.message_buffer, phm, phm->size); |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 2105 | /* signal we want a response */ |
| 2106 | send_dsp_command(phw, H620_HIF_GET_RESP); |
| 2107 | |
| 2108 | time_out2 = wait_dsp_ack(phw, H620_HIF_GET_RESP, HPI6205_TIMEOUT); |
| 2109 | |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 2110 | if (!time_out2) { |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 2111 | HPI_DEBUG_LOG(ERROR, |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 2112 | "(%u) Timed out waiting for " "GET_RESP state [%x]\n", |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 2113 | message_count, interface->dsp_ack); |
| 2114 | } else { |
| 2115 | HPI_DEBUG_LOG(VERBOSE, |
| 2116 | "(%u) transition to GET_RESP after %u\n", |
| 2117 | message_count, HPI6205_TIMEOUT - time_out2); |
| 2118 | } |
| 2119 | /* spin waiting on HIF interrupt flag (end of msg process) */ |
| 2120 | time_out = HPI6205_TIMEOUT; |
| 2121 | |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 2122 | /* read the result */ |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 2123 | if (time_out) { |
Eliot Blennerhassett | c6c2c9a | 2011-07-22 15:52:38 +1200 | [diff] [blame] | 2124 | if (interface->u.response_buffer.response.size <= phr->size) |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 2125 | memcpy(phr, &interface->u.response_buffer, |
Eliot Blennerhassett | c6c2c9a | 2011-07-22 15:52:38 +1200 | [diff] [blame] | 2126 | interface->u.response_buffer.response.size); |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 2127 | else { |
| 2128 | HPI_DEBUG_LOG(ERROR, |
| 2129 | "response len %d too big for buffer %d\n", |
Eliot Blennerhassett | c6c2c9a | 2011-07-22 15:52:38 +1200 | [diff] [blame] | 2130 | interface->u.response_buffer.response.size, |
| 2131 | phr->size); |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 2132 | memcpy(phr, &interface->u.response_buffer, |
| 2133 | sizeof(struct hpi_response_header)); |
| 2134 | phr->error = HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL; |
| 2135 | phr->specific_error = |
Eliot Blennerhassett | c6c2c9a | 2011-07-22 15:52:38 +1200 | [diff] [blame] | 2136 | interface->u.response_buffer.response.size; |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 2137 | phr->size = sizeof(struct hpi_response_header); |
| 2138 | } |
| 2139 | } |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 2140 | /* set interface back to idle */ |
| 2141 | send_dsp_command(phw, H620_HIF_IDLE); |
| 2142 | |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 2143 | if (!time_out || !time_out2) { |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 2144 | HPI_DEBUG_LOG(DEBUG, "something timed out!\n"); |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 2145 | return HPI6205_ERROR_MSG_RESP_TIMEOUT; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 2146 | } |
| 2147 | /* special case for adapter close - */ |
| 2148 | /* wait for the DSP to indicate it is idle */ |
| 2149 | if (phm->function == HPI_ADAPTER_CLOSE) { |
| 2150 | if (!wait_dsp_ack(phw, H620_HIF_IDLE, HPI6205_TIMEOUT)) { |
| 2151 | HPI_DEBUG_LOG(DEBUG, |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 2152 | "Timeout waiting for idle " |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 2153 | "(on adapter_close)\n"); |
Eliot Blennerhassett | 3285ea1 | 2011-02-10 17:25:58 +1300 | [diff] [blame] | 2154 | return HPI6205_ERROR_MSG_RESP_IDLE_TIMEOUT; |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 2155 | } |
| 2156 | } |
| 2157 | err = hpi_validate_response(phm, phr); |
| 2158 | return err; |
| 2159 | } |
| 2160 | |
| 2161 | static void hw_message(struct hpi_adapter_obj *pao, struct hpi_message *phm, |
| 2162 | struct hpi_response *phr) |
| 2163 | { |
| 2164 | |
| 2165 | u16 err = 0; |
| 2166 | |
| 2167 | hpios_dsplock_lock(pao); |
| 2168 | |
| 2169 | err = message_response_sequence(pao, phm, phr); |
| 2170 | |
| 2171 | /* maybe an error response */ |
| 2172 | if (err) { |
| 2173 | /* something failed in the HPI/DSP interface */ |
Eliot Blennerhassett | 0a00044 | 2011-02-10 17:26:05 +1300 | [diff] [blame] | 2174 | if (err >= HPI_ERROR_BACKEND_BASE) { |
| 2175 | phr->error = HPI_ERROR_DSP_COMMUNICATION; |
| 2176 | phr->specific_error = err; |
| 2177 | } else { |
| 2178 | phr->error = err; |
| 2179 | } |
| 2180 | |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 2181 | pao->dsp_crashed++; |
| 2182 | |
| 2183 | /* just the header of the response is valid */ |
| 2184 | phr->size = sizeof(struct hpi_response_header); |
| 2185 | goto err; |
| 2186 | } else |
| 2187 | pao->dsp_crashed = 0; |
| 2188 | |
| 2189 | if (phr->error != 0) /* something failed in the DSP */ |
| 2190 | goto err; |
| 2191 | |
| 2192 | switch (phm->function) { |
| 2193 | case HPI_OSTREAM_WRITE: |
| 2194 | case HPI_ISTREAM_ANC_WRITE: |
| 2195 | err = hpi6205_transfer_data(pao, phm->u.d.u.data.pb_data, |
| 2196 | phm->u.d.u.data.data_size, H620_HIF_SEND_DATA); |
| 2197 | break; |
| 2198 | |
| 2199 | case HPI_ISTREAM_READ: |
| 2200 | case HPI_OSTREAM_ANC_READ: |
| 2201 | err = hpi6205_transfer_data(pao, phm->u.d.u.data.pb_data, |
| 2202 | phm->u.d.u.data.data_size, H620_HIF_GET_DATA); |
| 2203 | break; |
| 2204 | |
Eliot Blennerhassett | 719f82d | 2010-04-21 18:17:39 +0200 | [diff] [blame] | 2205 | } |
| 2206 | phr->error = err; |
| 2207 | |
| 2208 | err: |
| 2209 | hpios_dsplock_unlock(pao); |
| 2210 | |
| 2211 | return; |
| 2212 | } |