2 * Misc utility routines for accessing PMU corerev specific features
3 * of the SiliconBackplane-based Broadcom chips.
5 * Copyright (C) 1999-2010, Broadcom Corporation
7 * Unless you and Broadcom execute a separate written software license
8 * agreement governing use of this software, this software is licensed to you
9 * under the terms of the GNU General Public License version 2 (the "GPL"),
10 * available at http://www.broadcom.com/licenses/GPLv2.php, with the
11 * following added to such license:
13 * As a special exception, the copyright holders of this software give you
14 * permission to link this software with independent modules, and to copy and
15 * distribute the resulting executable under terms of your choice, provided that
16 * you also meet, for each linked independent module, the terms and conditions of
17 * the license of that module. An independent module is a module which is not
18 * derived from this software. The special exception does not apply to any
19 * modifications of the software.
21 * Notwithstanding the above, under no circumstances may you combine this
22 * software in any way with any other Broadcom software provided under a license
23 * other than the GPL, without Broadcom's express prior written consent.
25 * $Id: hndpmu.c,v 1.95.2.17.4.11.2.63 2010/07/21 13:55:09 Exp $
39 #define PMU_ERROR(args)
44 /* SDIO Pad drive strength to select value mappings */
46 uint8 strength; /* Pad Drive Strength in mA */
47 uint8 sel; /* Chip-specific select value */
50 /* SDIO Drive Strength to sel value table for PMU Rev 1 */
51 static const sdiod_drive_str_t sdiod_drive_strength_tab1[] = {
57 /* SDIO Drive Strength to sel value table for PMU Rev 2, 3 */
58 static const sdiod_drive_str_t sdiod_drive_strength_tab2[] = {
67 #define SDIOD_DRVSTR_KEY(chip, pmu) (((chip) << 16) | (pmu))
70 si_sdiod_drive_strength_init(si_t *sih, osl_t *osh, uint32 drivestrength)
73 uint origidx, intr_val = 0;
74 sdiod_drive_str_t *str_tab = NULL;
78 if (!(sih->cccaps & CC_CAP_PMU)) {
82 /* Remember original core before switch to chipc */
83 cc = (chipcregs_t *) si_switch_core(sih, CC_CORE_ID, &origidx, &intr_val);
85 switch (SDIOD_DRVSTR_KEY(sih->chip, sih->pmurev)) {
86 case SDIOD_DRVSTR_KEY(BCM4325_CHIP_ID, 1):
87 str_tab = (sdiod_drive_str_t *)&sdiod_drive_strength_tab1;
88 str_mask = 0x30000000;
91 case SDIOD_DRVSTR_KEY(BCM4325_CHIP_ID, 2):
92 case SDIOD_DRVSTR_KEY(BCM4325_CHIP_ID, 3):
93 case SDIOD_DRVSTR_KEY(BCM4315_CHIP_ID, 4):
94 str_tab = (sdiod_drive_str_t *)&sdiod_drive_strength_tab2;
95 str_mask = 0x00003800;
100 PMU_MSG(("No SDIO Drive strength init done for chip %x rev %d pmurev %d\n",
101 sih->chip, sih->chiprev, sih->pmurev));
106 if (str_tab != NULL) {
107 uint32 drivestrength_sel = 0;
111 for (i = 0; str_tab[i].strength != 0; i ++) {
112 if (drivestrength >= str_tab[i].strength) {
113 drivestrength_sel = str_tab[i].sel;
118 W_REG(osh, &cc->chipcontrol_addr, 1);
119 cc_data_temp = R_REG(osh, &cc->chipcontrol_data);
120 cc_data_temp &= ~str_mask;
121 drivestrength_sel <<= str_shift;
122 cc_data_temp |= drivestrength_sel;
123 W_REG(osh, &cc->chipcontrol_data, cc_data_temp);
125 PMU_MSG(("SDIO: %dmA drive strength selected, set to 0x%08x\n",
126 drivestrength, cc_data_temp));
129 /* Return to original core */
130 si_restore_core(sih, origidx, intr_val);