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.

AM335x TCLKIN on Linux 3.19

Enabling TCLKIN on Linux 3.8 was a breeze with the help of ddrown's kernel-tclkin patch: https://github.com/ddrown/pps-gmtimer/

However, I needed to switch to a newer version of the kernel (3.19-rc7) in order to get device tree overlay support, and more modern at86rf233 drivers.

This newer version of the kernel features a unified clock system for OMAP 3xxx processors. One of the things that has been lost is the definition of "tclkin_ck", which allowed me to clock my board from an external oscillator using the TCLKIN pin.

Does anybody know how to modify arch/arm/plat-omap/dmtimer.c and arch/arm/mach-omap2/cclock_3xxx_data.c to restore this ability?

  • Hi Andrew,

    This forum supports only the TI distributed SDK, currently v3.14. You can ask about other versions on http://beagleboard.org/Community/Forums

  • Hi Biser

    I believe that the common clock code was checked in pre Linux 3.14, so my question applies to the TI kernel too:

    Relevant files:
    git.ti.com/.../cclock3xxx_data.c
    git.ti.com/.../dmtimer.c

    In particular, line 517 of dtimer.c allows one to set a clock source with parent_name "timer_ext_ck". However, no such parent is specified in cclock3xxx_data.c. Am I missing something here? The common clock code seems to have broken the external timer source.

    Regards
    Andrew

  • Hi Andrew,

    Many of initialization in sdk8 are different with previous sdk. You can see also file .../arch/arm/boot/dts/am33xx-clocks.dtsi. In this file are located many of clocks definitions. I'll post you some good link for using a DT and you will see the more of clocks defined are there:
    devicetree.org/Device_Tree_Usage

    BR
    Ivan
  • Hi Ivan

    Thanks for the reference. I realise that tclkin_ck is exposed by .../arch/arm/boot/dts/am33xx-clocks.dtsi:

    tclkin_ck: tclkin_ck {
        #clock-cells = <0>;
        compatible = "fixed-clock";
        clock-frequency = <10000000>;
    };

    I have noticed that the am335x-bone-common.dtsi  pinmuxes mcu to clkout2 mode, and made sure to disable this before configuring TCLKIN as follows.

    timer_pins: pinmux_timer_pins {
        pinctrl-single,pins = <
    	  0x1b4 0x2A /* P9.41A MODE2 TIMER4 TCLKIN */
    	  0x1a8 0x0F /* P9.41B MODE7 TIMER4 INPUT  */
        >;
    };

    There are no complaints from the DT in dmesg on boot.

    My issue lies with the common OMAP clock format introduced in Linux 3.14+. Earlier versions of the Linux OMAP timer code made provision (see Line 75 of cclock33xx_data.c in Linux 3.12) for a tclkin_ck clock source, which was easy to configure.

    I have already tried to hack cclock3xxx_data.c to make use of tclkin_ck this without any luck :(

    The real trouble is that I can't find anything online that talks about TCLKIN on kernels > 3.8.

    Any help would be greatly appreciated,

  • I'm going to answer my own question for the benefit of others.

    I didn't realise that the initialisation of the TI clocks in more recent kernels takes place here: https://github.com/torvalds/linux/blob/v3.18-rc7/drivers/clk/ti/clk-33xx.c.

    In addition to the DT pinmux and cclock3xxx_data.c hack, I also needed to change clkout2_ck to tclkin_ck on line 119 in the file above to get TCLKIN working.

    I hope this helps others.

  • Hi Andrew,

    Thank you for your information.

    I'm challenging to use TCLKIN to use external clock signal for timer interrupt on Beagle Bone Black.
    Your configuration matches my situation, so I'm trying to modify my kernel as you did.
    My environment is ti-sdk-am335x-evm-7.00.00.00 and Beagle Bone Black.

    I've already do the following modifications:

    - am33xx-clocks.dtsi: clock-frequency as the external signal frequency.
    - am335x-bone-common.dtsi: define two pins (P9.41A, P9.41B) as you described.
    - clk-33xx.c: change clkout2_ck to tclkin_ck

    - arch/arm/plat-omap/dmtimer.c, according to github.com/.../kernel-tclkin.patch
    case OMAP_TIMER_SRC_EXT_CLK:
    - parent_name = "timer_ext_ck";
    + parent_name = "tclkin_ck";
    break;
    }

    I want to patch cclock3xxx_data.c as you described, but I can't access your patch, the result is is "Diff not found." because the diff tool is online service, I think.

    Without the patch for cclock3xxx_data.c, the result is Segmentation fault at register access in plat-omap/dmtimer.c:omap_dm_timer_set_prescaler().
    [ 47.574159] Unhandled fault: external abort on non-linefetch (0x1028) at 0xfa042038

    So, please let me know your patch for cclock3xxx_data.c.

    Regards,
    TOMINAGA 'Tommy' Satoshi

  • My problem is fixed with proper external clock to TCLKIN.

    In my environment, the signal connected to P9.41A (TCLKIN) must be properly provided when the timer registers are accessed.

    Without external clock, 

    Unhandled fault: external abort on non-linefetch (0x1028)

    is occurred at the first timer register access.

    Regards,

    Tommy