2 * Broadcom specific AMBA
3 * ChipCommon Power Management Unit driver
5 * Copyright 2009, Michael Buesch <m@bues.ch>
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
) {
59 pr_err("PMU resource config unknown for device 0x%04X\n",
63 /* Set the resource masks. */
65 bcma_cc_write32(cc
, BCMA_CC_PMU_MINRES_MSK
, min_msk
);
67 bcma_cc_write32(cc
, BCMA_CC_PMU_MAXRES_MSK
, max_msk
);
70 void bcma_pmu_swreg_init(struct bcma_drv_cc
*cc
)
72 struct bcma_bus
*bus
= cc
->core
->bus
;
74 switch (bus
->chipinfo
.id
) {
81 pr_err("PMU switch/regulators init unknown for device "
82 "0x%04X\n", bus
->chipinfo
.id
);
86 void bcma_pmu_workarounds(struct bcma_drv_cc
*cc
)
88 struct bcma_bus
*bus
= cc
->core
->bus
;
90 switch (bus
->chipinfo
.id
) {
92 bcma_chipco_chipctl_maskset(cc
, 0, ~0, 0x7);
95 pr_err("Enabling Ext PA lines not implemented\n");
98 if (bus
->chipinfo
.rev
== 0) {
99 pr_err("Workarounds for 43224 rev 0 not fully "
101 bcma_chipco_chipctl_maskset(cc
, 0, ~0, 0x00F000F0);
103 bcma_chipco_chipctl_maskset(cc
, 0, ~0, 0xF0);
109 pr_err("Workarounds unknown for device 0x%04X\n",
114 void bcma_pmu_init(struct bcma_drv_cc
*cc
)
118 pmucap
= bcma_cc_read32(cc
, BCMA_CC_PMU_CAP
);
119 cc
->pmu
.rev
= (pmucap
& BCMA_CC_PMU_CAP_REVISION
);
121 pr_debug("Found rev %u PMU (capabilities 0x%08X)\n", cc
->pmu
.rev
,
124 if (cc
->pmu
.rev
== 1)
125 bcma_cc_mask32(cc
, BCMA_CC_PMU_CTL
,
126 ~BCMA_CC_PMU_CTL_NOILPONW
);
128 bcma_cc_set32(cc
, BCMA_CC_PMU_CTL
,
129 BCMA_CC_PMU_CTL_NOILPONW
);
131 if (cc
->core
->id
.id
== 0x4329 && cc
->core
->id
.rev
== 2)
132 pr_err("Fix for 4329b0 bad LPOM state not implemented!\n");
134 bcma_pmu_pll_init(cc
);
135 bcma_pmu_resources_init(cc
);
136 bcma_pmu_swreg_init(cc
);
137 bcma_pmu_workarounds(cc
);