/* * Marvell Berlin PWM driver * * Copyright (C) 2015 Marvell Technology Group Ltd. * * Author: Antoine Tenart <antoine.tenart@free-electrons.com> * * This file is licensed under the terms of the GNU General Public * License version 2. This program is licensed "as is" without any * warranty of any kind, whether express or implied.
*/
#define BERLIN_PWM_EN 0x0 #define BERLIN_PWM_ENABLE BIT(0) #define BERLIN_PWM_CONTROL 0x4 /* * The prescaler claims to support 8 different moduli, configured using the * low three bits of PWM_CONTROL. (Sequentially, they are 1, 4, 8, 16, 64, * 256, 1024, and 4096.) However, the moduli from 4 to 1024 appear to be * implemented by internally shifting TCNT left without adding additional * bits. So, the max TCNT that actually works for a modulus of 4 is 0x3fff; * for 8, 0x1fff; and so on. This means that those moduli are entirely * useless, as we could just do the shift ourselves. The 4096 modulus is * implemented with a real prescaler, so we do use that, but we treat it * as a flag instead of pretending the modulus is actually configurable.
*/ #define BERLIN_PWM_PRESCALE_4096 0x7 #define BERLIN_PWM_INVERT_POLARITY BIT(3) #define BERLIN_PWM_DUTY 0x8 #define BERLIN_PWM_TCNT 0xc #define BERLIN_PWM_MAX_TCNT 65535
value = berlin_pwm_readl(bpc, pwm->hwpwm, BERLIN_PWM_CONTROL); if (prescale_4096)
value |= BERLIN_PWM_PRESCALE_4096; else
value &= ~BERLIN_PWM_PRESCALE_4096;
berlin_pwm_writel(bpc, pwm->hwpwm, value, BERLIN_PWM_CONTROL);
ret = clk_prepare_enable(bpc->clk); if (ret) return ret;
for (i = 0; i < chip->npwm; i++) { struct berlin_pwm_channel *channel = &bpc->channel[i];
berlin_pwm_writel(bpc, i, channel->ctrl, BERLIN_PWM_CONTROL);
berlin_pwm_writel(bpc, i, channel->duty, BERLIN_PWM_DUTY);
berlin_pwm_writel(bpc, i, channel->tcnt, BERLIN_PWM_TCNT);
berlin_pwm_writel(bpc, i, channel->enable, BERLIN_PWM_EN);
}
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.