ines_util.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /***************************************************************************
  2. nec7210/ines_util.c - description
  3. -------------------
  4. copyright : (C) 2002 by Frank Mori Hess
  5. email : fmhess@users.sourceforge.net
  6. ***************************************************************************/
  7. /***************************************************************************
  8. * *
  9. * This program is free software; you can redistribute it and/or modify *
  10. * it under the terms of the GNU General Public License as published by *
  11. * the Free Software Foundation; either version 2 of the License, or *
  12. * (at your option) any later version. *
  13. * *
  14. ***************************************************************************/
  15. #include "ines.h"
  16. #include <linux/pci.h>
  17. #include <asm/io.h>
  18. #include <linux/module.h>
  19. int ines_line_status( const gpib_board_t *board )
  20. {
  21. int status = ValidALL;
  22. int bcm_bits;
  23. ines_private_t *ines_priv;
  24. nec7210_private_t *nec_priv;
  25. ines_priv = board->private_data;
  26. nec_priv = &ines_priv->nec7210_priv;
  27. bcm_bits = ines_inb( ines_priv, BUS_CONTROL_MONITOR );
  28. if( bcm_bits & BCM_REN_BIT )
  29. status |= BusREN;
  30. if( bcm_bits & BCM_IFC_BIT )
  31. status |= BusIFC;
  32. if( bcm_bits & BCM_SRQ_BIT )
  33. status |= BusSRQ;
  34. if( bcm_bits & BCM_EOI_BIT )
  35. status |= BusEOI;
  36. if( bcm_bits & BCM_NRFD_BIT )
  37. status |= BusNRFD;
  38. if( bcm_bits & BCM_NDAC_BIT )
  39. status |= BusNDAC;
  40. if( bcm_bits & BCM_DAV_BIT )
  41. status |= BusDAV;
  42. if( bcm_bits & BCM_ATN_BIT )
  43. status |= BusATN;
  44. return status;
  45. }
  46. void ines_set_xfer_counter( ines_private_t *priv, unsigned int count )
  47. {
  48. if( count > 0xffff )
  49. {
  50. printk("ines: bug! tried to set xfer counter > 0xffff\n" );
  51. return;
  52. }
  53. ines_outb( priv, ( count >> 8 ) & 0xff, XFER_COUNT_UPPER );
  54. ines_outb( priv, count & 0xff, XFER_COUNT_LOWER );
  55. }
  56. unsigned int ines_t1_delay( gpib_board_t *board, unsigned int nano_sec )
  57. {
  58. ines_private_t *ines_priv = board->private_data;
  59. nec7210_private_t *nec_priv = &ines_priv->nec7210_priv;
  60. unsigned int retval;
  61. retval = nec7210_t1_delay( board, nec_priv, nano_sec );
  62. if( nano_sec <= 250 )
  63. {
  64. write_byte( nec_priv, INES_AUXD | INES_FOLLOWING_T1_250ns |
  65. INES_INITIAL_T1_2000ns, AUXMR );
  66. retval = 250;
  67. }else if( nano_sec <=350 )
  68. {
  69. write_byte( nec_priv, INES_AUXD | INES_FOLLOWING_T1_350ns |
  70. INES_INITIAL_T1_2000ns, AUXMR );
  71. retval = 350;
  72. }else
  73. {
  74. write_byte( nec_priv, INES_AUXD | INES_FOLLOWING_T1_500ns |
  75. INES_INITIAL_T1_2000ns, AUXMR );
  76. retval = 500;
  77. }
  78. return retval;
  79. }