Lines Matching full:data
26 #define PCH_SPDWR 0x0C /* SPI write data register */
27 #define PCH_SPDRR 0x10 /* SPI read data register */
136 * @bpw_len: Length of data to be transferred in bits per
139 * @tx_index: Transmit data count; for bookkeeping during
141 * @rx_index: Receive data count; for bookkeeping during
143 * @pkt_tx_buff: Buffer for data to be transmitted
144 * @pkt_rx_buff: Buffer for received data
153 * @board_dat: Reference to the SPI device data structure
159 * @save_total_len: Save length while data is being transferred
225 struct pch_spi_data *data = spi_master_get_devdata(master); in pch_spi_writereg() local
226 iowrite32(val, (data->io_remap_addr + idx)); in pch_spi_writereg()
236 struct pch_spi_data *data = spi_master_get_devdata(master); in pch_spi_readreg() local
237 return ioread32(data->io_remap_addr + idx); in pch_spi_readreg()
263 static void pch_spi_handler_sub(struct pch_spi_data *data, u32 reg_spsr_val, in pch_spi_handler_sub() argument
277 if (data->transfer_active) { in pch_spi_handler_sub()
278 rx_index = data->rx_index; in pch_spi_handler_sub()
279 tx_index = data->tx_index; in pch_spi_handler_sub()
280 bpw_len = data->bpw_len; in pch_spi_handler_sub()
281 pkt_rx_buffer = data->pkt_rx_buff; in pch_spi_handler_sub()
282 pkt_tx_buff = data->pkt_tx_buff; in pch_spi_handler_sub()
308 data->tx_index = tx_index; in pch_spi_handler_sub()
309 data->rx_index = rx_index; in pch_spi_handler_sub()
315 pch_spi_setclr_reg(data->master, PCH_SPCR, 0, in pch_spi_handler_sub()
320 data->transfer_complete = true; in pch_spi_handler_sub()
321 data->transfer_active = false; in pch_spi_handler_sub()
322 wake_up(&data->wait); in pch_spi_handler_sub()
324 dev_vdbg(&data->master->dev, in pch_spi_handler_sub()
343 struct pch_spi_data *data = dev_id; in pch_spi_handler() local
344 struct pch_spi_board_data *board_dat = data->board_dat; in pch_spi_handler()
352 io_remap_addr = data->io_remap_addr; in pch_spi_handler()
359 if (data->current_msg->complete) { in pch_spi_handler()
360 data->transfer_complete = true; in pch_spi_handler()
361 data->current_msg->status = -EIO; in pch_spi_handler()
362 data->current_msg->complete(data->current_msg->context); in pch_spi_handler()
363 data->bcurrent_msg_processing = false; in pch_spi_handler()
364 data->current_msg = NULL; in pch_spi_handler()
365 data->cur_trans = NULL; in pch_spi_handler()
369 if (data->use_dma) in pch_spi_handler()
374 pch_spi_handler_sub(data, reg_spsr_val, io_remap_addr); in pch_spi_handler()
458 struct pch_spi_data *data = spi_master_get_devdata(pspi->master); in pch_spi_transfer() local
463 if (data->status == STATUS_EXITING) { in pch_spi_transfer()
470 if (data->board_dat->suspend_sts) { in pch_spi_transfer()
481 spin_lock_irqsave(&data->lock, flags); in pch_spi_transfer()
483 list_add_tail(&pmsg->queue, &data->queue); in pch_spi_transfer()
484 spin_unlock_irqrestore(&data->lock, flags); in pch_spi_transfer()
488 schedule_work(&data->work); in pch_spi_transfer()
498 static inline void pch_spi_select_chip(struct pch_spi_data *data, in pch_spi_select_chip() argument
501 if (data->current_chip != NULL) { in pch_spi_select_chip()
502 if (pspi->chip_select != data->n_curnt_chip) { in pch_spi_select_chip()
504 data->current_chip = NULL; in pch_spi_select_chip()
508 data->current_chip = pspi; in pch_spi_select_chip()
510 data->n_curnt_chip = data->current_chip->chip_select; in pch_spi_select_chip()
516 static void pch_spi_set_tx(struct pch_spi_data *data, int *bpw) in pch_spi_set_tx() argument
526 if (data->cur_trans->speed_hz) { in pch_spi_set_tx()
527 dev_dbg(&data->master->dev, "%s:setting baud rate\n", __func__); in pch_spi_set_tx()
528 pch_spi_set_baud_rate(data->master, data->cur_trans->speed_hz); in pch_spi_set_tx()
532 if (data->cur_trans->bits_per_word && in pch_spi_set_tx()
533 (data->current_msg->spi->bits_per_word != data->cur_trans->bits_per_word)) { in pch_spi_set_tx()
534 dev_dbg(&data->master->dev, "%s:set bits per word\n", __func__); in pch_spi_set_tx()
535 pch_spi_set_bits_per_word(data->master, in pch_spi_set_tx()
536 data->cur_trans->bits_per_word); in pch_spi_set_tx()
537 *bpw = data->cur_trans->bits_per_word; in pch_spi_set_tx()
539 *bpw = data->current_msg->spi->bits_per_word; in pch_spi_set_tx()
543 data->tx_index = 0; in pch_spi_set_tx()
544 data->rx_index = 0; in pch_spi_set_tx()
546 data->bpw_len = data->cur_trans->len / (*bpw / 8); in pch_spi_set_tx()
549 size = data->cur_trans->len * sizeof(*data->pkt_tx_buff); in pch_spi_set_tx()
552 data->pkt_tx_buff = kzalloc(size, GFP_KERNEL); in pch_spi_set_tx()
553 if (data->pkt_tx_buff != NULL) { in pch_spi_set_tx()
554 data->pkt_rx_buff = kzalloc(size, GFP_KERNEL); in pch_spi_set_tx()
555 if (!data->pkt_rx_buff) { in pch_spi_set_tx()
556 kfree(data->pkt_tx_buff); in pch_spi_set_tx()
557 data->pkt_tx_buff = NULL; in pch_spi_set_tx()
561 if (!data->pkt_rx_buff) { in pch_spi_set_tx()
563 list_for_each_entry_safe(pmsg, tmp, data->queue.next, queue) { in pch_spi_set_tx()
575 /* copy Tx Data */ in pch_spi_set_tx()
576 if (data->cur_trans->tx_buf != NULL) { in pch_spi_set_tx()
578 tx_buf = data->cur_trans->tx_buf; in pch_spi_set_tx()
579 for (j = 0; j < data->bpw_len; j++) in pch_spi_set_tx()
580 data->pkt_tx_buff[j] = *tx_buf++; in pch_spi_set_tx()
582 tx_sbuf = data->cur_trans->tx_buf; in pch_spi_set_tx()
583 for (j = 0; j < data->bpw_len; j++) in pch_spi_set_tx()
584 data->pkt_tx_buff[j] = *tx_sbuf++; in pch_spi_set_tx()
589 n_writes = data->bpw_len; in pch_spi_set_tx()
593 dev_dbg(&data->master->dev, in pch_spi_set_tx()
596 pch_spi_writereg(data->master, PCH_SSNXCR, SSN_LOW); in pch_spi_set_tx()
599 pch_spi_writereg(data->master, PCH_SPDWR, data->pkt_tx_buff[j]); in pch_spi_set_tx()
602 data->tx_index = j; in pch_spi_set_tx()
605 data->transfer_complete = false; in pch_spi_set_tx()
606 data->transfer_active = true; in pch_spi_set_tx()
609 static void pch_spi_nomore_transfer(struct pch_spi_data *data) in pch_spi_nomore_transfer() argument
612 dev_dbg(&data->master->dev, "%s called\n", __func__); in pch_spi_nomore_transfer()
615 data->current_msg->status = 0; in pch_spi_nomore_transfer()
617 if (data->current_msg->complete) { in pch_spi_nomore_transfer()
618 dev_dbg(&data->master->dev, in pch_spi_nomore_transfer()
620 data->current_msg->complete(data->current_msg->context); in pch_spi_nomore_transfer()
624 data->bcurrent_msg_processing = false; in pch_spi_nomore_transfer()
626 dev_dbg(&data->master->dev, in pch_spi_nomore_transfer()
627 "%s:data->bcurrent_msg_processing = false\n", __func__); in pch_spi_nomore_transfer()
629 data->current_msg = NULL; in pch_spi_nomore_transfer()
630 data->cur_trans = NULL; in pch_spi_nomore_transfer()
634 if ((list_empty(&data->queue) == 0) && in pch_spi_nomore_transfer()
635 (!data->board_dat->suspend_sts) && in pch_spi_nomore_transfer()
636 (data->status != STATUS_EXITING)) { in pch_spi_nomore_transfer()
641 dev_dbg(&data->master->dev, "%s:Invoke queue_work\n", __func__); in pch_spi_nomore_transfer()
642 schedule_work(&data->work); in pch_spi_nomore_transfer()
643 } else if (data->board_dat->suspend_sts || in pch_spi_nomore_transfer()
644 data->status == STATUS_EXITING) { in pch_spi_nomore_transfer()
645 dev_dbg(&data->master->dev, in pch_spi_nomore_transfer()
648 list_for_each_entry_safe(pmsg, tmp, data->queue.next, queue) { in pch_spi_nomore_transfer()
660 static void pch_spi_set_ir(struct pch_spi_data *data) in pch_spi_set_ir() argument
663 if ((data->bpw_len) > PCH_MAX_FIFO_DEPTH) in pch_spi_set_ir()
665 pch_spi_setclr_reg(data->master, PCH_SPCR, in pch_spi_set_ir()
672 pch_spi_setclr_reg(data->master, PCH_SPCR, in pch_spi_set_ir()
680 dev_dbg(&data->master->dev, in pch_spi_set_ir()
683 wait_event_interruptible(data->wait, data->transfer_complete); in pch_spi_set_ir()
686 pch_spi_writereg(data->master, PCH_SPSR, in pch_spi_set_ir()
687 pch_spi_readreg(data->master, PCH_SPSR)); in pch_spi_set_ir()
689 pch_spi_setclr_reg(data->master, PCH_SPCR, 0, PCH_ALL | SPCR_SPE_BIT); in pch_spi_set_ir()
691 pch_spi_clear_fifo(data->master); in pch_spi_set_ir()
694 static void pch_spi_copy_rx_data(struct pch_spi_data *data, int bpw) in pch_spi_copy_rx_data() argument
700 /* copy Rx Data */ in pch_spi_copy_rx_data()
701 if (!data->cur_trans->rx_buf) in pch_spi_copy_rx_data()
705 rx_buf = data->cur_trans->rx_buf; in pch_spi_copy_rx_data()
706 for (j = 0; j < data->bpw_len; j++) in pch_spi_copy_rx_data()
707 *rx_buf++ = data->pkt_rx_buff[j] & 0xFF; in pch_spi_copy_rx_data()
709 rx_sbuf = data->cur_trans->rx_buf; in pch_spi_copy_rx_data()
710 for (j = 0; j < data->bpw_len; j++) in pch_spi_copy_rx_data()
711 *rx_sbuf++ = data->pkt_rx_buff[j]; in pch_spi_copy_rx_data()
715 static void pch_spi_copy_rx_data_for_dma(struct pch_spi_data *data, int bpw) in pch_spi_copy_rx_data_for_dma() argument
723 /* copy Rx Data */ in pch_spi_copy_rx_data_for_dma()
724 if (!data->cur_trans->rx_buf) in pch_spi_copy_rx_data_for_dma()
728 rx_buf = data->cur_trans->rx_buf; in pch_spi_copy_rx_data_for_dma()
729 rx_dma_buf = data->dma.rx_buf_virt; in pch_spi_copy_rx_data_for_dma()
730 for (j = 0; j < data->bpw_len; j++) in pch_spi_copy_rx_data_for_dma()
732 data->cur_trans->rx_buf = rx_buf; in pch_spi_copy_rx_data_for_dma()
734 rx_sbuf = data->cur_trans->rx_buf; in pch_spi_copy_rx_data_for_dma()
735 rx_dma_sbuf = data->dma.rx_buf_virt; in pch_spi_copy_rx_data_for_dma()
736 for (j = 0; j < data->bpw_len; j++) in pch_spi_copy_rx_data_for_dma()
738 data->cur_trans->rx_buf = rx_sbuf; in pch_spi_copy_rx_data_for_dma()
742 static int pch_spi_start_transfer(struct pch_spi_data *data) in pch_spi_start_transfer() argument
748 dma = &data->dma; in pch_spi_start_transfer()
750 spin_lock_irqsave(&data->lock, flags); in pch_spi_start_transfer()
753 pch_spi_setclr_reg(data->master, PCH_SPCR, SPCR_SPE_BIT, PCH_ALL); in pch_spi_start_transfer()
755 spin_unlock_irqrestore(&data->lock, flags); in pch_spi_start_transfer()
759 dev_dbg(&data->master->dev, in pch_spi_start_transfer()
761 rtn = wait_event_interruptible_timeout(data->wait, in pch_spi_start_transfer()
762 data->transfer_complete, in pch_spi_start_transfer()
765 dev_err(&data->master->dev, in pch_spi_start_transfer()
768 dma_sync_sg_for_cpu(&data->master->dev, dma->sg_rx_p, dma->nent, in pch_spi_start_transfer()
771 dma_sync_sg_for_cpu(&data->master->dev, dma->sg_tx_p, dma->nent, in pch_spi_start_transfer()
773 memset(data->dma.tx_buf_virt, 0, PAGE_SIZE); in pch_spi_start_transfer()
780 spin_lock_irqsave(&data->lock, flags); in pch_spi_start_transfer()
783 pch_spi_setclr_reg(data->master, PCH_SPCR, 0, in pch_spi_start_transfer()
787 pch_spi_writereg(data->master, PCH_SPSR, in pch_spi_start_transfer()
788 pch_spi_readreg(data->master, PCH_SPSR)); in pch_spi_start_transfer()
790 pch_spi_clear_fifo(data->master); in pch_spi_start_transfer()
792 spin_unlock_irqrestore(&data->lock, flags); in pch_spi_start_transfer()
799 struct pch_spi_data *data = arg; in pch_dma_rx_complete() local
802 data->transfer_complete = true; in pch_dma_rx_complete()
803 wake_up_interruptible(&data->wait); in pch_dma_rx_complete()
819 static void pch_spi_request_dma(struct pch_spi_data *data, int bpw) in pch_spi_request_dma() argument
833 dma = &data->dma; in pch_spi_request_dma()
838 dma_dev = pci_get_slot(data->board_dat->pdev->bus, in pch_spi_request_dma()
839 PCI_DEVFN(PCI_SLOT(data->board_dat->pdev->devfn), 0)); in pch_spi_request_dma()
844 param->chan_id = data->ch * 2; /* Tx = 0, 2 */ in pch_spi_request_dma()
845 param->tx_reg = data->io_base_addr + PCH_SPDWR; in pch_spi_request_dma()
849 dev_err(&data->master->dev, in pch_spi_request_dma()
858 param->chan_id = data->ch * 2 + 1; /* Rx = Tx + 1 */ in pch_spi_request_dma()
859 param->rx_reg = data->io_base_addr + PCH_SPDRR; in pch_spi_request_dma()
863 dev_err(&data->master->dev, in pch_spi_request_dma()
875 data->use_dma = 0; in pch_spi_request_dma()
878 static void pch_spi_release_dma(struct pch_spi_data *data) in pch_spi_release_dma() argument
882 dma = &data->dma; in pch_spi_release_dma()
895 static void pch_spi_handle_dma(struct pch_spi_data *data, int *bpw) in pch_spi_handle_dma() argument
912 dma = &data->dma; in pch_spi_handle_dma()
915 if (data->cur_trans->speed_hz) { in pch_spi_handle_dma()
916 dev_dbg(&data->master->dev, "%s:setting baud rate\n", __func__); in pch_spi_handle_dma()
917 spin_lock_irqsave(&data->lock, flags); in pch_spi_handle_dma()
918 pch_spi_set_baud_rate(data->master, data->cur_trans->speed_hz); in pch_spi_handle_dma()
919 spin_unlock_irqrestore(&data->lock, flags); in pch_spi_handle_dma()
923 if (data->cur_trans->bits_per_word && in pch_spi_handle_dma()
924 (data->current_msg->spi->bits_per_word != in pch_spi_handle_dma()
925 data->cur_trans->bits_per_word)) { in pch_spi_handle_dma()
926 dev_dbg(&data->master->dev, "%s:set bits per word\n", __func__); in pch_spi_handle_dma()
927 spin_lock_irqsave(&data->lock, flags); in pch_spi_handle_dma()
928 pch_spi_set_bits_per_word(data->master, in pch_spi_handle_dma()
929 data->cur_trans->bits_per_word); in pch_spi_handle_dma()
930 spin_unlock_irqrestore(&data->lock, flags); in pch_spi_handle_dma()
931 *bpw = data->cur_trans->bits_per_word; in pch_spi_handle_dma()
933 *bpw = data->current_msg->spi->bits_per_word; in pch_spi_handle_dma()
935 data->bpw_len = data->cur_trans->len / (*bpw / 8); in pch_spi_handle_dma()
937 if (data->bpw_len > PCH_BUF_SIZE) { in pch_spi_handle_dma()
938 data->bpw_len = PCH_BUF_SIZE; in pch_spi_handle_dma()
939 data->cur_trans->len -= PCH_BUF_SIZE; in pch_spi_handle_dma()
942 /* copy Tx Data */ in pch_spi_handle_dma()
943 if (data->cur_trans->tx_buf != NULL) { in pch_spi_handle_dma()
945 tx_buf = data->cur_trans->tx_buf; in pch_spi_handle_dma()
947 for (i = 0; i < data->bpw_len; i++) in pch_spi_handle_dma()
950 tx_sbuf = data->cur_trans->tx_buf; in pch_spi_handle_dma()
952 for (i = 0; i < data->bpw_len; i++) in pch_spi_handle_dma()
958 if (data->bpw_len > PCH_DMA_TRANS_SIZE) { in pch_spi_handle_dma()
959 if (data->bpw_len % PCH_DMA_TRANS_SIZE) { in pch_spi_handle_dma()
960 num = data->bpw_len / PCH_DMA_TRANS_SIZE + 1; in pch_spi_handle_dma()
961 rem = data->bpw_len % PCH_DMA_TRANS_SIZE; in pch_spi_handle_dma()
963 num = data->bpw_len / PCH_DMA_TRANS_SIZE; in pch_spi_handle_dma()
969 size = data->bpw_len; in pch_spi_handle_dma()
970 rem = data->bpw_len; in pch_spi_handle_dma()
972 dev_dbg(&data->master->dev, "%s num=%d size=%d rem=%d\n", in pch_spi_handle_dma()
974 spin_lock_irqsave(&data->lock, flags); in pch_spi_handle_dma()
977 pch_spi_setclr_reg(data->master, PCH_SPCR, in pch_spi_handle_dma()
982 spin_unlock_irqrestore(&data->lock, flags); in pch_spi_handle_dma()
1019 dev_err(&data->master->dev, in pch_spi_handle_dma()
1023 dma_sync_sg_for_device(&data->master->dev, sg, num, DMA_FROM_DEVICE); in pch_spi_handle_dma()
1025 desc_rx->callback_param = data; in pch_spi_handle_dma()
1030 if (data->bpw_len > PCH_MAX_FIFO_DEPTH) { in pch_spi_handle_dma()
1032 if (data->bpw_len % PCH_DMA_TRANS_SIZE > 4) { in pch_spi_handle_dma()
1033 num = data->bpw_len / PCH_DMA_TRANS_SIZE + 1; in pch_spi_handle_dma()
1034 rem = data->bpw_len % PCH_DMA_TRANS_SIZE - head; in pch_spi_handle_dma()
1036 num = data->bpw_len / PCH_DMA_TRANS_SIZE; in pch_spi_handle_dma()
1037 rem = data->bpw_len % PCH_DMA_TRANS_SIZE + in pch_spi_handle_dma()
1043 size = data->bpw_len; in pch_spi_handle_dma()
1044 rem = data->bpw_len; in pch_spi_handle_dma()
1081 dev_err(&data->master->dev, in pch_spi_handle_dma()
1085 dma_sync_sg_for_device(&data->master->dev, sg, num, DMA_TO_DEVICE); in pch_spi_handle_dma()
1087 desc_tx->callback_param = data; in pch_spi_handle_dma()
1091 dev_dbg(&data->master->dev, "%s:Pulling down SSN low - writing 0x2 to SSNXCR\n", __func__); in pch_spi_handle_dma()
1093 spin_lock_irqsave(&data->lock, flags); in pch_spi_handle_dma()
1094 pch_spi_writereg(data->master, PCH_SSNXCR, SSN_LOW); in pch_spi_handle_dma()
1097 spin_unlock_irqrestore(&data->lock, flags); in pch_spi_handle_dma()
1100 data->transfer_complete = false; in pch_spi_handle_dma()
1106 struct pch_spi_data *data; in pch_spi_process_messages() local
1109 data = container_of(pwork, struct pch_spi_data, work); in pch_spi_process_messages()
1110 dev_dbg(&data->master->dev, "%s data initialized\n", __func__); in pch_spi_process_messages()
1112 spin_lock(&data->lock); in pch_spi_process_messages()
1114 if (data->board_dat->suspend_sts || (data->status == STATUS_EXITING)) { in pch_spi_process_messages()
1115 dev_dbg(&data->master->dev, in pch_spi_process_messages()
1117 list_for_each_entry_safe(pmsg, tmp, data->queue.next, queue) { in pch_spi_process_messages()
1121 spin_unlock(&data->lock); in pch_spi_process_messages()
1123 spin_lock(&data->lock); in pch_spi_process_messages()
1130 spin_unlock(&data->lock); in pch_spi_process_messages()
1134 data->bcurrent_msg_processing = true; in pch_spi_process_messages()
1135 dev_dbg(&data->master->dev, in pch_spi_process_messages()
1136 "%s Set data->bcurrent_msg_processing= true\n", __func__); in pch_spi_process_messages()
1139 data->current_msg = list_entry(data->queue.next, struct spi_message, in pch_spi_process_messages()
1142 list_del_init(&data->current_msg->queue); in pch_spi_process_messages()
1144 data->current_msg->status = 0; in pch_spi_process_messages()
1146 pch_spi_select_chip(data, data->current_msg->spi); in pch_spi_process_messages()
1148 spin_unlock(&data->lock); in pch_spi_process_messages()
1150 if (data->use_dma) in pch_spi_process_messages()
1151 pch_spi_request_dma(data, in pch_spi_process_messages()
1152 data->current_msg->spi->bits_per_word); in pch_spi_process_messages()
1153 pch_spi_writereg(data->master, PCH_SSNXCR, SSN_NO_CONTROL); in pch_spi_process_messages()
1159 spin_lock(&data->lock); in pch_spi_process_messages()
1160 if (data->cur_trans == NULL) { in pch_spi_process_messages()
1161 data->cur_trans = in pch_spi_process_messages()
1162 list_entry(data->current_msg->transfers.next, in pch_spi_process_messages()
1164 dev_dbg(&data->master->dev, in pch_spi_process_messages()
1168 data->cur_trans = in pch_spi_process_messages()
1169 list_entry(data->cur_trans->transfer_list.next, in pch_spi_process_messages()
1171 dev_dbg(&data->master->dev, in pch_spi_process_messages()
1175 spin_unlock(&data->lock); in pch_spi_process_messages()
1177 if (!data->cur_trans->len) in pch_spi_process_messages()
1179 cnt = (data->cur_trans->len - 1) / PCH_BUF_SIZE + 1; in pch_spi_process_messages()
1180 data->save_total_len = data->cur_trans->len; in pch_spi_process_messages()
1181 if (data->use_dma) { in pch_spi_process_messages()
1183 char *save_rx_buf = data->cur_trans->rx_buf; in pch_spi_process_messages()
1186 pch_spi_handle_dma(data, &bpw); in pch_spi_process_messages()
1187 if (!pch_spi_start_transfer(data)) { in pch_spi_process_messages()
1188 data->transfer_complete = true; in pch_spi_process_messages()
1189 data->current_msg->status = -EIO; in pch_spi_process_messages()
1190 data->current_msg->complete in pch_spi_process_messages()
1191 (data->current_msg->context); in pch_spi_process_messages()
1192 data->bcurrent_msg_processing = false; in pch_spi_process_messages()
1193 data->current_msg = NULL; in pch_spi_process_messages()
1194 data->cur_trans = NULL; in pch_spi_process_messages()
1197 pch_spi_copy_rx_data_for_dma(data, bpw); in pch_spi_process_messages()
1199 data->cur_trans->rx_buf = save_rx_buf; in pch_spi_process_messages()
1201 pch_spi_set_tx(data, &bpw); in pch_spi_process_messages()
1202 pch_spi_set_ir(data); in pch_spi_process_messages()
1203 pch_spi_copy_rx_data(data, bpw); in pch_spi_process_messages()
1204 kfree(data->pkt_rx_buff); in pch_spi_process_messages()
1205 data->pkt_rx_buff = NULL; in pch_spi_process_messages()
1206 kfree(data->pkt_tx_buff); in pch_spi_process_messages()
1207 data->pkt_tx_buff = NULL; in pch_spi_process_messages()
1210 data->cur_trans->len = data->save_total_len; in pch_spi_process_messages()
1211 data->current_msg->actual_length += data->cur_trans->len; in pch_spi_process_messages()
1213 dev_dbg(&data->master->dev, in pch_spi_process_messages()
1214 "%s:data->current_msg->actual_length=%d\n", in pch_spi_process_messages()
1215 __func__, data->current_msg->actual_length); in pch_spi_process_messages()
1217 spi_transfer_delay_exec(data->cur_trans); in pch_spi_process_messages()
1219 spin_lock(&data->lock); in pch_spi_process_messages()
1222 if ((data->cur_trans->transfer_list.next) == in pch_spi_process_messages()
1223 &(data->current_msg->transfers)) { in pch_spi_process_messages()
1224 pch_spi_nomore_transfer(data); in pch_spi_process_messages()
1227 spin_unlock(&data->lock); in pch_spi_process_messages()
1229 } while (data->cur_trans != NULL); in pch_spi_process_messages()
1232 pch_spi_writereg(data->master, PCH_SSNXCR, SSN_HIGH); in pch_spi_process_messages()
1233 if (data->use_dma) in pch_spi_process_messages()
1234 pch_spi_release_dma(data); in pch_spi_process_messages()
1238 struct pch_spi_data *data) in pch_spi_free_resources() argument
1242 flush_work(&data->work); in pch_spi_free_resources()
1246 struct pch_spi_data *data) in pch_spi_get_resources() argument
1251 pch_spi_reset(data->master); in pch_spi_get_resources()
1255 dev_dbg(&board_dat->pdev->dev, "%s data->irq_reg_sts=true\n", __func__); in pch_spi_get_resources()
1261 struct pch_spi_data *data) in pch_free_dma_buf() argument
1265 dma = &data->dma; in pch_free_dma_buf()
1275 struct pch_spi_data *data) in pch_alloc_dma_buf() argument
1280 dma = &data->dma; in pch_alloc_dma_buf()
1302 struct pch_spi_data *data; in pch_spi_pd_probe() local
1314 data = spi_master_get_devdata(master); in pch_spi_pd_probe()
1315 data->master = master; in pch_spi_pd_probe()
1317 platform_set_drvdata(plat_dev, data); in pch_spi_pd_probe()
1320 data->io_base_addr = pci_resource_start(board_dat->pdev, 1) + in pch_spi_pd_probe()
1322 data->io_remap_addr = pci_iomap(board_dat->pdev, 1, 0); in pch_spi_pd_probe()
1323 if (!data->io_remap_addr) { in pch_spi_pd_probe()
1328 data->io_remap_addr += PCH_ADDRESS_SIZE * plat_dev->id; in pch_spi_pd_probe()
1331 plat_dev->id, data->io_remap_addr); in pch_spi_pd_probe()
1341 data->board_dat = board_dat; in pch_spi_pd_probe()
1342 data->plat_dev = plat_dev; in pch_spi_pd_probe()
1343 data->n_curnt_chip = 255; in pch_spi_pd_probe()
1344 data->status = STATUS_RUNNING; in pch_spi_pd_probe()
1345 data->ch = plat_dev->id; in pch_spi_pd_probe()
1346 data->use_dma = use_dma; in pch_spi_pd_probe()
1348 INIT_LIST_HEAD(&data->queue); in pch_spi_pd_probe()
1349 spin_lock_init(&data->lock); in pch_spi_pd_probe()
1350 INIT_WORK(&data->work, pch_spi_process_messages); in pch_spi_pd_probe()
1351 init_waitqueue_head(&data->wait); in pch_spi_pd_probe()
1353 ret = pch_spi_get_resources(board_dat, data); in pch_spi_pd_probe()
1360 IRQF_SHARED, KBUILD_MODNAME, data); in pch_spi_pd_probe()
1366 data->irq_reg_sts = true; in pch_spi_pd_probe()
1371 dev_info(&plat_dev->dev, "Use DMA for data transfers\n"); in pch_spi_pd_probe()
1372 ret = pch_alloc_dma_buf(board_dat, data); in pch_spi_pd_probe()
1387 pch_free_dma_buf(board_dat, data); in pch_spi_pd_probe()
1388 free_irq(board_dat->pdev->irq, data); in pch_spi_pd_probe()
1390 pch_spi_free_resources(board_dat, data); in pch_spi_pd_probe()
1392 pci_iounmap(board_dat->pdev, data->io_remap_addr); in pch_spi_pd_probe()
1402 struct pch_spi_data *data = platform_get_drvdata(plat_dev); in pch_spi_pd_remove() local
1410 pch_free_dma_buf(board_dat, data); in pch_spi_pd_remove()
1415 spin_lock_irqsave(&data->lock, flags); in pch_spi_pd_remove()
1416 data->status = STATUS_EXITING; in pch_spi_pd_remove()
1417 while ((list_empty(&data->queue) == 0) && --count) { in pch_spi_pd_remove()
1420 spin_unlock_irqrestore(&data->lock, flags); in pch_spi_pd_remove()
1422 spin_lock_irqsave(&data->lock, flags); in pch_spi_pd_remove()
1424 spin_unlock_irqrestore(&data->lock, flags); in pch_spi_pd_remove()
1426 pch_spi_free_resources(board_dat, data); in pch_spi_pd_remove()
1428 if (data->irq_reg_sts) { in pch_spi_pd_remove()
1430 pch_spi_setclr_reg(data->master, PCH_SPCR, 0, PCH_ALL); in pch_spi_pd_remove()
1431 data->irq_reg_sts = false; in pch_spi_pd_remove()
1432 free_irq(board_dat->pdev->irq, data); in pch_spi_pd_remove()
1435 pci_iounmap(board_dat->pdev, data->io_remap_addr); in pch_spi_pd_remove()
1436 spi_unregister_master(data->master); in pch_spi_pd_remove()
1446 struct pch_spi_data *data = platform_get_drvdata(pd_dev); in pch_spi_pd_suspend() local
1460 if (!(data->bcurrent_msg_processing)) in pch_spi_pd_suspend()
1466 if (data->irq_reg_sts) { in pch_spi_pd_suspend()
1468 pch_spi_setclr_reg(data->master, PCH_SPCR, 0, PCH_ALL); in pch_spi_pd_suspend()
1469 pch_spi_reset(data->master); in pch_spi_pd_suspend()
1470 free_irq(board_dat->pdev->irq, data); in pch_spi_pd_suspend()
1472 data->irq_reg_sts = false; in pch_spi_pd_suspend()
1483 struct pch_spi_data *data = platform_get_drvdata(pd_dev); in pch_spi_pd_resume() local
1492 if (!data->irq_reg_sts) { in pch_spi_pd_resume()
1495 IRQF_SHARED, KBUILD_MODNAME, data); in pch_spi_pd_resume()
1503 pch_spi_reset(data->master); in pch_spi_pd_resume()
1504 pch_spi_set_master_mode(data->master); in pch_spi_pd_resume()
1505 data->irq_reg_sts = true; in pch_spi_pd_resume()
1679 "to use DMA for data transfers pass 1 else 0; default 1");