vuart.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * PS3 virtual uart
  3. *
  4. * Copyright (C) 2006 Sony Computer Entertainment Inc.
  5. * Copyright 2006 Sony Corp.
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; version 2 of the License.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. */
  20. #if !defined(_PS3_VUART_H)
  21. #define _PS3_VUART_H
  22. #include <asm/ps3.h>
  23. struct ps3_vuart_stats {
  24. unsigned long bytes_written;
  25. unsigned long bytes_read;
  26. unsigned long tx_interrupts;
  27. unsigned long rx_interrupts;
  28. unsigned long disconnect_interrupts;
  29. };
  30. struct ps3_vuart_work {
  31. struct work_struct work;
  32. unsigned long trigger;
  33. struct ps3_system_bus_device *dev; /* to convert work to device */
  34. };
  35. /**
  36. * struct ps3_vuart_port_driver - a driver for a device on a vuart port
  37. */
  38. struct ps3_vuart_port_driver {
  39. struct ps3_system_bus_driver core;
  40. int (*probe)(struct ps3_system_bus_device *);
  41. int (*remove)(struct ps3_system_bus_device *);
  42. void (*shutdown)(struct ps3_system_bus_device *);
  43. void (*work)(struct ps3_system_bus_device *);
  44. /* int (*tx_event)(struct ps3_system_bus_device *dev); */
  45. /* int (*rx_event)(struct ps3_system_bus_device *dev); */
  46. /* int (*disconnect_event)(struct ps3_system_bus_device *dev); */
  47. /* int (*suspend)(struct ps3_system_bus_device *, pm_message_t); */
  48. /* int (*resume)(struct ps3_system_bus_device *); */
  49. };
  50. int ps3_vuart_port_driver_register(struct ps3_vuart_port_driver *drv);
  51. void ps3_vuart_port_driver_unregister(struct ps3_vuart_port_driver *drv);
  52. static inline struct ps3_vuart_port_driver *
  53. ps3_system_bus_dev_to_vuart_drv(struct ps3_system_bus_device *_dev)
  54. {
  55. struct ps3_system_bus_driver *sbd =
  56. ps3_system_bus_dev_to_system_bus_drv(_dev);
  57. BUG_ON(!sbd);
  58. return container_of(sbd, struct ps3_vuart_port_driver, core);
  59. }
  60. static inline struct ps3_system_bus_device *ps3_vuart_work_to_system_bus_dev(
  61. struct work_struct *_work)
  62. {
  63. struct ps3_vuart_work *vw = container_of(_work, struct ps3_vuart_work,
  64. work);
  65. return vw->dev;
  66. }
  67. int ps3_vuart_write(struct ps3_system_bus_device *dev, const void *buf,
  68. unsigned int bytes);
  69. int ps3_vuart_read(struct ps3_system_bus_device *dev, void *buf,
  70. unsigned int bytes);
  71. int ps3_vuart_read_async(struct ps3_system_bus_device *dev, unsigned int bytes);
  72. void ps3_vuart_cancel_async(struct ps3_system_bus_device *dev);
  73. void ps3_vuart_clear_rx_bytes(struct ps3_system_bus_device *dev,
  74. unsigned int bytes);
  75. struct vuart_triggers {
  76. unsigned long rx;
  77. unsigned long tx;
  78. };
  79. int ps3_vuart_get_triggers(struct ps3_system_bus_device *dev,
  80. struct vuart_triggers *trig);
  81. int ps3_vuart_set_triggers(struct ps3_system_bus_device *dev, unsigned int tx,
  82. unsigned int rx);
  83. int ps3_vuart_enable_interrupt_tx(struct ps3_system_bus_device *dev);
  84. int ps3_vuart_disable_interrupt_tx(struct ps3_system_bus_device *dev);
  85. int ps3_vuart_enable_interrupt_rx(struct ps3_system_bus_device *dev);
  86. int ps3_vuart_disable_interrupt_rx(struct ps3_system_bus_device *dev);
  87. int ps3_vuart_enable_interrupt_disconnect(struct ps3_system_bus_device *dev);
  88. int ps3_vuart_disable_interrupt_disconnect(struct ps3_system_bus_device *dev);
  89. #endif