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.

How to select the 32K oscillator input as clock source for the RTC

Hi,

I have a custom DM8147 design where I need the RTC to be running from the external 1/32768 clock input (and not the internally generated CLKDIVIDER) where we have a more precise oscillator connected. The RTC is drifting too much for our application.

How do I select the sys_32k_clkin_ck instead of the rtc_divider_ck?
I can see that it is done by writing a 1 to the SYSCLK18_CLKSRC register (offset 0x2F0) but I have no idea where to do this!!

Thanks,

Karsten

  • Hi Karsten,

    What is you SDK?

    In case you are on EZSDK, you can make this change in the linux kernel source code.

    {EZSDK}/board-support/linux-2.6.37-psp04.04.00.01/arch/arm/mach-omap2/clock814x_data.c

    My modifications are in yellow:

    int __init ti814x_clk_init(void)
    {
        struct omap_clk *c;
        u32 cpu_clkflg = CK_TI814X;
        
          struct clk *clkp;            
          struct clk *new_parent;       

    ................

    clk_enable_init_clocks();
        
        clkp = clk_get(NULL,"audio_prcm_clkin_ck");    
        if(!clkp) printk("audio_prcm_clkin_ck clk_get failed\n"); 
        else printk("audio_prcm_clkin_ck clk_get successed.\n"); 

        new_parent = clk_get(NULL,"sys_32k_clkin_ck");
        if(!new_parent) printk("sys_32k_clkin_ck clk_get failed\n");
        else printk("sys_32k_clkin_ck clk_get successed.\n");

        clk_set_parent(clkp, new_parent);

        return 0;
    }

    Make new uImage and use it. Thus after booting, the above code makes SYSCLK18_CLKSRC[0] SYSCLK18_SOURCE = 0x1

    Check the below link for more details:

    http://processors.wiki.ti.com/index.php/TI81XX_PSP_PM_CLOCK_FRAMEWORK_User_Guide

    Best regards,
    Pavel


  • Hi Pavel,

    Thanks for the quick answer!

    It solved my problem but I can see that this _might_ not always be enough to select sys_32k_clkin_ck as the parent to audio_prcm_clkin_ck!

    In order to make sure that the RTC is actually running from the sys_32k_clkin_ck then I had to make sure that the sysclk18_ck has audio_prcm_clkin_ck as the parent (and not audio_dpll_clk1_ck which per default has got rtc_divider_ck as the parent)

    So I ended up with something like this:

    int __init ti814x_clk_init(void)
    {
        struct omap_clk *c;
        u32 cpu_clkflg = CK_TI814X;

        struct clk *clkp;
        struct clk *new_parent;

    ...

        clk_enable_init_clocks();

        clkp = clk_get(NULL,"sysclk18_ck");
        if(!clkp)
            printk("sysclk18_ck clk_get failed\n");
        else
        {
            printk("sysclk18_ck clk_get successed.\n");

            new_parent = clk_get(NULL,"audio_prcm_clkin_ck");
            if(!new_parent)
                printk("audio_prcm_clkin_ck clk_get failed\n");
            else
            {
                printk("audio_prcm_clkin_ck clk_get successed! Setting audio_prcm_clkin_ck as parent to sysclk18_ck\n");
                clk_set_parent(clkp, new_parent);
            }
        }


        clkp = clk_get(NULL,"audio_prcm_clkin_ck");
        if(!clkp)
            printk("audio_prcm_clkin_ck clk_get failed\n");
        else
        {
            printk("audio_prcm_clkin_ck clk_get successed.\n");

            new_parent = clk_get(NULL,"sys_32k_clkin_ck");
            if(!new_parent)
                printk("sys_32k_clkin_ck clk_get failed\n");
            else
            {
                printk("audio_prcm_clkin_ck clk_get successed! Setting sys_32k_clkin_ck as parent to audio_prcm_clkin_ck\n");

                clk_set_parent(clkp, new_parent);
            }
        }
        
        return 0;
    }

    Best regards,

    Karsten

  • Karsten,

    Karsten said:
    In order to make sure that the RTC is actually running from the sys_32k_clkin_ck then I had to make sure that the sysclk18_ck has audio_prcm_clkin_ck as the parent (and not audio_dpll_clk1_ck which per default has got rtc_divider_ck as the parent)

    sysclk18_ck has audio_prcm_clkin_ck as a parent clock by default, so if you do not change this setting explicitly, you should not worry about this. Anyway your additional code is not an issue and you can use it as a double check.

    BR
    Pavel