superhyway.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * include/linux/superhyway.h
  3. *
  4. * SuperHyway Bus definitions
  5. *
  6. * Copyright (C) 2004, 2005 Paul Mundt <lethal@linux-sh.org>
  7. *
  8. * This file is subject to the terms and conditions of the GNU General Public
  9. * License. See the file "COPYING" in the main directory of this archive
  10. * for more details.
  11. */
  12. #ifndef __LINUX_SUPERHYWAY_H
  13. #define __LINUX_SUPERHYWAY_H
  14. #include <linux/device.h>
  15. /*
  16. * SuperHyway IDs
  17. */
  18. #define SUPERHYWAY_DEVICE_ID_SH5_DMAC 0x0183
  19. struct superhyway_vcr_info {
  20. u8 perr_flags; /* P-port Error flags */
  21. u8 merr_flags; /* Module Error flags */
  22. u16 mod_vers; /* Module Version */
  23. u16 mod_id; /* Module ID */
  24. u8 bot_mb; /* Bottom Memory block */
  25. u8 top_mb; /* Top Memory block */
  26. };
  27. struct superhyway_ops {
  28. int (*read_vcr)(unsigned long base, struct superhyway_vcr_info *vcr);
  29. int (*write_vcr)(unsigned long base, struct superhyway_vcr_info vcr);
  30. };
  31. struct superhyway_bus {
  32. struct superhyway_ops *ops;
  33. };
  34. extern struct superhyway_bus superhyway_channels[];
  35. struct superhyway_device_id {
  36. unsigned int id;
  37. unsigned long driver_data;
  38. };
  39. struct superhyway_device;
  40. extern struct bus_type superhyway_bus_type;
  41. struct superhyway_driver {
  42. char *name;
  43. const struct superhyway_device_id *id_table;
  44. struct device_driver drv;
  45. int (*probe)(struct superhyway_device *dev, const struct superhyway_device_id *id);
  46. void (*remove)(struct superhyway_device *dev);
  47. };
  48. #define to_superhyway_driver(d) container_of((d), struct superhyway_driver, drv)
  49. struct superhyway_device {
  50. char name[32];
  51. struct device dev;
  52. struct superhyway_device_id id;
  53. struct superhyway_driver *drv;
  54. struct superhyway_bus *bus;
  55. int num_resources;
  56. struct resource *resource;
  57. struct superhyway_vcr_info vcr;
  58. };
  59. #define to_superhyway_device(d) container_of((d), struct superhyway_device, dev)
  60. #define superhyway_get_drvdata(d) dev_get_drvdata(&(d)->dev)
  61. #define superhyway_set_drvdata(d,p) dev_set_drvdata(&(d)->dev, (p))
  62. static inline int
  63. superhyway_read_vcr(struct superhyway_device *dev, unsigned long base,
  64. struct superhyway_vcr_info *vcr)
  65. {
  66. return dev->bus->ops->read_vcr(base, vcr);
  67. }
  68. static inline int
  69. superhyway_write_vcr(struct superhyway_device *dev, unsigned long base,
  70. struct superhyway_vcr_info vcr)
  71. {
  72. return dev->bus->ops->write_vcr(base, vcr);
  73. }
  74. extern int superhyway_scan_bus(struct superhyway_bus *);
  75. /* drivers/sh/superhyway/superhyway.c */
  76. int superhyway_register_driver(struct superhyway_driver *);
  77. void superhyway_unregister_driver(struct superhyway_driver *);
  78. int superhyway_add_device(unsigned long base, struct superhyway_device *, struct superhyway_bus *);
  79. int superhyway_add_devices(struct superhyway_bus *bus, struct superhyway_device **devices, int nr_devices);
  80. /* drivers/sh/superhyway/superhyway-sysfs.c */
  81. extern struct device_attribute superhyway_dev_attrs[];
  82. #endif /* __LINUX_SUPERHYWAY_H */