Re: pwm-samsung: incorrect register values for 100% duty cycle
Hi, Thanks for looking into this. On Wed, Oct 1, 2014 at 4:55 AM, Tomasz Figa tomasz.f...@gmail.com wrote: I think that comment is incorrect. If tcmp is written as -1UL then the LED totally turns off. And there is nothing in the Exynos4412 manual to suggest that -1UL should be set in the TCMP register for 100% duty. Looking at Figure 11-3 in 11.3.2 Basic Timer Operation chapter of Exynos 4412 public datasheet [1] (page 659), the calculation above seems correct. The default state of timer output is high and if TCMP is set to a value higher than TCNT, then it will never toggle to low. [1] http://www.samsung.com/global/business/semiconductor/file/product/Exynos_4_Quad_User_Manaul_Public_REV1.00-0.pdf I read that diagram a bit differently. The default state of the output is high, but that is while PWM is inactive. It goes low at the point when the timer starts, and it also goes low when the timer later restarts every time. So once we enable PWM the output should be low. It will go high once TCMP == TCNT, but because TCMP is placed at the maximum value which is never hit, that will never happen, so the LED stays off. But I am confused on a few counts here... I may have identified above why a maximum TCMP value would not result in the output going high, but then why does the rest of the brightness scale work? If I set brightness 200 (tcmp=6470, tcnt=2) then the LED is on dimly. If I set brightness 254 (tcmp=117, tcnt=2) then the LED comes on much brighter. But according to my above explanation and looking at the diagram you referenced, such a decrease in the tcmp value would result in a shorter time for which the output is high, i.e. lower brightness, but actually the brightness increases. If the output is high by default, why don't I see the LED turning on in uboot before Linux has even loaded? Does the above diagram really apply to Linux? Because Linux sets the invert bit for all the channels in pwm_samsung_probe. So maybe that diagram is irrelevant until we invert the TOUT signal shown there? Daniel -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: pwm-samsung: incorrect register values for 100% duty cycle
On 02.10.2014 21:27, Daniel Drake wrote: Hi, Thanks for looking into this. On Wed, Oct 1, 2014 at 4:55 AM, Tomasz Figa tomasz.f...@gmail.com wrote: I think that comment is incorrect. If tcmp is written as -1UL then the LED totally turns off. And there is nothing in the Exynos4412 manual to suggest that -1UL should be set in the TCMP register for 100% duty. Looking at Figure 11-3 in 11.3.2 Basic Timer Operation chapter of Exynos 4412 public datasheet [1] (page 659), the calculation above seems correct. The default state of timer output is high and if TCMP is set to a value higher than TCNT, then it will never toggle to low. [1] http://www.samsung.com/global/business/semiconductor/file/product/Exynos_4_Quad_User_Manaul_Public_REV1.00-0.pdf I read that diagram a bit differently. The default state of the output is high, but that is while PWM is inactive. It goes low at the point when the timer starts, and it also goes low when the timer later restarts every time. So once we enable PWM the output should be low. That's right. I believe this should match what I wrote in my mail. It will go high once TCMP == TCNT, but because TCMP is placed at the maximum value which is never hit, that will never happen, so the LED stays off. Right. Although all the levels above don't take into account state of the inverter. What's shown on the diagram in the datasheet is with inverter disabled, which corresponds to Linux's PWM_POLARITY_INVERSED. But I am confused on a few counts here... I may have identified above why a maximum TCMP value would not result in the output going high, but then why does the rest of the brightness scale work? If I set brightness 200 (tcmp=6470, tcnt=2) then the LED is on dimly. If I set brightness 254 (tcmp=117, tcnt=2) then the LED comes on much brighter. But according to my above explanation and looking at the diagram you referenced, such a decrease in the tcmp value would result in a shorter time for which the output is high, i.e. lower brightness, but actually the brightness increases. This is strange. I remember verifying various edge cases with a scope on an Exynos4210-based Origen board and I don't recall any issues. Unfortunately I don't have appropriate hardware to recheck this specific case anymore. Could you specify on what board you are testing this or how the LED is wired? If the output is high by default, why don't I see the LED turning on in uboot before Linux has even loaded? Most likely because u-boot doesn't switch the pinmux from default input to respective special function. Does the above diagram really apply to Linux? Because Linux sets the invert bit for all the channels in pwm_samsung_probe. So maybe that diagram is irrelevant until we invert the TOUT signal shown there? The diagram illustrates how the hardware works. It shows TOUT levels without inverter enabled. Still, the inverter simply negates the signal, so the diagram is applicable, just with the exception that you need to consider the output inverted. Best regards, Tomasz -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: pwm-samsung: incorrect register values for 100% duty cycle
On Thu, Oct 2, 2014 at 1:49 PM, Tomasz Figa tomasz.f...@gmail.com wrote: This is strange. I remember verifying various edge cases with a scope on an Exynos4210-based Origen board and I don't recall any issues. Unfortunately I don't have appropriate hardware to recheck this specific case anymore. Could you specify on what board you are testing this or how the LED is wired? Its a new board prototype with Exynos4412. The PWM output connects to a APL5606AKI-TRG chip which does AC-to-DC conversion and multiplies the voltage, and outputs to a simple LED. Not the easiest unknown setup to work with, I know. I'll get hold of a multimeter and try to get a better understanding of what is happening. You've given me a few ideas. Thanks Daniel -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
pwm-samsung: incorrect register values for 100% duty cycle
Hi, I'm using pwm-samsung on Exynos4412 for a variable-brightness LED. When the LED is set to maximum brightness via the pwm-leds driver, we arrive at pwm_samsung_config with duty_ns = period_ns, i.e. 100% duty cycle. This function does: /* -1UL will give 100% duty. */ --tcmp; writel(tcmp, our_chip-base + REG_TCMPB(pwm-hwpwm)); I think that comment is incorrect. If tcmp is written as -1UL then the LED totally turns off. And there is nothing in the Exynos4412 manual to suggest that -1UL should be set in the TCMP register for 100% duty. If I remove that --tcmp line, so that 100% duty cycle is handled as tcmp=0, the problem is solved: the LED turns on at max brightness when the leds subsystem requests so. Any ideas? Is this -1UL thing a quirk from older chip versions not applicable to Exynos4? Thanks Daniel -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html