driver_chipcommon_pmu.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * Broadcom specific AMBA
  3. * ChipCommon Power Management Unit driver
  4. *
  5. * Copyright 2009, Michael Buesch <mb@bu3sch.de>
  6. * Copyright 2007, Broadcom Corporation
  7. *
  8. * Licensed under the GNU/GPL. See COPYING for details.
  9. */
  10. #include "bcma_private.h"
  11. #include <linux/bcma/bcma.h>
  12. static void bcma_chipco_chipctl_maskset(struct bcma_drv_cc *cc,
  13. u32 offset, u32 mask, u32 set)
  14. {
  15. u32 value;
  16. bcma_cc_read32(cc, BCMA_CC_CHIPCTL_ADDR);
  17. bcma_cc_write32(cc, BCMA_CC_CHIPCTL_ADDR, offset);
  18. bcma_cc_read32(cc, BCMA_CC_CHIPCTL_ADDR);
  19. value = bcma_cc_read32(cc, BCMA_CC_CHIPCTL_DATA);
  20. value &= mask;
  21. value |= set;
  22. bcma_cc_write32(cc, BCMA_CC_CHIPCTL_DATA, value);
  23. bcma_cc_read32(cc, BCMA_CC_CHIPCTL_DATA);
  24. }
  25. static void bcma_pmu_pll_init(struct bcma_drv_cc *cc)
  26. {
  27. struct bcma_bus *bus = cc->core->bus;
  28. switch (bus->chipinfo.id) {
  29. case 0x4313:
  30. case 0x4331:
  31. case 43224:
  32. case 43225:
  33. break;
  34. default:
  35. pr_err("PLL init unknown for device 0x%04X\n",
  36. bus->chipinfo.id);
  37. }
  38. }
  39. static void bcma_pmu_resources_init(struct bcma_drv_cc *cc)
  40. {
  41. struct bcma_bus *bus = cc->core->bus;
  42. u32 min_msk = 0, max_msk = 0;
  43. switch (bus->chipinfo.id) {
  44. case 0x4313:
  45. min_msk = 0x200D;
  46. max_msk = 0xFFFF;
  47. break;
  48. case 43224:
  49. break;
  50. default:
  51. pr_err("PMU resource config unknown for device 0x%04X\n",
  52. bus->chipinfo.id);
  53. }
  54. /* Set the resource masks. */
  55. if (min_msk)
  56. bcma_cc_write32(cc, BCMA_CC_PMU_MINRES_MSK, min_msk);
  57. if (max_msk)
  58. bcma_cc_write32(cc, BCMA_CC_PMU_MAXRES_MSK, max_msk);
  59. }
  60. void bcma_pmu_swreg_init(struct bcma_drv_cc *cc)
  61. {
  62. struct bcma_bus *bus = cc->core->bus;
  63. switch (bus->chipinfo.id) {
  64. case 0x4313:
  65. case 0x4331:
  66. case 43224:
  67. break;
  68. default:
  69. pr_err("PMU switch/regulators init unknown for device "
  70. "0x%04X\n", bus->chipinfo.id);
  71. }
  72. }
  73. void bcma_pmu_workarounds(struct bcma_drv_cc *cc)
  74. {
  75. struct bcma_bus *bus = cc->core->bus;
  76. switch (bus->chipinfo.id) {
  77. case 0x4313:
  78. bcma_chipco_chipctl_maskset(cc, 0, ~0, 0x7);
  79. break;
  80. case 0x4331:
  81. pr_err("Enabling Ext PA lines not implemented\n");
  82. break;
  83. case 43224:
  84. if (bus->chipinfo.rev == 0) {
  85. pr_err("Workarounds for 43224 rev 0 not fully "
  86. "implemented\n");
  87. bcma_chipco_chipctl_maskset(cc, 0, ~0, 0xF0);
  88. } else {
  89. bcma_chipco_chipctl_maskset(cc, 0, ~0, 0xF0);
  90. }
  91. break;
  92. default:
  93. pr_err("Workarounds unknown for device 0x%04X\n",
  94. bus->chipinfo.id);
  95. }
  96. }
  97. void bcma_pmu_init(struct bcma_drv_cc *cc)
  98. {
  99. u32 pmucap;
  100. pmucap = bcma_cc_read32(cc, BCMA_CC_PMU_CAP);
  101. cc->pmu.rev = (pmucap & BCMA_CC_PMU_CAP_REVISION);
  102. pr_debug("Found rev %u PMU (capabilities 0x%08X)\n", cc->pmu.rev,
  103. pmucap);
  104. if (cc->pmu.rev == 1)
  105. bcma_cc_mask32(cc, BCMA_CC_PMU_CTL,
  106. ~BCMA_CC_PMU_CTL_NOILPONW);
  107. else
  108. bcma_cc_set32(cc, BCMA_CC_PMU_CTL,
  109. BCMA_CC_PMU_CTL_NOILPONW);
  110. if (cc->core->id.id == 0x4329 && cc->core->id.rev == 2)
  111. pr_err("Fix for 4329b0 bad LPOM state not implemented!\n");
  112. bcma_pmu_pll_init(cc);
  113. bcma_pmu_resources_init(cc);
  114. bcma_pmu_swreg_init(cc);
  115. bcma_pmu_workarounds(cc);
  116. }