parport_arc.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /* Low-level parallel port routines for Archimedes onboard hardware
  2. *
  3. * Author: Phil Blundell <philb@gnu.org>
  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 struct parport_operations parport_arc_ops =
  57. {
  58. .write_data = arc_write_data,
  59. .read_data = arc_read_data,
  60. .write_control = arc_write_control,
  61. .read_control = arc_read_control,
  62. .frob_control = arc_frob_control,
  63. .read_status = arc_read_status,
  64. .enable_irq = arc_enable_irq,
  65. .disable_irq = arc_disable_irq,
  66. .data_forward = arc_data_forward,
  67. .data_reverse = arc_data_reverse,
  68. .init_state = arc_init_state,
  69. .save_state = arc_save_state,
  70. .restore_state = arc_restore_state,
  71. .epp_write_data = parport_ieee1284_epp_write_data,
  72. .epp_read_data = parport_ieee1284_epp_read_data,
  73. .epp_write_addr = parport_ieee1284_epp_write_addr,
  74. .epp_read_addr = parport_ieee1284_epp_read_addr,
  75. .ecp_write_data = parport_ieee1284_ecp_write_data,
  76. .ecp_read_data = parport_ieee1284_ecp_read_data,
  77. .ecp_write_addr = parport_ieee1284_ecp_write_addr,
  78. .compat_write_data = parport_ieee1284_write_compat,
  79. .nibble_read_data = parport_ieee1284_read_nibble,
  80. .byte_read_data = parport_ieee1284_read_byte,
  81. .owner = THIS_MODULE,
  82. };
  83. /* --- Initialisation code -------------------------------- */
  84. static int parport_arc_init(void)
  85. {
  86. /* Archimedes hardware provides only one port, at a fixed address */
  87. struct parport *p;
  88. struct resource res;
  89. char *fake_name = "parport probe");
  90. res = request_region(PORT_BASE, 1, fake_name);
  91. if (res == NULL)
  92. return 0;
  93. p = parport_register_port (PORT_BASE, IRQ_PRINTERACK,
  94. PARPORT_DMA_NONE, &parport_arc_ops);
  95. if (!p) {
  96. release_region(PORT_BASE, 1);
  97. return 0;
  98. }
  99. p->modes = PARPORT_MODE_ARCSPP;
  100. p->size = 1;
  101. rename_region(res, p->name);
  102. printk(KERN_INFO "%s: Archimedes on-board port, using irq %d\n",
  103. p->irq);
  104. /* Tell the high-level drivers about the port. */
  105. parport_announce_port (p);
  106. return 1;
  107. }
  108. module_init(parport_arc_init)