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.

PHYTC-3P-PHYCORE-AM335X: Kernel changes for reading cause of reset

Part Number: PHYTC-3P-PHYCORE-AM335X

We would like to know how to read the cause of reset on the AM335x within the kernel level drivers. (We can read it in uboot, but want to do it in the linux driver)

I am surprised that this is still not solved after 7+ years of no support in the driver.

By following other posts, I believe I have added the functions I need, but in the omap_wdt.c file, when it checks to see if the "read_reset_sources" function is present, it skips over it because I believe it is null, or possibly "pdata" is null.

I have added some pr_err lines for debugging, and I never get to the "OMAP Watchdog Reset Value" line:

omap_wdt.c

pr_err("OMAP Watchdog Entered Here Before Reset Checking\n");

if (pdata && pdata->read_reset_sources) {
    u32 rs = pdata->read_reset_sources();
    pr_err("OMAP Watchdog Reset Value: 0x%08X\n", rs);
    if (rs & (1 << OMAP_MPU_WD_RST_SRC_ID_SHIFT))
      wdev->wdog.bootstatus = WDIOF_CARDRESET;
}

In prm33xx.c, I have added the am33xx_prm_read_reset_sources function, and also created the prm_reset_src_map structure based on the AM335x TRM.

I then link the function into the prm_ll_data structure.

(I added the AM33XX... shift bits in the regbits header file)

prm33xx.c

/* AM335x Reset Map */
static struct prm_reset_src_map omap33xx_prm_reset_src_map[] = {
    { AM33XX_GLOBAL_COLD_RST_SHIFT, OMAP_GLOBAL_COLD_RST_SRC_ID_SHIFT },
    { AM33XX_GLOBAL_SW_RST_SHIFT, OMAP_GLOBAL_WARM_RST_SRC_ID_SHIFT },
    { AM33XX_MPU_WD_RST_SHIFT, OMAP_MPU_WD_RST_SRC_ID_SHIFT },
    { AM33XX_EXTERNAL_WARM_RST_SHIFT, OMAP_EXTWARM_RST_SRC_ID_SHIFT },
    { AM33XX_ICEPICK_RST_SHIFT, OMAP_ICEPICK_RST_SRC_ID_SHIFT },
    { -1, -1 },

};

...

/**
* am33xx_prm_read_reset_sources - return last SoC reset source
*
* Return a u32 representing the last reset sources of the SoC. The
* returned reset source bits are standardized across OMAP SoCs.
*/

static u32 am33xx_prm_read_reset_sources(void)
{
    struct prm_reset_src_map *p;
    u32 r = 0;
    u32 v;

    v = am33xx_prm_read_reg(AM33XX_PRM_DEVICE_MOD, AM33XX_PRM_RSTST_OFFSET);

    p = omap33xx_prm_reset_src_map;
    while (p->reg_shift >= 0 && p->std_shift >= 0) {
        if (v & (1 << p->reg_shift))
            r |= 1 << p->std_shift;
        p++;
    }
    pr_err("powerdomain: Reset Source Register: 0x%08X\n", r);

    return r;
}

...

static struct prm_ll_data am33xx_prm_ll_data = {
    .read_reset_sources = am33xx_prm_read_reset_sources,
    .assert_hardreset = am33xx_prm_assert_hardreset,
    .deassert_hardreset = am33xx_prm_deassert_hardreset,
    .is_hardreset_asserted = am33xx_prm_is_hardreset_asserted,
    .reset_system = am33xx_prm_global_warm_sw_reset,
};

What else do I need to do so that omap_wdt recognizes that the driver does indeed support the read_reset_sources function?

  • I just debugged the value of pdata, and it is 0x0000_0000. What is the reason this is not getting populated?

    (this is the non-modified driver code in linux 5.10.65)

    omap_wdt.c

    static int omap_wdt_probe(struct platform_device *pdev)
    {
         struct omap_wd_timer_platform_data *pdata = dev_get_platdata(&pdev->dev);

    ...

  • Hi Jason,

    Since this function is not implemented in the upstream kernel, I didn't review your implementation. But can you please let me know what you need to know this information (reset source)? How will you use this data in user space?

  • Hi Bin,

    This post describes a very similar issue to what I am having. I am not sure how he determined it was due to a device tree probe.

    https://e2e.ti.com/support/processors-group/processors/f/processors-forum/419216/am355x-watchdog-reboot-detection

    User Space Implementation:

    We have enabled the watchdog timer. We want to create a statement in our log file if we detected that the cause of a reboot was due to a watchdog.

    Where can I go to file an official request to make get this supported in the Kernel? All other OMAP devices support this, the TRM details the exact reset causes, I am not sure why this hasn't been added by TI. 

    I thought I have done everything necessary to make this happen, but the pdev->dev is not returning the reset sources function.

  • Hi Jason,

    This forum is the channel for requesting functions/features. I could submit the request now to our sw dev team, but I am afraid the request would be in the low priority queue and not got approved and implemented any time soon.

    As a workaround, can you directly read the reset source register in your application (devmem2 is one of the programs to do so, or directly implement mmap() and read() in your userspace program, depending on how your log is generated...) instead of get the info from sysfs watchdog entry?

  • Hi Bin,

    We will work to get this working with the suggestions you provided.

    In the mean time, please officially submit the request. It may help someone 7 years from now...

    Just a little background, we went to implement the watchdog and then wanted to test / log if the board reset due to the watchdog. We read the documentation and enabled the sysfs feature. We tried reading from the bootstatus file, and the value never changed regardless of the reset cause. What would have taken us less than 1 day to develop, has turned into a week+ ordeal because this feature was not implemented.

    If someone had officially requested this to the software team 7 years ago, I hope we would have had it by now.

    Thanks!

  • Hi Jason,

    Understood.

    But I think the fast path is to let me debug it and fix/implement it, then submit the kernel patch to our sw dev team or kernel upstream directly (depending on how the dev team wants to handle this case).

    My work for this month is already planned so I won't be able to look into it at least in a month or two.

  • Hi Bin,

    Thanks. I think it will be very valuable to the community and the developers that use the AM335x.