vuart.h 2.6 KB

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