This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

omap4460 about leds-omap-pwm.c

Hello:

I met a problem when I want to enable  DMTIMER10_PWM to generate 15KHz to

control the LCD backlight. I am using led-omap-pwm.c as my driver to control duty cycle. 

And I select system clock as my clock source (38.4MHz). I know which registers I should

set to generate 15KHz. The following is my thoughts:

1. configure EMU18/DMTIMER10_PWM_EVT/AB4 to be PWM mode (PinMux)

2. set GPTIMER10 CLOCK CONTROL register : GPTIMER10 CLOCK CONTROL(0x4a009428):

    0x00000002   (selects sys_clk 38.4MHz clock)

3. set TLDR register : select 15KHz :TLDR(0x4808602C): 0xFFFFF5FF

4. set TCLR register :  TCLR(0x48086024): 0X00001843 (To be set at last) 

Code implement: I am using leds-omap-pwm.c to be my driver.

I have change some places.  

static void omap_pwm_led_set_blink(struct omap_pwm_led *led)
{

if (!led->powered)
return;

if (led->on_period != 0 && led->off_period != 0) {

unsigned long load_reg, cmp_reg;

/*******change duty cycle*****/ //jaden change 20120531

// load_reg = 32768 * (led->on_period + led->off_period) / 1000;
// cmp_reg = 32768 * led->on_period / 1000;


load_reg = 38400000 * (led->on_period + led->off_period) / 1000000;
cmp_reg = 38400000 * led->on_period / 1000000;


/*******change duty cycle*****/

omap_dm_timer_stop(led->blink_timer);
omap_dm_timer_set_load(led->blink_timer, 1, -load_reg);
omap_dm_timer_set_match(led->blink_timer, 1, -cmp_reg);
omap_dm_timer_set_pwm(led->blink_timer, 1, 1,
OMAP_TIMER_TRIGGER_OVERFLOW_AND_COMPARE);
omap_dm_timer_write_counter(led->blink_timer, -2);
omap_dm_timer_start(led->blink_timer);
} else {
omap_dm_timer_set_pwm(led->blink_timer, 1, 1,
OMAP_TIMER_TRIGGER_OVERFLOW_AND_COMPARE);
omap_dm_timer_stop(led->blink_timer);
}
}

static void omap_pwm_led_power_on(struct omap_pwm_led *led)
{
if (led->powered)
return;
led->powered = 1;

/* Select clock */
omap_dm_timer_enable(led->intensity_timer);
omap_dm_timer_set_source(led->intensity_timer, OMAP_TIMER_SRC_32_KHZ);

/* Turn voltage on */
if (led->pdata->set_power != NULL)
led->pdata->set_power(led->pdata, 1);

/* Enable PWM timers */
if (led->blink_timer != NULL) {
omap_dm_timer_enable(led->blink_timer);

/****change clock source*******/ //jaden change 20120531
//omap_dm_timer_set_source(led->blink_timer,
// OMAP_TIMER_SRC_32_KHZ);
omap_dm_timer_set_source(led->blink_timer,
OMAP_TIMER_SRC_SYS_CLK);                  //to select system_clock
/***********************/
omap_pwm_led_set_blink(led);
}

omap_dm_timer_set_load(led->intensity_timer, 1, 0xffffff00);
}

In board-44xx-tablet.c, I add these following codes. 

void test_led_set_power(struct omap_pwm_led_platform_data *self,
int on_off)
{
if (on_off) {

__raw_writel(0x00000004, OMAP2_L4_IO_ADDRESS(GPT_TSICR));  //#define GPT_TSICR 0x48086040

__raw_writel(0x00000001, OMAP2_L4_IO_ADDRESS(GPT_TTGR)); //#define GPT_TTGR 0x48086030

__raw_writel(0x00001843, OMAP2_L4_IO_ADDRESS(GPT_TCLR)); //#define GPT_TCLR 0x48086028

} else {

}
}

static struct omap_pwm_led_platform_data test_pwm = {
.name = "test_pwm",
.blink_timer = 10,
.set_power = test_led_set_power,
};

Here is my situation, I can see my devices name tese_pwm in /sys/class/leds/test_pwm,

and there are few functions I can set  (like on_period and off_period). Bbut the oscilloscope

doesn't not reflect anything (the voltage is still low). Do anyone give us some suggestions to

verify?

Thank you. 

  • Hi,

    I haven't checked your snippet in detail and I haven't modified any code on my side, but I can tell you that I what I am trying and is working for me (however, I am routing dptimer10 through USBB1_ULPITLL_DAT6 pad instead of DPM_EMU18 pad, for ease of testing). Since I am using USBB1_ULPITLL_DAT6 pad, I am connecting the oscilloscope to the test point TP19 on the processor board (close the J1 connector), but I think this shouldn't matter if you are using another pad to route it... here is what I am doing, pretty much you are doing almost the same:

    1.- Configure the pad (USBB1_ULPITLL_DAT6 in my case, DPM_EMU18 in your case):

    /omapconf write 0x4A1000D4 0x0001010C (/omapconf write 0x4A1001D0 0x0001010C, in your case).

    2.- Set GPTIMER10 CLOCK CONTROL register (selects sysclock as clock source = 38.4Mhz).

    /omapconf write 0x4A009428 0x00000002

    3.- Configure the timer (GPT_TCLR) but do not start it yet; set pwm output, toggle modulation, trigger on overflow and match, low level default pwm value and autoreload timer:

    GPO_CFG(14) = 0x0 (pwm output)
    PT(12) = 0x1 (toggle modulation).
    TRG(11:10) = 0x1 (trigger on overflow and match)
    SCPWM(7) = 0x0 (PWM default value)
    AR(1) = 0x1 (Autoreload timer)

    /omapconf write 0x48086024 0x00001802

    4.- Configure load count after overflow (GPT_TLDR):

    /omapconf write 0x4808602C 0xFFFFF5FF

    5.- Configure compare count (GPT_TMAR). For testing purposes, I am setting this to get a 33%low, 66%high period. 0xFFFFFAFF should give a 50%/50% period:

    /omapconf write 0x48086038 0xFFFFFCFF

    6.- Enable compare (GPT_TLCR):

    /omapconf write 0x48086024 0x00001842

    7.- Start the timer:

    /omapconf write 0x48086024 0x00001843

    However, I am observing a weird behavior on the current release that I tried - the timer is not enabled until about ~2mins after I have it enabled at least once... after that, the timer can be enabled/disabled immediately. I am trying to figure out why this is happening, but I guess it might be different for you...

    Also, make sure you are only routing once the dptimer10 to either USBB1_ULPITLL_DAT6 or DPM_EMU18, but not both - as this could cause an issue.

    A quick way to see if you are actually manipulating the right line could be to set the default PWM value to 1 (the voltage level should go up immediatly in all cases). This is bit 7 of GPT_CLR.

    Hope this is helpful.

  • Hi  Jorge Bustamante:

    Thanks for your replying. I have enabled the GP_TIMER20 to generate 15KHZ. The problem I met before

    was because I am confusing with blink timer and intensity timer. After clarifying some questions, the GP_TIMER10

    can generate 15KHz. The solutions are the same as you mentioned above. Thank you.

    Best regards. 

    Jaden




  • hi all,

           I have a question to ask. I am now using the pwm timer 8.Just like what Jorge Bustamante said. I can get the pwm success,but there is still something wrong,

    At t beginning, i can get the pwm, i tried serval time, it is ok.But after a short time later, i want to get the pwm, but then i fail to get it. Then i can never get the pwm,

    unless i restart the device.

          It is really very strange. Hope to get the answer from you .

          Thanks very much!!