cdmm.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2014 Imagination Technologies Ltd.
  7. */
  8. #ifndef __ASM_CDMM_H
  9. #define __ASM_CDMM_H
  10. #include <linux/device.h>
  11. #include <linux/mod_devicetable.h>
  12. /**
  13. * struct mips_cdmm_device - Represents a single device on a CDMM bus.
  14. * @dev: Driver model device object.
  15. * @cpu: CPU which can access this device.
  16. * @res: MMIO resource.
  17. * @type: Device type identifier.
  18. * @rev: Device revision number.
  19. */
  20. struct mips_cdmm_device {
  21. struct device dev;
  22. unsigned int cpu;
  23. struct resource res;
  24. unsigned int type;
  25. unsigned int rev;
  26. };
  27. /**
  28. * struct mips_cdmm_driver - Represents a driver for a CDMM device.
  29. * @drv: Driver model driver object.
  30. * @probe Callback for probing newly discovered devices.
  31. * @remove: Callback to remove the device.
  32. * @shutdown: Callback on system shutdown.
  33. * @cpu_down: Callback when the parent CPU is going down.
  34. * Any CPU pinned threads/timers should be disabled.
  35. * @cpu_up: Callback when the parent CPU is coming back up again.
  36. * CPU pinned threads/timers can be restarted.
  37. * @id_table: Table for CDMM IDs to match against.
  38. */
  39. struct mips_cdmm_driver {
  40. struct device_driver drv;
  41. int (*probe)(struct mips_cdmm_device *);
  42. int (*remove)(struct mips_cdmm_device *);
  43. void (*shutdown)(struct mips_cdmm_device *);
  44. int (*cpu_down)(struct mips_cdmm_device *);
  45. int (*cpu_up)(struct mips_cdmm_device *);
  46. const struct mips_cdmm_device_id *id_table;
  47. };
  48. /**
  49. * mips_cdmm_phys_base() - Choose a physical base address for CDMM region.
  50. *
  51. * Picking a suitable physical address at which to map the CDMM region is
  52. * platform specific, so this function can be defined by platform code to
  53. * pick a suitable value if none is configured by the bootloader.
  54. *
  55. * This address must be 32kB aligned, and the region occupies a maximum of 32kB
  56. * of physical address space which must not be used for anything else.
  57. *
  58. * Returns: Physical base address for CDMM region, or 0 on failure.
  59. */
  60. phys_addr_t mips_cdmm_phys_base(void);
  61. extern struct bus_type mips_cdmm_bustype;
  62. void __iomem *mips_cdmm_early_probe(unsigned int dev_type);
  63. #define to_mips_cdmm_device(d) container_of(d, struct mips_cdmm_device, dev)
  64. #define mips_cdmm_get_drvdata(d) dev_get_drvdata(&d->dev)
  65. #define mips_cdmm_set_drvdata(d, p) dev_set_drvdata(&d->dev, p)
  66. int mips_cdmm_driver_register(struct mips_cdmm_driver *);
  67. void mips_cdmm_driver_unregister(struct mips_cdmm_driver *);
  68. /*
  69. * module_mips_cdmm_driver() - Helper macro for drivers that don't do
  70. * anything special in module init/exit. This eliminates a lot of
  71. * boilerplate. Each module may only use this macro once, and
  72. * calling it replaces module_init() and module_exit()
  73. */
  74. #define module_mips_cdmm_driver(__mips_cdmm_driver) \
  75. module_driver(__mips_cdmm_driver, mips_cdmm_driver_register, \
  76. mips_cdmm_driver_unregister)
  77. /*
  78. * builtin_mips_cdmm_driver() - Helper macro for drivers that don't do anything
  79. * special in init and have no exit. This eliminates some boilerplate. Each
  80. * driver may only use this macro once, and calling it replaces device_initcall
  81. * (or in some cases, the legacy __initcall). This is meant to be a direct
  82. * parallel of module_mips_cdmm_driver() above but without the __exit stuff that
  83. * is not used for builtin cases.
  84. */
  85. #define builtin_mips_cdmm_driver(__mips_cdmm_driver) \
  86. builtin_driver(__mips_cdmm_driver, mips_cdmm_driver_register)
  87. /* drivers/tty/mips_ejtag_fdc.c */
  88. #ifdef CONFIG_MIPS_EJTAG_FDC_EARLYCON
  89. int setup_early_fdc_console(void);
  90. #else
  91. static inline int setup_early_fdc_console(void)
  92. {
  93. return -ENODEV;
  94. }
  95. #endif
  96. #endif /* __ASM_CDMM_H */