tried again with pwm2 (fan-socket), but i do not recognize any change in brightness…
root@bpi-r64:/sys/class/pwm/pwmchip0/pwm2# echo 10000 > period
root@bpi-r64:/sys/class/pwm/pwmchip0/pwm2# echo 5000 > duty_cycle
root@bpi-r64:/sys/class/pwm/pwmchip0/pwm2# echo 1000 > duty_cycle
root@bpi-r64:/sys/class/pwm/pwmchip0/pwm2# echo 8000 > duty_cycle
only if i change enable to 1, led goes off
@Mbk_Kamble which kernel do you use? i’m using the 5.7-pwm branch
as far as i looked into other pwm drivers, the function for inverting is basicly same
static int vt8500_pwm_set_polarity(struct pwm_chip *chip,
struct pwm_device *pwm,
enum pwm_polarity polarity)
{
struct vt8500_chip *vt8500 = to_vt8500_chip(chip);
u32 val;
val = readl(vt8500->base + REG_CTRL(pwm->hwpwm));
if (polarity == PWM_POLARITY_INVERSED)
val |= CTRL_INVERT;
else
val &= ~CTRL_INVERT;
writel(val, vt8500->base + REG_CTRL(pwm->hwpwm));
pwm_busy_wait(vt8500, pwm->hwpwm, STATUS_CTRL_UPDATE);
return 0;
}
static int ecap_pwm_set_polarity(struct pwm_chip *chip, struct pwm_device *pwm,
enum pwm_polarity polarity)
{
struct ecap_pwm_chip *pc = to_ecap_pwm_chip(chip);
u16 value;
pm_runtime_get_sync(pc->chip.dev);
value = readw(pc->mmio_base + ECCTL2);
if (polarity == PWM_POLARITY_INVERSED)
/* Duty cycle defines LOW period of PWM */
value |= ECCTL2_APWM_POL_LOW;
else
/* Duty cycle defines HIGH period of PWM */
value &= ~ECCTL2_APWM_POL_LOW;
writew(value, pc->mmio_base + ECCTL2);
pm_runtime_put_sync(pc->chip.dev);
return 0;
}
i tried to find a mtk-specific value for inverting the polarity (mt7622 datasheet), but found none. basicly we can do similar by modifying the duty-cycle value before writing to register (or write again). something like duty_cycle=period - duty_cycle but this inverts not the enable-state of course…so still confusing
maybe i’ve found something on Page 527…
110061CC PWM_LOOP_BACK_TEST (lower 5 bits named PWMx_STATUS) for pwm0-4 (not 5&6)
0 PWMx Output is low
1 PWMx Output is high
@sam33 any idea of reversing/fan socket? I wonder why @Mbk_Kamble had success on changing speed of fan and i see no change on modifying duty_cycle in both directions