parport_arc.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:3k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /* Low-level parallel port routines for Archimedes onboard hardware
  2.  *
  3.  * Author: Phil Blundell <Philip.Blundell@pobox.com>
  4.  */
  5. /* This driver is for the parallel port hardware found on Acorn's old
  6.  * range of Archimedes machines.  The A5000 and newer systems have PC-style
  7.  * I/O hardware and should use the parport_pc driver instead.
  8.  *
  9.  * The Acorn printer port hardware is very simple.  There is a single 8-bit
  10.  * write-only latch for the data port and control/status bits are handled
  11.  * with various auxilliary input and output lines.  The port is not
  12.  * bidirectional, does not support any modes other than SPP, and has only
  13.  * a subset of the standard printer control lines connected.
  14.  */
  15. #include <linux/threads.h>
  16. #include <linux/delay.h>
  17. #include <linux/errno.h>
  18. #include <linux/interrupt.h>
  19. #include <linux/ioport.h>
  20. #include <linux/kernel.h>
  21. #include <linux/slab.h>
  22. #include <linux/parport.h>
  23. #include <asm/ptrace.h>
  24. #include <asm/io.h>
  25. #include <asm/arch/oldlatches.h>
  26. #include <asm/arch/irqs.h>
  27. #define DATA_ADDRESS    0x3350010
  28. /* This is equivalent to the above and only used for request_region. */
  29. #define PORT_BASE       0x80000000 | ((DATA_ADDRESS - IO_BASE) >> 2)
  30. /* The hardware can't read from the data latch, so we must use a soft
  31.    copy. */
  32. static unsigned char data_copy;
  33. /* These are pretty simple. We know the irq is never shared and the
  34.    kernel does all the magic that's required. */
  35. static void arc_enable_irq(struct parport *p)
  36. {
  37. enable_irq(p->irq);
  38. }
  39. static void arc_disable_irq(struct parport *p)
  40. {
  41. disable_irq(p->irq);
  42. }
  43. static void arc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
  44. {
  45. parport_generic_irq(irq, (struct parport *) dev_id, regs);
  46. }
  47. static void arc_write_data(struct parport *p, unsigned char data)
  48. {
  49. data_copy = data;
  50. outb_t(data, DATA_LATCH);
  51. }
  52. static unsigned char arc_read_data(struct parport *p)
  53. {
  54. return data_copy;
  55. }
  56. static void arc_inc_use_count(void)
  57. {
  58. #ifdef MODULE
  59. MOD_INC_USE_COUNT;
  60. #endif
  61. }
  62. static void arc_dec_use_count(void)
  63. {
  64. #ifdef MODULE
  65. MOD_DEC_USE_COUNT;
  66. #endif
  67. }
  68. static struct parport_operations parport_arc_ops = 
  69. {
  70. arc_write_data,
  71. arc_read_data,
  72. arc_write_control,
  73. arc_read_control,
  74. arc_frob_control,
  75. arc_read_status,
  76. arc_enable_irq,
  77. arc_disable_irq,
  78. arc_data_forward,
  79. arc_data_reverse,
  80. arc_init_state,
  81. arc_save_state,
  82. arc_restore_state,
  83. arc_inc_use_count,
  84. arc_dec_use_count,
  85. parport_ieee1284_epp_write_data,
  86. parport_ieee1284_epp_read_data,
  87. parport_ieee1284_epp_write_addr,
  88. parport_ieee1284_epp_read_addr,
  89. parport_ieee1284_ecp_write_data,
  90. parport_ieee1284_ecp_read_data,
  91. parport_ieee1284_ecp_write_addr,
  92. parport_ieee1284_write_compat,
  93. parport_ieee1284_read_nibble,
  94. parport_ieee1284_read_byte,
  95. };
  96. /* --- Initialisation code -------------------------------- */
  97. int parport_arc_init(void)
  98. {
  99. /* Archimedes hardware provides only one port, at a fixed address */
  100. struct parport *p;
  101. if (check_region(PORT_BASE, 1))
  102. return 0;
  103. p = parport_register_port (PORT_BASE, IRQ_PRINTERACK,
  104.    PARPORT_DMA_NONE, &parport_arc_ops);
  105. if (!p)
  106. return 0;
  107. p->modes = PARPORT_MODE_ARCSPP;
  108. p->size = 1;
  109. printk(KERN_INFO "%s: Archimedes on-board port, using irq %dn",
  110.        p->irq);
  111. parport_proc_register(p);
  112. /* Tell the high-level drivers about the port. */
  113. parport_announce_port (p);
  114. return 1;
  115. }