Scott Jiang | d2aae47 | 2012-06-20 17:00:30 -0400 | [diff] [blame] | 1 | /* |
| 2 | * bf6xx_sport - Analog Devices BF6XX SPORT driver |
| 3 | * |
| 4 | * Copyright (c) 2012 Analog Devices Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2 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., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 18 | */ |
| 19 | |
| 20 | #ifndef _BF6XX_SPORT_H_ |
| 21 | #define _BF6XX_SPORT_H_ |
| 22 | |
| 23 | #include <linux/platform_device.h> |
| 24 | #include <asm/bfin_sport3.h> |
| 25 | |
| 26 | struct sport_device { |
| 27 | struct platform_device *pdev; |
| 28 | const unsigned short *pin_req; |
| 29 | struct sport_register *tx_regs; |
| 30 | struct sport_register *rx_regs; |
| 31 | int tx_dma_chan; |
| 32 | int rx_dma_chan; |
| 33 | int tx_err_irq; |
| 34 | int rx_err_irq; |
| 35 | |
| 36 | void (*tx_callback)(void *data); |
| 37 | void *tx_data; |
| 38 | void (*rx_callback)(void *data); |
| 39 | void *rx_data; |
| 40 | |
| 41 | struct dmasg *tx_desc; |
| 42 | struct dmasg *rx_desc; |
| 43 | unsigned int tx_desc_size; |
| 44 | unsigned int rx_desc_size; |
| 45 | unsigned char *tx_buf; |
| 46 | unsigned char *rx_buf; |
| 47 | unsigned int tx_fragsize; |
| 48 | unsigned int rx_fragsize; |
| 49 | unsigned int tx_frags; |
| 50 | unsigned int rx_frags; |
| 51 | unsigned int wdsize; |
| 52 | }; |
| 53 | |
| 54 | struct sport_params { |
| 55 | u32 spctl; |
| 56 | u32 div; |
| 57 | }; |
| 58 | |
| 59 | struct sport_device *sport_create(struct platform_device *pdev); |
| 60 | void sport_delete(struct sport_device *sport); |
| 61 | int sport_set_tx_params(struct sport_device *sport, |
| 62 | struct sport_params *params); |
| 63 | int sport_set_rx_params(struct sport_device *sport, |
| 64 | struct sport_params *params); |
| 65 | void sport_tx_start(struct sport_device *sport); |
| 66 | void sport_rx_start(struct sport_device *sport); |
| 67 | void sport_tx_stop(struct sport_device *sport); |
| 68 | void sport_rx_stop(struct sport_device *sport); |
| 69 | void sport_set_tx_callback(struct sport_device *sport, |
| 70 | void (*tx_callback)(void *), void *tx_data); |
| 71 | void sport_set_rx_callback(struct sport_device *sport, |
| 72 | void (*rx_callback)(void *), void *rx_data); |
| 73 | int sport_config_tx_dma(struct sport_device *sport, void *buf, |
| 74 | int fragcount, size_t fragsize); |
| 75 | int sport_config_rx_dma(struct sport_device *sport, void *buf, |
| 76 | int fragcount, size_t fragsize); |
| 77 | unsigned long sport_curr_offset_tx(struct sport_device *sport); |
| 78 | unsigned long sport_curr_offset_rx(struct sport_device *sport); |
| 79 | |
| 80 | |
| 81 | |
| 82 | #endif |