2 * Broadcom specific AMBA
3 * ChipCommon Power Management Unit driver
5 * Copyright 2009, Michael Buesch <mb@bu3sch.de>
6 * Copyright 2007, Broadcom Corporation
8 * Licensed under the GNU/GPL. See COPYING for details.
11 #include "bcma_private.h"
12 #include <linux/bcma/bcma.h>
14 static void bcma_chipco_chipctl_maskset(struct bcma_drv_cc
*cc
,
15 u32 offset
, u32 mask
, u32 set
)
19 bcma_cc_read32(cc
, BCMA_CC_CHIPCTL_ADDR
);
20 bcma_cc_write32(cc
, BCMA_CC_CHIPCTL_ADDR
, offset
);
21 bcma_cc_read32(cc
, BCMA_CC_CHIPCTL_ADDR
);
22 value
= bcma_cc_read32(cc
, BCMA_CC_CHIPCTL_DATA
);
25 bcma_cc_write32(cc
, BCMA_CC_CHIPCTL_DATA
, value
);
26 bcma_cc_read32(cc
, BCMA_CC_CHIPCTL_DATA
);
29 static void bcma_pmu_pll_init(struct bcma_drv_cc
*cc
)
31 struct bcma_bus
*bus
= cc
->core
->bus
;
33 switch (bus
->chipinfo
.id
) {
40 pr_err("PLL init unknown for device 0x%04X\n",
45 static void bcma_pmu_resources_init(struct bcma_drv_cc
*cc
)
47 struct bcma_bus
*bus
= cc
->core
->bus
;
48 u32 min_msk
= 0, max_msk
= 0;
50 switch (bus
->chipinfo
.id
) {
58 pr_err("PMU resource config unknown for device 0x%04X\n",
62 /* Set the resource masks. */
64 bcma_cc_write32(cc
, BCMA_CC_PMU_MINRES_MSK
, min_msk
);
66 bcma_cc_write32(cc
, BCMA_CC_PMU_MAXRES_MSK
, max_msk
);
69 void bcma_pmu_swreg_init(struct bcma_drv_cc
*cc
)
71 struct bcma_bus
*bus
= cc
->core
->bus
;
73 switch (bus
->chipinfo
.id
) {
79 pr_err("PMU switch/regulators init unknown for device "
80 "0x%04X\n", bus
->chipinfo
.id
);
84 void bcma_pmu_workarounds(struct bcma_drv_cc
*cc
)
86 struct bcma_bus
*bus
= cc
->core
->bus
;
88 switch (bus
->chipinfo
.id
) {
90 bcma_chipco_chipctl_maskset(cc
, 0, ~0, 0x7);
93 pr_err("Enabling Ext PA lines not implemented\n");
96 if (bus
->chipinfo
.rev
== 0) {
97 pr_err("Workarounds for 43224 rev 0 not fully "
99 bcma_chipco_chipctl_maskset(cc
, 0, ~0, 0xF0);
101 bcma_chipco_chipctl_maskset(cc
, 0, ~0, 0xF0);
105 pr_err("Workarounds unknown for device 0x%04X\n",
110 void bcma_pmu_init(struct bcma_drv_cc
*cc
)
114 pmucap
= bcma_cc_read32(cc
, BCMA_CC_PMU_CAP
);
115 cc
->pmu
.rev
= (pmucap
& BCMA_CC_PMU_CAP_REVISION
);
117 pr_debug("Found rev %u PMU (capabilities 0x%08X)\n", cc
->pmu
.rev
,
120 if (cc
->pmu
.rev
== 1)
121 bcma_cc_mask32(cc
, BCMA_CC_PMU_CTL
,
122 ~BCMA_CC_PMU_CTL_NOILPONW
);
124 bcma_cc_set32(cc
, BCMA_CC_PMU_CTL
,
125 BCMA_CC_PMU_CTL_NOILPONW
);
127 if (cc
->core
->id
.id
== 0x4329 && cc
->core
->id
.rev
== 2)
128 pr_err("Fix for 4329b0 bad LPOM state not implemented!\n");
130 bcma_pmu_pll_init(cc
);
131 bcma_pmu_resources_init(cc
);
132 bcma_pmu_swreg_init(cc
);
133 bcma_pmu_workarounds(cc
);