2 * Broadcom specific AMBA
5 * Licensed under the GNU/GPL. See COPYING for details.
8 #include "bcma_private.h"
9 #include <linux/bcma/bcma.h>
11 bool bcma_core_is_enabled(struct bcma_device
*core
)
13 if ((bcma_aread32(core
, BCMA_IOCTL
) & (BCMA_IOCTL_CLK
| BCMA_IOCTL_FGC
))
16 if (bcma_aread32(core
, BCMA_RESET_CTL
) & BCMA_RESET_CTL_RESET
)
20 EXPORT_SYMBOL_GPL(bcma_core_is_enabled
);
22 void bcma_core_disable(struct bcma_device
*core
, u32 flags
)
24 if (bcma_aread32(core
, BCMA_RESET_CTL
) & BCMA_RESET_CTL_RESET
)
27 bcma_awrite32(core
, BCMA_IOCTL
, flags
);
28 bcma_aread32(core
, BCMA_IOCTL
);
31 bcma_awrite32(core
, BCMA_RESET_CTL
, BCMA_RESET_CTL_RESET
);
34 EXPORT_SYMBOL_GPL(bcma_core_disable
);
36 int bcma_core_enable(struct bcma_device
*core
, u32 flags
)
38 bcma_core_disable(core
, flags
);
40 bcma_awrite32(core
, BCMA_IOCTL
, (BCMA_IOCTL_CLK
| BCMA_IOCTL_FGC
| flags
));
41 bcma_aread32(core
, BCMA_IOCTL
);
43 bcma_awrite32(core
, BCMA_RESET_CTL
, 0);
46 bcma_awrite32(core
, BCMA_IOCTL
, (BCMA_IOCTL_CLK
| flags
));
47 bcma_aread32(core
, BCMA_IOCTL
);
52 EXPORT_SYMBOL_GPL(bcma_core_enable
);
54 void bcma_core_set_clockmode(struct bcma_device
*core
,
55 enum bcma_clkmode clkmode
)
59 WARN_ON(core
->id
.id
!= BCMA_CORE_CHIPCOMMON
&&
60 core
->id
.id
!= BCMA_CORE_PCIE
&&
61 core
->id
.id
!= BCMA_CORE_80211
);
64 case BCMA_CLKMODE_FAST
:
65 bcma_set32(core
, BCMA_CLKCTLST
, BCMA_CLKCTLST_FORCEHT
);
67 for (i
= 0; i
< 1500; i
++) {
68 if (bcma_read32(core
, BCMA_CLKCTLST
) &
69 BCMA_CLKCTLST_HAVEHT
) {
76 pr_err("HT force timeout\n");
78 case BCMA_CLKMODE_DYNAMIC
:
79 pr_warn("Dynamic clockmode not supported yet!\n");
83 EXPORT_SYMBOL_GPL(bcma_core_set_clockmode
);
85 void bcma_core_pll_ctl(struct bcma_device
*core
, u32 req
, u32 status
, bool on
)
89 WARN_ON(req
& ~BCMA_CLKCTLST_EXTRESREQ
);
90 WARN_ON(status
& ~BCMA_CLKCTLST_EXTRESST
);
93 bcma_set32(core
, BCMA_CLKCTLST
, req
);
94 for (i
= 0; i
< 10000; i
++) {
95 if ((bcma_read32(core
, BCMA_CLKCTLST
) & status
) ==
103 pr_err("PLL enable timeout\n");
105 pr_warn("Disabling PLL not supported yet!\n");
108 EXPORT_SYMBOL_GPL(bcma_core_pll_ctl
);
110 u32
bcma_core_dma_translation(struct bcma_device
*core
)
112 switch (core
->bus
->hosttype
) {
113 case BCMA_HOSTTYPE_PCI
:
114 if (bcma_aread32(core
, BCMA_IOST
) & BCMA_IOST_DMA64
)
115 return BCMA_DMA_TRANSLATION_DMA64_CMT
;
117 return BCMA_DMA_TRANSLATION_DMA32_CMT
;
119 pr_err("DMA translation unknown for host %d\n",
120 core
->bus
->hosttype
);
122 return BCMA_DMA_TRANSLATION_NONE
;
124 EXPORT_SYMBOL(bcma_core_dma_translation
);