• Thierry Reding's avatar
    pwm: Allow chips to support multiple PWMs · f051c466
    Thierry Reding authored
    Many PWM controllers provide access to more than a single PWM output and
    may even share some resource among them. Allowing a PWM chip to provide
    multiple PWM devices enables better sharing of those resources. As a
    side-effect this change allows easy integration with the device tree
    where a given PWM can be looked up based on the PWM chip's phandle and a
    corresponding index.
    
    This commit modifies the PWM core to support multiple PWMs per struct
    pwm_chip. It achieves this in a similar way to how gpiolib works, by
    allowing PWM ranges to be requested dynamically (pwm_chip.base == -1) or
    starting at a given offset (pwm_chip.base >= 0). A chip specifies how
    many PWMs it controls using the npwm member. Each of the functions in
    the pwm_ops structure gets an additional argument that specified the PWM
    number (it can be converted to a per-chip index by subtracting the
    chip's base).
    
    The total maximum number of PWM devices is currently fixed to 1024 while
    the data is actually stored in a radix tree, thus saving resources if
    not all of them are used.
    Reviewed-by: 's avatarMark Brown <broonie@opensource.wolfsonmicro.com>
    Reviewed-by: 's avatarShawn Guo <shawn.guo@linaro.org>
    [eric@eukrea.com: fix error handling in pwmchip_add]
    Signed-off-by: 's avatarEric Bénard <eric@eukrea.com>
    Signed-off-by: 's avatarThierry Reding <thierry.reding@avionic-design.de>
    f051c466
pwm.txt 2.27 KB