pwm: improvements and ability to set polarity