summaryrefslogtreecommitdiff
path: root/io-module/spi.c
diff options
context:
space:
mode:
authorMike Fiore <mfiore@multitech.com>2014-09-23 10:35:11 -0500
committerMike Fiore <mfiore@multitech.com>2014-09-23 10:35:11 -0500
commita21c24fa2486e4d4a3b25d0dcbf873ae62fdbcec (patch)
tree6d78da220c6235cd33408acbd22adf9b4038bbc1 /io-module/spi.c
parent24c012065ca7a764e1e51a9cfc4422d649cd2851 (diff)
downloadmts-io-a21c24fa2486e4d4a3b25d0dcbf873ae62fdbcec.tar.gz
mts-io-a21c24fa2486e4d4a3b25d0dcbf873ae62fdbcec.tar.bz2
mts-io-a21c24fa2486e4d4a3b25d0dcbf873ae62fdbcec.zip
mts-io: clean up accessory card support
use custom kernel config option MTS_NUM_ACCESSORY_PORTS to find out how many slots exist (mostly) dynamically handle any number of accessory cards streamline code to make it easier to add accessory cards in the future
Diffstat (limited to 'io-module/spi.c')
-rw-r--r--io-module/spi.c295
1 files changed, 0 insertions, 295 deletions
diff --git a/io-module/spi.c b/io-module/spi.c
index e652b90..210371c 100644
--- a/io-module/spi.c
+++ b/io-module/spi.c
@@ -40,35 +40,6 @@ MODULE_PARM_DESC(
"Maximum clock rate to be used with this device (default: 1 MHz)"
);
-static struct spi_device *spi_ap1_dout_dev;
-static struct spi_device *spi_ap2_dout_dev;
-static u8 spi_ap_dout_value;
-static DEFINE_MUTEX(spi_ap_dout_mutex);
-static unsigned int ap_dout_max_speed_hz = 1 * 1000 * 1000;
-module_param(ap_dout_max_speed_hz, uint, S_IRUGO);
-MODULE_PARM_DESC(
- ap_dout_max_speed_hz,
- "Maximum clock rate to be used with this device (default: 1 MHz)"
-);
-
-static struct spi_device *spi_ap1_din_dev;
-static struct spi_device *spi_ap2_din_dev;
-static unsigned int ap_din_max_speed_hz = 1 * 1000 * 1000;
-module_param(ap_din_max_speed_hz, uint, S_IRUGO);
-MODULE_PARM_DESC(
- ap_din_max_speed_hz,
- "Maximum clock rate to be used with this device (default: 1 MHz)"
-);
-
-static struct spi_device *spi_ap1_adc_dev;
-static struct spi_device *spi_ap2_adc_dev;
-static unsigned int ap_adc_max_speed_hz = 20 * 1000 * 1000;
-module_param(ap_adc_max_speed_hz, uint, S_IRUGO);
-MODULE_PARM_DESC(
- ap_adc_max_speed_hz,
- "Maximum clock rate to be used with this device (default: 20 MHz)"
-);
-
static struct spi_device *spi_board_temp_dev;
static unsigned int board_temp_max_speed_hz = 1 * 1000 * 1000;
module_param(board_temp_max_speed_hz, uint, S_IRUGO);
@@ -598,272 +569,6 @@ static struct spi_driver mts_spi_din_driver = {
.remove = mts_spi_din_remove,
};
-static int mts_spi_ap1_dout_probe(struct spi_device *spi)
-{
- int tmp;
-
- if (! have_accessory_card_slot_1 || mts_ap1_product_id != MTAC_GPIOB_0_0) {
- log_error("accessory card 1 digital outputs not available");
- return -ENODEV;
- }
-
- spi->max_speed_hz = ap_dout_max_speed_hz;
- spi->mode = 0;
-
- log_debug("ap1_dout_max_speed_hz: %d", ap_dout_max_speed_hz);
-
- tmp = spi_setup(spi);
- if (tmp < 0) {
- log_error("spi_setup accessory card 1 dout failed");
- return tmp;
- }
-
- spi_ap_dout_value = 0x00;
- spi_writen(spi, &spi_ap_dout_value, 1);
-
- spi_ap1_dout_dev = spi;
-
- return 0;
-}
-
-static int mts_spi_ap1_dout_remove(struct spi_device *spi)
-{
- spi_ap1_dout_dev = NULL;
-
- return 0;
-}
-
-static struct spi_driver mts_spi_ap1_dout_driver = {
- .driver = {
- .name = "mts-io-ap1-dout",
- .bus = &spi_bus_type,
- .owner = THIS_MODULE,
- },
-
- .probe = mts_spi_ap1_dout_probe,
- .remove = mts_spi_ap1_dout_remove,
-};
-
-static int mts_spi_ap1_din_probe(struct spi_device *spi)
-{
- int tmp;
-
- if (! have_accessory_card_slot_1 || mts_ap1_product_id != MTAC_GPIOB_0_0) {
- log_error("accessory card 1 digital inputs not available");
- return -ENODEV;
- }
-
- spi->max_speed_hz = ap_din_max_speed_hz;
- spi->mode = SPI_CPOL;
-
- log_debug("ap1_din_max_speed_hz: %d", ap_din_max_speed_hz);
-
- tmp = spi_setup(spi);
- if (tmp < 0) {
- log_error("spi_setup accessory card 1 din failed");
- return tmp;
- }
-
- spi_ap1_din_dev = spi;
-
- return 0;
-}
-
-static int mts_spi_ap1_din_remove(struct spi_device *spi)
-{
- spi_ap1_din_dev = NULL;
-
- return 0;
-}
-
-static struct spi_driver mts_spi_ap1_din_driver = {
- .driver = {
- .name = "mts-io-ap1-din",
- .bus = &spi_bus_type,
- .owner = THIS_MODULE,
- },
-
- .probe = mts_spi_ap1_din_probe,
- .remove = mts_spi_ap1_din_remove,
-};
-
-static int mts_spi_ap1_adc_probe(struct spi_device *spi)
-{
- int tmp;
-
- if (! have_accessory_card_slot_1 || mts_ap1_product_id != MTAC_GPIOB_0_0) {
- log_error("accessory card 1 analog to digital not available");
- return -ENODEV;
- }
-
- spi->max_speed_hz = ap_adc_max_speed_hz;
- spi->mode = 0;
-
- log_debug("ap1_adc_max_speed_hz: %d", ap_adc_max_speed_hz);
- log_debug("ap1_adc_mode: %d", spi->mode);
-
- tmp = spi_setup(spi);
- if (tmp < 0) {
- log_error("spi_setup accessory card 1 adc failed");
- return tmp;
- }
-
- spi_ap1_adc_dev = spi;
-
- return 0;
-}
-
-static int mts_spi_ap1_adc_remove(struct spi_device *spi)
-{
- spi_ap1_adc_dev = NULL;
-
- return 0;
-}
-
-static struct spi_driver mts_spi_ap1_adc_driver = {
- .driver = {
- .name = "mts-io-ap1-adc",
- .bus = &spi_bus_type,
- .owner = THIS_MODULE,
- },
-
- .probe = mts_spi_ap1_adc_probe,
- .remove = mts_spi_ap1_adc_remove,
-};
-
-static int mts_spi_ap2_dout_probe(struct spi_device *spi)
-{
- int tmp;
-
- if (! have_accessory_card_slot_2 || mts_ap2_product_id != MTAC_GPIOB_0_0) {
- log_error("accessory card 2 digital outputs not available");
- return -ENODEV;
- }
-
- spi->max_speed_hz = ap_dout_max_speed_hz;
- spi->mode = 0;
-
- log_debug("ap2_dout_max_speed_hz: %d", ap_dout_max_speed_hz);
-
- tmp = spi_setup(spi);
- if (tmp < 0) {
- log_error("spi_setup accessory card 2 dout failed");
- return tmp;
- }
-
- spi_ap_dout_value = 0x00;
- spi_writen(spi, &spi_ap_dout_value, 2);
-
- spi_ap2_dout_dev = spi;
-
- return 0;
-}
-
-static int mts_spi_ap2_dout_remove(struct spi_device *spi)
-{
- spi_ap2_dout_dev = NULL;
-
- return 0;
-}
-
-static struct spi_driver mts_spi_ap2_dout_driver = {
- .driver = {
- .name = "mts-io-ap2-dout",
- .bus = &spi_bus_type,
- .owner = THIS_MODULE,
- },
-
- .probe = mts_spi_ap2_dout_probe,
- .remove = mts_spi_ap2_dout_remove,
-};
-
-static int mts_spi_ap2_din_probe(struct spi_device *spi)
-{
- int tmp;
-
- if (! have_accessory_card_slot_2 || mts_ap2_product_id != MTAC_GPIOB_0_0) {
- log_error("accessory card 2 digital inputs not available");
- return -ENODEV;
- }
-
- spi->max_speed_hz = ap_din_max_speed_hz;
- spi->mode = SPI_CPOL;
-
- log_debug("ap2_din_max_speed_hz: %d", ap_din_max_speed_hz);
-
- tmp = spi_setup(spi);
- if (tmp < 0) {
- log_error("spi_setup accessory card 2 din failed");
- return tmp;
- }
-
- spi_ap2_din_dev = spi;
-
- return 0;
-}
-
-static int mts_spi_ap2_din_remove(struct spi_device *spi)
-{
- spi_ap2_din_dev = NULL;
-
- return 0;
-}
-
-static struct spi_driver mts_spi_ap2_din_driver = {
- .driver = {
- .name = "mts-io-ap2-din",
- .bus = &spi_bus_type,
- .owner = THIS_MODULE,
- },
-
- .probe = mts_spi_ap2_din_probe,
- .remove = mts_spi_ap2_din_remove,
-};
-
-static int mts_spi_ap2_adc_probe(struct spi_device *spi)
-{
- int tmp;
-
- if (! have_accessory_card_slot_2 || mts_ap2_product_id != MTAC_GPIOB_0_0) {
- log_error("accessory card 2 analog to digital not available");
- return -ENODEV;
- }
-
- spi->max_speed_hz = ap_adc_max_speed_hz;
- spi->mode = 0;
-
- log_debug("ap2_adc_max_speed_hz: %d", ap_adc_max_speed_hz);
- log_debug("ap2_adc_mode: %d", spi->mode);
-
- tmp = spi_setup(spi);
- if (tmp < 0) {
- log_error("spi_setup accessory card 2 adc failed");
- return tmp;
- }
-
- spi_ap2_adc_dev = spi;
-
- return 0;
-}
-
-static int mts_spi_ap2_adc_remove(struct spi_device *spi)
-{
- spi_ap2_adc_dev = NULL;
-
- return 0;
-}
-
-static struct spi_driver mts_spi_ap2_adc_driver = {
- .driver = {
- .name = "mts-io-ap2-adc",
- .bus = &spi_bus_type,
- .owner = THIS_MODULE,
- },
-
- .probe = mts_spi_ap2_adc_probe,
- .remove = mts_spi_ap2_adc_remove,
-};
-
static int mts_spi_board_temp_probe(struct spi_device *spi)
{
int tmp;