/* * This driver handles the PWMs of TWL4030 and TWL6030. * The TRM names for the PWMs on TWL4030 are: PWM0, PWM1 * TWL6030 also have two PWMs named in the TRM as PWM1, PWM2
*/
#define TWL_PWM_MAX 0x7f
/* Registers, bits and macro for TWL4030 */ #define TWL4030_GPBR1_REG 0x0c #define TWL4030_PMBR1_REG 0x0d
/* * To configure the duty period: * On-cycle is set to 1 (the minimum allowed value) * The off time of 0 is not configurable, so the mapping is: * 0 -> off cycle = 2, * 1 -> off cycle = 2, * 2 -> off cycle = 3, * 126 - > off cycle 127, * 127 - > off cycle 1 * When on cycle == off cycle the PWM will be always on
*/ if (duty_cycle == 1)
duty_cycle = 2; elseif (duty_cycle > TWL_PWM_MAX)
duty_cycle = 1;
base = pwm->hwpwm * 3;
pwm_config[1] = duty_cycle;
ret = twl_i2c_write(TWL_MODULE_PWM, pwm_config, base, 2); if (ret < 0)
dev_err(pwmchip_parent(chip), "%s: Failed to configure PWM\n", pwm->label);
mutex_lock(&twl->mutex);
val = twl->twl6030_toggle3;
val |= TWL6030_PWM_TOGGLE(pwm->hwpwm, TWL6030_PWMXS | TWL6030_PWMXEN);
val &= ~TWL6030_PWM_TOGGLE(pwm->hwpwm, TWL6030_PWMXR);
ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, val, TWL6030_TOGGLE3_REG); if (ret < 0) {
dev_err(pwmchip_parent(chip), "%s: Failed to enable PWM\n", pwm->label); goto out;
}
mutex_lock(&twl->mutex);
val = twl->twl6030_toggle3;
val |= TWL6030_PWM_TOGGLE(pwm->hwpwm, TWL6030_PWMXR);
val &= ~TWL6030_PWM_TOGGLE(pwm->hwpwm, TWL6030_PWMXS | TWL6030_PWMXEN);
ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, val, TWL6030_TOGGLE3_REG); if (ret < 0) {
dev_err(pwmchip_parent(chip), "%s: Failed to disable PWM\n", pwm->label); goto out;
}
val |= TWL6030_PWM_TOGGLE(pwm->hwpwm, TWL6030_PWMXEN);
ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, val, TWL6030_TOGGLE3_REG); if (ret < 0) {
dev_err(pwmchip_parent(chip), "%s: Failed to disable PWM\n", pwm->label); goto out;
}
val &= ~TWL6030_PWM_TOGGLE(pwm->hwpwm, TWL6030_PWMXEN);
ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, val, TWL6030_TOGGLE3_REG); if (ret < 0) {
dev_err(pwmchip_parent(chip), "%s: Failed to disable PWM\n", pwm->label); goto out;
}
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.