chip.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * Copyright (c) 2014 Broadcom Corporation
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  11. * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  13. * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  14. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef BRCMF_CHIP_H
  17. #define BRCMF_CHIP_H
  18. #include <linux/types.h>
  19. #define CORE_CC_REG(base, field) \
  20. (base + offsetof(struct chipcregs, field))
  21. /**
  22. * struct brcmf_chip - chip level information.
  23. *
  24. * @chip: chip identifier.
  25. * @chiprev: chip revision.
  26. * @cc_caps: chipcommon core capabilities.
  27. * @pmucaps: PMU capabilities.
  28. * @pmurev: PMU revision.
  29. * @rambase: RAM base address (only applicable for ARM CR4 chips).
  30. * @ramsize: amount of RAM on chip including retention.
  31. * @srsize: amount of retention RAM on chip.
  32. * @name: string representation of the chip identifier.
  33. */
  34. struct brcmf_chip {
  35. u32 chip;
  36. u32 chiprev;
  37. u32 cc_caps;
  38. u32 pmucaps;
  39. u32 pmurev;
  40. u32 rambase;
  41. u32 ramsize;
  42. u32 srsize;
  43. char name[8];
  44. };
  45. /**
  46. * struct brcmf_core - core related information.
  47. *
  48. * @id: core identifier.
  49. * @rev: core revision.
  50. * @base: base address of core register space.
  51. */
  52. struct brcmf_core {
  53. u16 id;
  54. u16 rev;
  55. u32 base;
  56. };
  57. /**
  58. * struct brcmf_buscore_ops - buscore specific callbacks.
  59. *
  60. * @read32: read 32-bit value over bus.
  61. * @write32: write 32-bit value over bus.
  62. * @prepare: prepare bus for core configuration.
  63. * @setup: bus-specific core setup.
  64. * @active: chip becomes active.
  65. * The callback should use the provided @rstvec when non-zero.
  66. */
  67. struct brcmf_buscore_ops {
  68. u32 (*read32)(void *ctx, u32 addr);
  69. void (*write32)(void *ctx, u32 addr, u32 value);
  70. int (*prepare)(void *ctx);
  71. int (*reset)(void *ctx, struct brcmf_chip *chip);
  72. int (*setup)(void *ctx, struct brcmf_chip *chip);
  73. void (*activate)(void *ctx, struct brcmf_chip *chip, u32 rstvec);
  74. };
  75. struct brcmf_chip *brcmf_chip_attach(void *ctx,
  76. const struct brcmf_buscore_ops *ops);
  77. void brcmf_chip_detach(struct brcmf_chip *chip);
  78. struct brcmf_core *brcmf_chip_get_core(struct brcmf_chip *chip, u16 coreid);
  79. struct brcmf_core *brcmf_chip_get_chipcommon(struct brcmf_chip *chip);
  80. bool brcmf_chip_iscoreup(struct brcmf_core *core);
  81. void brcmf_chip_coredisable(struct brcmf_core *core, u32 prereset, u32 reset);
  82. void brcmf_chip_resetcore(struct brcmf_core *core, u32 prereset, u32 reset,
  83. u32 postreset);
  84. void brcmf_chip_set_passive(struct brcmf_chip *ci);
  85. bool brcmf_chip_set_active(struct brcmf_chip *ci, u32 rstvec);
  86. bool brcmf_chip_sr_capable(struct brcmf_chip *pub);
  87. #endif /* BRCMF_AXIDMP_H */