fw-device.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /* -*- c-basic-offset: 8 -*-
  2. *
  3. * fw-device.h - Device probing and sysfs code.
  4. *
  5. * Copyright (C) 2005-2006 Kristian Hoegsberg <krh@bitplanet.net>
  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; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software Foundation,
  19. * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  20. */
  21. #ifndef __fw_device_h
  22. #define __fw_device_h
  23. #include <linux/fs.h>
  24. #include <linux/cdev.h>
  25. #include <asm/atomic.h>
  26. enum fw_device_state {
  27. FW_DEVICE_INITIALIZING,
  28. FW_DEVICE_RUNNING,
  29. FW_DEVICE_SHUTDOWN,
  30. };
  31. struct fw_device {
  32. atomic_t state;
  33. struct fw_node *node;
  34. int node_id;
  35. int generation;
  36. struct fw_card *card;
  37. struct device device;
  38. struct list_head link;
  39. struct list_head client_list;
  40. __be32 *config_rom;
  41. size_t config_rom_length;
  42. int config_rom_retries;
  43. struct delayed_work work;
  44. };
  45. static inline struct fw_device *
  46. fw_device(struct device *dev)
  47. {
  48. return container_of(dev, struct fw_device, device);
  49. }
  50. struct fw_device *fw_device_get(struct fw_device *device);
  51. void fw_device_put(struct fw_device *device);
  52. int fw_device_enable_phys_dma(struct fw_device *device);
  53. void fw_device_cdev_update(struct fw_device *device);
  54. struct fw_device *fw_device_from_devt(dev_t devt);
  55. extern int fw_cdev_major;
  56. struct fw_unit {
  57. struct device device;
  58. u32 *directory;
  59. };
  60. static inline struct fw_unit *
  61. fw_unit(struct device *dev)
  62. {
  63. return container_of(dev, struct fw_unit, device);
  64. }
  65. #define CSR_OFFSET 0x40
  66. #define CSR_LEAF 0x80
  67. #define CSR_DIRECTORY 0xc0
  68. #define CSR_DESCRIPTOR 0x01
  69. #define CSR_VENDOR 0x03
  70. #define CSR_HARDWARE_VERSION 0x04
  71. #define CSR_NODE_CAPABILITIES 0x0c
  72. #define CSR_UNIT 0x11
  73. #define CSR_SPECIFIER_ID 0x12
  74. #define CSR_VERSION 0x13
  75. #define CSR_DEPENDENT_INFO 0x14
  76. #define CSR_MODEL 0x17
  77. #define CSR_INSTANCE 0x18
  78. #define SBP2_COMMAND_SET_SPECIFIER 0x38
  79. #define SBP2_COMMAND_SET 0x39
  80. #define SBP2_COMMAND_SET_REVISION 0x3b
  81. #define SBP2_FIRMWARE_REVISION 0x3c
  82. struct fw_csr_iterator {
  83. u32 *p;
  84. u32 *end;
  85. };
  86. void fw_csr_iterator_init(struct fw_csr_iterator *ci, u32 *p);
  87. int fw_csr_iterator_next(struct fw_csr_iterator *ci,
  88. int *key, int *value);
  89. #define FW_MATCH_VENDOR 0x0001
  90. #define FW_MATCH_MODEL 0x0002
  91. #define FW_MATCH_SPECIFIER_ID 0x0004
  92. #define FW_MATCH_VERSION 0x0008
  93. struct fw_device_id {
  94. u32 match_flags;
  95. u32 vendor;
  96. u32 model;
  97. u32 specifier_id;
  98. u32 version;
  99. void *driver_data;
  100. };
  101. struct fw_driver {
  102. struct device_driver driver;
  103. /* Called when the parent device sits through a bus reset. */
  104. void (*update) (struct fw_unit *unit);
  105. const struct fw_device_id *id_table;
  106. };
  107. static inline struct fw_driver *
  108. fw_driver(struct device_driver *drv)
  109. {
  110. return container_of(drv, struct fw_driver, driver);
  111. }
  112. extern const struct file_operations fw_device_ops;
  113. #endif /* __fw_device_h */