vuart.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. struct ps3_vuart_stats {
  23. unsigned long bytes_written;
  24. unsigned long bytes_read;
  25. unsigned long tx_interrupts;
  26. unsigned long rx_interrupts;
  27. unsigned long disconnect_interrupts;
  28. };
  29. /**
  30. * struct ps3_vuart_port_device - a device on a vuart port
  31. */
  32. struct ps3_vuart_port_device {
  33. enum ps3_match_id match_id;
  34. struct device core;
  35. /* private driver variables */
  36. unsigned int port_number;
  37. unsigned long interrupt_mask;
  38. struct {
  39. spinlock_t lock;
  40. struct list_head head;
  41. } tx_list;
  42. struct {
  43. unsigned long bytes_held;
  44. spinlock_t lock;
  45. struct list_head head;
  46. } rx_list;
  47. struct ps3_vuart_stats stats;
  48. };
  49. /**
  50. * struct ps3_vuart_port_driver - a driver for a device on a vuart port
  51. */
  52. struct ps3_vuart_port_driver {
  53. enum ps3_match_id match_id;
  54. struct device_driver core;
  55. int (*probe)(struct ps3_vuart_port_device *);
  56. int (*remove)(struct ps3_vuart_port_device *);
  57. int (*tx_event)(struct ps3_vuart_port_device *dev);
  58. int (*rx_event)(struct ps3_vuart_port_device *dev);
  59. int (*disconnect_event)(struct ps3_vuart_port_device *dev);
  60. /* int (*suspend)(struct ps3_vuart_port_device *, pm_message_t); */
  61. /* int (*resume)(struct ps3_vuart_port_device *); */
  62. };
  63. int ps3_vuart_port_device_register(struct ps3_vuart_port_device *dev);
  64. int ps3_vuart_port_driver_register(struct ps3_vuart_port_driver *drv);
  65. void ps3_vuart_port_driver_unregister(struct ps3_vuart_port_driver *drv);
  66. int ps3_vuart_write(struct ps3_vuart_port_device *dev,
  67. const void* buf, unsigned int bytes);
  68. int ps3_vuart_read(struct ps3_vuart_port_device *dev, void* buf,
  69. unsigned int bytes);
  70. static inline struct ps3_vuart_port_driver *to_ps3_vuart_port_driver(
  71. struct device_driver *_drv)
  72. {
  73. return container_of(_drv, struct ps3_vuart_port_driver, core);
  74. }
  75. static inline struct ps3_vuart_port_device *to_ps3_vuart_port_device(
  76. struct device *_dev)
  77. {
  78. return container_of(_dev, struct ps3_vuart_port_device, core);
  79. }
  80. int ps3_vuart_write(struct ps3_vuart_port_device *dev, const void* buf,
  81. unsigned int bytes);
  82. int ps3_vuart_read(struct ps3_vuart_port_device *dev, void* buf,
  83. unsigned int bytes);
  84. #endif