/* * The TWL4030/TW5030/TPS659x0 family chips include power management, a * USB OTG transceiver, an RTC, ADC, PWM, and lots more. Some versions * include an audio codec, battery charger, and more voltage regulators. * These chips are often used in OMAP-based systems. * * This driver implements software-based resource control for various * voltage regulators. This is usually augmented with state machine * based control.
*/
struct twlreg_info { /* start of regulator's PM_RECEIVER control register bank */
u8 base;
/* twl resource ID, for resource control state machine */
u8 id;
/* voltage in mV = table[VSEL]; table_len must be a power-of-two */
u8 table_len; const u16 *table;
/* State REMAP default configuration */
u8 remap;
/* used by regulator core */ struct regulator_desc desc;
/* chip specific features */ unsignedlong features;
/* data passed from board for external get/set voltage */ void *data;
};
/* LDO control registers ... offset is from the base of its register bank. * The first three registers of all power resource banks help hardware to * manage the various resource groups.
*/ /* Common offset in TWL4030/6030 */ #define VREG_GRP 0 /* TWL4030 register offsets */ #define VREG_TYPE 1 #define VREG_REMAP 2 #define VREG_DEDICATED 3 /* LDO control */ #define VREG_VOLTAGE_SMPS_4030 9 /* TWL6030 register offsets */ #define VREG_TRANS 1 #define VREG_STATE 2 #define VREG_VOLTAGE 3 #define VREG_VOLTAGE_SMPS 4
/* Wait until buffer empty/ready to send a word on power bus. */ staticint twl4030_wait_pb_ready(void)
{
int ret; int timeout = 10;
u8 val;
do {
ret = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &val,
TWL4030_PM_MASTER_PB_CFG); if (ret < 0) return ret;
if (!(val & PB_I2C_BUSY)) return 0;
mdelay(1);
timeout--;
} while (timeout);
return -ETIMEDOUT;
}
/* Send a word over the powerbus */ staticint twl4030_send_pb_msg(unsigned msg)
{
u8 val; int ret;
/* save powerbus configuration */
ret = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &val,
TWL4030_PM_MASTER_PB_CFG); if (ret < 0) return ret;
/* Enable i2c access to powerbus */
ret = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, val | PB_I2C_BWEN,
TWL4030_PM_MASTER_PB_CFG); if (ret < 0) return ret;
ret = twl4030_wait_pb_ready(); if (ret < 0) return ret;
ret = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, msg >> 8,
TWL4030_PM_MASTER_PB_WORD_MSB); if (ret < 0) return ret;
ret = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, msg & 0xff,
TWL4030_PM_MASTER_PB_WORD_LSB); if (ret < 0) return ret;
ret = twl4030_wait_pb_ready(); if (ret < 0) return ret;
/* We can only set the mode through state machine commands... */ switch (mode) { case REGULATOR_MODE_NORMAL:
message = MSG_SINGULAR(DEV_GRP_P1, info->id, RES_STATE_ACTIVE); break; case REGULATOR_MODE_STANDBY:
message = MSG_SINGULAR(DEV_GRP_P1, info->id, RES_STATE_SLEEP); break; default: return -EINVAL;
}
return twl4030_send_pb_msg(message);
}
staticinlineunsignedint twl4030reg_map_mode(unsignedint mode)
{ switch (mode) { case RES_STATE_ACTIVE: return REGULATOR_MODE_NORMAL; case RES_STATE_SLEEP: return REGULATOR_MODE_STANDBY; default: return REGULATOR_MODE_INVALID;
}
}
/* * Support for adjustable-voltage LDOs uses a four bit (or less) voltage * select field in its control register. We use tables indexed by VSEL * to record voltages in milliVolts. (Accuracy is about three percent.) * * Note that VSEL values for VAUX2 changed in twl5030 and newer silicon; * currently handled by listing two slightly different VAUX2 regulators, * only one of which will be configured. * * VSEL values documented as "TI cannot support these values" are flagged * in these tables as UNSUP() values; we normally won't assign them. * * VAUX3 at 3V is incorrectly listed in some TI manuals as unsupported. * TI are revising the twl5030/tps659x0 specs to support that 3.0V setting.
*/ #define UNSUP_MASK 0x8000
template = of_device_get_match_data(&pdev->dev); if (!template) return -ENODEV;
id = template->desc.id;
initdata = of_get_regulator_init_data(&pdev->dev, pdev->dev.of_node,
&template->desc); if (!initdata) return -EINVAL;
info = devm_kmemdup(&pdev->dev, template, sizeof(*info), GFP_KERNEL); if (!info) return -ENOMEM;
/* Constrain board-specific capabilities according to what * this driver and the chip itself can actually do.
*/
c = &initdata->constraints;
c->valid_modes_mask &= REGULATOR_MODE_NORMAL | REGULATOR_MODE_STANDBY;
c->valid_ops_mask &= REGULATOR_CHANGE_VOLTAGE
| REGULATOR_CHANGE_MODE
| REGULATOR_CHANGE_STATUS; switch (id) { case TWL4030_REG_VIO: case TWL4030_REG_VDD1: case TWL4030_REG_VDD2: case TWL4030_REG_VPLL1: case TWL4030_REG_VINTANA1: case TWL4030_REG_VINTANA2: case TWL4030_REG_VINTDIG:
c->always_on = true; break; default: break;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.