ARM: OMAP: second set of PRM/CM/CGRM cleanup patches for 3.8
Subsystems (6)
Paul Walmsley
maintainercover ARM: OMAP: second set of PRM/CM/CGRM cleanup patches for 3.8
This series removes the omap_prcm_get_reset_sources() function. This was exported from arch/arm/mach-omap2/prcm.c for use by the OMAP watchdog driver to report the "boot reason". This series reimplements this using a platform_data function pointer for the time being, but after the upcoming PRM/CM drivers are merged, the watchdog driver can be patched to use an exported function from the drivers.
This series will also be used as a base for other PRM/CM cleanup during the 3.8 time frame, since it adds the prm_register() and prm_unregister() functions. These are called by SoC-specific PRM IP block drivers to register function pointers with the PRM subsystem.
This series changes the format of the watchdog's boot reason data to conform with the watchdog subsystem standard (the WDIOF_* flags). If users need more detail than that interface provides, either the watchdog interface can be patched, or those users can get that information from the upcoming PRM drivers.
- Paul
---
prcm_cleanup_b_3.8
text data bss dec hex filename
7519295 696796 5613996 13830087 d307c7 vmlinux.omap2plus_defconfig.orig
7520203 696868 5613996 13831067 d30b9b vmlinux.omap2plus_defconfig
Paul Walmsley (7):
ARM: OMAP2+: PRM: prepare for use of prm_ll_data function pointers
ARM: OMAP2+: CM: prepare for use of cm_ll_data function pointers
ARM: OMAP1: create read_reset_sources() function (for initial use by watchdog)
ARM: OMAP2+: PRM: create PRM reset source API for the watchdog timer driver
ARM: OMAP2+: WDT: move init; add read_reset_sources pdata function pointer
watchdog: OMAP: use standard GETBOOTSTATUS interface; use platform_data fn ptr
ARM: OMAP2+: PRCM: remove omap_prcm_get_reset_sources()
arch/arm/mach-omap1/common.h | 2 + arch/arm/mach-omap1/devices.c | 21 ++++++- arch/arm/mach-omap1/reset.c | 39 +++++++++++++ arch/arm/mach-omap2/Makefile | 2 - arch/arm/mach-omap2/cm.h | 12 ++++ arch/arm/mach-omap2/cm_common.c | 71 +++++++++++++++++++++++ arch/arm/mach-omap2/devices.c | 26 -------- arch/arm/mach-omap2/prcm.c | 12 ---- arch/arm/mach-omap2/prm-regbits-24xx.h | 4 + arch/arm/mach-omap2/prm-regbits-34xx.h | 10 +++ arch/arm/mach-omap2/prm.h | 53 +++++++++++++++++ arch/arm/mach-omap2/prm2xxx.c | 68 ++++++++++++++++++++++ arch/arm/mach-omap2/prm2xxx.h | 4 + arch/arm/mach-omap2/prm2xxx_3xxx.h | 2 + arch/arm/mach-omap2/prm3xxx.c | 65 +++++++++++++++++++++ arch/arm/mach-omap2/prm3xxx.h | 2 + arch/arm/mach-omap2/prm44xx.c | 83 ++++++++++++++++++++++++++- arch/arm/mach-omap2/prm44xx.h | 2 + arch/arm/mach-omap2/prm_common.c | 78 +++++++++++++++++++++++++ arch/arm/mach-omap2/wd_timer.c | 33 +++++++++++ arch/arm/plat-omap/include/plat/prcm.h | 1 drivers/watchdog/omap_wdt.c | 26 ++++---- include/linux/platform_data/omap-wd-timer.h | 38 ++++++++++++ 23 files changed, 594 insertions(+), 60 deletions(-) create mode 100644 arch/arm/mach-omap2/cm_common.c create mode 100644 include/linux/platform_data/omap-wd-timer.h
Paul Walmsley
maintainerPATCH 1/7 ARM: OMAP2+: PRM: prepare for use of prm_ll_data function pointers
There are several PRM operations which behave similarly across OMAP2+ SoCs, but which have slight differences in their underlying implementations. For example, to fetch the SoC's last reset sources, different registers are read across OMAP2xxx, 3xxx, and 44xx, and different bits are used on each SoC. But the information returned is so similar that a single, common interface for drivers is useful.
This patch creates the support code for this function pointer registration process. No function pointers are included yet, but a subsequent patch will create one for the reset source API.
To illustrate the end goal with the above reset source example, each per-SoC driver will use its own low-level implementation function -- e.g., prm2xxx.c would contain omap2xxx_prm_read_reset_sources(). This function would read the appropriate register and remap the register bits to a standard set of reset source bits. When the prm2xxx.c driver is loaded, it would register this function with the common PRM driver, prm.c. prm.c would then export a common function, omap_prm_read_reset_sources(). Calling it would call through to the function pointer for the currently-registered SoC PRM driver. This will allow other drivers to use PRM-provided data and operations without needing to know which SoC is currently in use.
--- arch/arm/mach-omap2/prm.h | 11 ++++++++ arch/arm/mach-omap2/prm_common.c | 52 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+)
arch/arm/mach-omap2/prm.h +11 -0
@@ -52,5 +52,16 @@#define OMAP_POWERSTATE_SHIFT 0#define OMAP_POWERSTATE_MASK (0x3 << 0) +#ifndef __ASSEMBLER__ + +/** +* struct prm_ll_data - fn ptrs to per-SoC PRM function implementations +*/ +struct prm_ll_data {}; + +extern int prm_register (struct prm_ll_data *pld); +extern int prm_unregister (struct prm_ll_data *pld); + +#endif #endif
arch/arm/mach-omap2/prm_common.c +52 -0
61 lines not on this page · raw message
Paul Walmsley
maintainerPATCH 2/7 ARM: OMAP2+: CM: prepare for use of cm_ll_data function pointers
In reply to Paul WalmsleyThere are several CM operations which behave similarly across OMAP2+ SoCs, but which have slight differences in their underlying implementations.
This patch creates the support code for this function pointer registration process. No function pointers are included yet, but a subsequent patch will create these for the module IDLEST registers.
This patch allows other code to use CM-provided data and operations without needing to know which SoC is currently in use. A further description of the concept is provided in the patch entitled "ARM: OMAP2+: PRM: prepare for use of prm_ll_data function pointers".
--- arch/arm/mach-omap2/Makefile | 2 + arch/arm/mach-omap2/cm.h | 12 +++++++ arch/arm/mach-omap2/cm_common.c | 71 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 arch/arm/mach-omap2/cm_common.c
arch/arm/mach-omap2/Makefile +1 -1
@@ -93,7 +93,7 @@ obj-$(CONFIG_ARCH_OMAP4) += cpuidle44xx.o endif # PRCM -obj-y += prcm.o prm_common.o +obj-y += prcm.o prm_common.o cm_common.o obj-$(CONFIG_ARCH_OMAP2) += prm2xxx_3xxx.o prm2xxx.o cm2xxx.o obj-$(CONFIG_ARCH_OMAP3) += prm2xxx_3xxx.o prm3xxx.o cm3xxx.o obj-$(CONFIG_ARCH_OMAP3) += vc3xxx_data.o vp3xxx_data.o
arch/arm/mach-omap2/cm.h +12 -0
@@ -33,4 +33,16 @@*/ #define MAX_MODULE_DISABLE_TIME 5000 +# ifndef __ASSEMBLER__ + +/** +* struct cm_ll_data - fn ptrs to per-SoC CM function implementations +*/ +struct cm_ll_data {}; + +extern int cm_register (struct cm_ll_data *cld); +extern int cm_unregister (struct cm_ll_data *cld); + +# endif +#endif
arch/arm/mach-omap2/cm_common.c new file +71 -0
71 lines not on this page · raw message
Paul Walmsley
maintainerPATCH 3/7 ARM: OMAP1: create read_reset_sources() function (for initial use by watchdog)
In reply to Paul WalmsleyOn OMAP1, the existing OMAP watchdog driver reads a register directly from a non-watchdog IP block. It also does not convert the register's contents into the standard WDIOF_* bits expected from the GETBOOTSTATUS ioctl().
To move towards fixing these problems, create an function in arch/arm/mach-omap1 to return the reset source data. A subsequent patch will provide this function to the watchdog driver via platform_data.
In the long term, the best approach would be to move this function to a new OMAP1 driver that handles access to the OMAP1 Clock Generation and Reset Management IP block. Then no platform_data would be needed.
--- arch/arm/mach-omap1/common.h | 2 ++ arch/arm/mach-omap1/reset.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+)
arch/arm/mach-omap1/common.h +2 -0
@@ -90,4 +90,6 @@ extern int ocpi_enable(void);static inline int ocpi_enable (void ) {return 0 ; }#endif +extern u32 omap1_read_reset_sources (void ); +#endif /* __ARCH_ARM_MACH_OMAP1_COMMON_H */
arch/arm/mach-omap1/reset.c +39 -0
@@ -8,8 +8,22 @@#include <mach/hardware.h> +#include "iomap.h" #include "common.h" +/* ARM_SYSST bit shifts related to SoC reset sources */ +#define ARM_SYSST_POR_SHIFT 5 +#define ARM_SYSST_EXT_RST_SHIFT 4 +#define ARM_SYSST_ARM_WDRST_SHIFT 2 +#define ARM_SYSST_GLOB_SWRST_SHIFT 1 + +/* Standardized reset source bits (across all OMAP SoCs) */ +#define OMAP_GLOBAL_COLD_RST_SRC_ID_SHIFT 0 +#define OMAP_GLOBAL_WARM_RST_SRC_ID_SHIFT 1 +#define OMAP_MPU_WD_RST_SRC_ID_SHIFT 3 +#define OMAP_EXTWARM_RST_SRC_ID_SHIFT 5 + +void omap1_restart (char mode,const char *cmd) {/*
@@ -23,3 +37,28 @@ void omap1_restart(char mode, const char *cmd)omap_writew (1 ,ARM_RSTCT1 ); } + +/** +* omap1_read_reset_sources - return the source of the SoC's last reset +* +* Returns bits that represent the last reset source for the SoC. The +* format is standardized across OMAPs for use by the OMAP watchdog. +*/ +u32 omap1_read_reset_sources (void ) +{ +int ret =0 ; +u16 rs; + + rs =__raw_readw (OMAP1_IO_ADDRESS (ARM_SYSST )); + +if (rs & (1 <<ARM_SYSST_POR_SHIFT )) + ret |=1 <<OMAP_GLOBAL_COLD_RST_SRC_ID_SHIFT ; +if (rs & (1 <<ARM_SYSST_EXT_RST_SHIFT )) + ret |=1 <<OMAP_EXTWARM_RST_SRC_ID_SHIFT ; +if (rs & (1 <<ARM_SYSST_ARM_WDRST_SHIFT )) + ret |=1 <<OMAP_MPU_WD_RST_SRC_ID_SHIFT ; +if (rs & (1 <<ARM_SYSST_GLOB_SWRST_SHIFT )) + ret |=1 <<OMAP_GLOBAL_WARM_RST_SRC_ID_SHIFT ; + +return ret; +}
Paul Walmsley
maintainerPATCH 4/7 ARM: OMAP2+: PRM: create PRM reset source API for the watchdog timer driver
In reply to Paul WalmsleyThe OMAP watchdog timer driver needs to determine what caused the SoC to reset for its GETBOOTSTATUS ioctl. So, define a set of standard reset sources across OMAP SoCs. For OMAP2xxx, 3xxx, and 4xxx SoCs, define mappings from the SoC-specific reset source register bits to the standardized reset source IDs. Create SoC-specific PRM functions that read the appropriate per-SoC register and use the mapping to return the standardized reset bits. Register the SoC-specific PRM functions with the common PRM code via prm_register(). Create a function in the common PRM code, prm_read_reset_sources(), that calls the SoC-specific function, registered during boot.
This patch does not yet handle some SoCs, such as AM33xx. Those SoCs were not handled by the code this will replace.
--- arch/arm/mach-omap2/prm-regbits-24xx.h | 4 ++ arch/arm/mach-omap2/prm-regbits-34xx.h | 10 ++++ arch/arm/mach-omap2/prm.h | 44 +++++++++++++++++ arch/arm/mach-omap2/prm2xxx.c | 68 ++++++++++++++++++++++++++ arch/arm/mach-omap2/prm2xxx.h | 4 ++ arch/arm/mach-omap2/prm2xxx_3xxx.h | 2 + arch/arm/mach-omap2/prm3xxx.c | 65 +++++++++++++++++++++++++ arch/arm/mach-omap2/prm3xxx.h | 2 + arch/arm/mach-omap2/prm44xx.c | 83 +++++++++++++++++++++++++++++++- arch/arm/mach-omap2/prm44xx.h | 2 + arch/arm/mach-omap2/prm_common.c | 26 ++++++++++ 11 files changed, 306 insertions(+), 4 deletions(-)
arch/arm/mach-omap2/prm-regbits-24xx.h +4 -0
@@ -209,9 +209,13 @@/* RM_RSTST_WKUP specific bits */ /* 2430 calls EXTWMPU_RST "EXTWARM_RST" and GLOBALWMPU_RST "GLOBALWARM_RST" */ +#define OMAP24XX_EXTWMPU_RST_SHIFT 6#define OMAP24XX_EXTWMPU_RST_MASK (1 << 6) +#define OMAP24XX_SECU_WD_RST_SHIFT 5#define OMAP24XX_SECU_WD_RST_MASK (1 << 5) +#define OMAP24XX_MPU_WD_RST_SHIFT 4#define OMAP24XX_MPU_WD_RST_MASK (1 << 4) +#define OMAP24XX_SECU_VIOL_RST_SHIFT 3#define OMAP24XX_SECU_VIOL_RST_MASK (1 << 3)/* PM_WKEN_WKUP specific bits */
arch/arm/mach-omap2/prm-regbits-34xx.h +10 -0
@@ -509,15 +509,25 @@#define OMAP3430_RSTTIME1_MASK (0xff << 0)/* PRM_RSTST */ +#define OMAP3430_ICECRUSHER_RST_SHIFT 10#define OMAP3430_ICECRUSHER_RST_MASK (1 << 10) +#define OMAP3430_ICEPICK_RST_SHIFT 9#define OMAP3430_ICEPICK_RST_MASK (1 << 9) +#define OMAP3430_VDD2_VOLTAGE_MANAGER_RST_SHIFT 8#define OMAP3430_VDD2_VOLTAGE_MANAGER_RST_MASK (1 << 8) +#define OMAP3430_VDD1_VOLTAGE_MANAGER_RST_SHIFT 7#define OMAP3430_VDD1_VOLTAGE_MANAGER_RST_MASK (1 << 7) +#define OMAP3430_EXTERNAL_WARM_RST_SHIFT 6#define OMAP3430_EXTERNAL_WARM_RST_MASK (1 << 6) +#define OMAP3430_SECURE_WD_RST_SHIFT 5#define OMAP3430_SECURE_WD_RST_MASK (1 << 5) +#define OMAP3430_MPU_WD_RST_SHIFT 4#define OMAP3430_MPU_WD_RST_MASK (1 << 4) +#define OMAP3430_SECURITY_VIOL_RST_SHIFT 3#define OMAP3430_SECURITY_VIOL_RST_MASK (1 << 3) +#define OMAP3430_GLOBAL_SW_RST_SHIFT 1#define OMAP3430_GLOBAL_SW_RST_MASK (1 << 1) +#define OMAP3430_GLOBAL_COLD_RST_SHIFT 0#define OMAP3430_GLOBAL_COLD_RST_MASK (1 << 0)/* PRM_VOLTCTRL */
arch/arm/mach-omap2/prm.h +43 -1
59 lines not on this page · raw message
arch/arm/mach-omap2/prm2xxx.c +68 -0
77 lines not on this page · raw message
arch/arm/mach-omap2/prm2xxx.h +4 -0
@@ -123,6 +123,10 @@/* Function prototypes */ extern int omap2xxx_clkdm_sleep (struct clockdomain *clkdm);extern int omap2xxx_clkdm_wakeup (struct clockdomain *clkdm); + +extern int __init prm2xxx_init (void ); +extern int __exit prm2xxx_exit(void); +#endif #endif
arch/arm/mach-omap2/prm2xxx_3xxx.h +2 -0
@@ -211,7 +211,9 @@ extern int omap2_clkdm_clear_all_wkdeps(struct clockdomain *clkdm);* * 3430: RM_RSTST_CORE, RM_RSTST_EMU */ +#define OMAP_GLOBALWARM_RST_SHIFT 1#define OMAP_GLOBALWARM_RST_MASK (1 << 1) +#define OMAP_GLOBALCOLD_RST_SHIFT 0#define OMAP_GLOBALCOLD_RST_MASK (1 << 0)/*
arch/arm/mach-omap2/prm3xxx.c +65 -0
95 lines not on this page · raw message
arch/arm/mach-omap2/prm3xxx.h +2 -0
@@ -152,6 +152,8 @@ extern void omap3xxx_prm_ocp_barrier(void);extern void omap3xxx_prm_save_and_clear_irqen (u32 *saved_mask);extern void omap3xxx_prm_restore_irqen (u32 *saved_mask); +extern u32 omap3xxx_prm_get_reset_sources (void ); +#endif /* __ASSEMBLER */
arch/arm/mach-omap2/prm44xx.c +80 -3
119 lines not on this page · raw message
arch/arm/mach-omap2/prm44xx.h +2 -0
@@ -771,6 +771,8 @@ extern void omap44xx_prm_ocp_barrier(void);extern void omap44xx_prm_save_and_clear_irqen (u32 *saved_mask);extern void omap44xx_prm_restore_irqen (u32 *saved_mask); +extern u32 omap44xx_prm_get_reset_sources (void ); +# endif #endif
arch/arm/mach-omap2/prm_common.c +26 -0
@@ -28,6 +28,8 @@#include <plat/prcm.h> #include "prm2xxx_3xxx.h" +#include "prm2xxx.h" +#include "prm3xxx.h" #include "prm44xx.h" /*
@@ -327,6 +329,30 @@ err: }/** +* prm_read_reset_sources - return the sources of the SoC's last reset +* +* Return a u32 bitmask representing the reset sources that caused the +* SoC to reset. The low-level per-SoC functions called by this +* function remap the SoC-specific reset source bits into an +* OMAP-common set of reset source bits, defined in +* arch/arm/mach-omap2/prm.h. Returns the standardized reset source +* u32 bitmask from the hardware upon success, or returns (1 << +* OMAP_UNKNOWN_RST_SRC_ID_SHIFT) if no low-level read_reset_sources() +* function was registered. +*/ +u32 prm_read_reset_sources (void ) +{ +u32 ret =1 <<OMAP_UNKNOWN_RST_SRC_ID_SHIFT ; + +if (prm_ll_data->read_reset_sources) + ret = prm_ll_data->read_reset_sources (); +else +WARN_ONCE (1 ,"prm: %s: no mapping function defined for reset sources\n" , __func__); + +return ret; +} + +/** * prm_register - register per-SoC low-level data with the PRM * @pld: low-level per-SoC OMAP PRM data & function pointers to register *
Paul Walmsley
maintainerPATCH 5/7 ARM: OMAP2+: WDT: move init; add read_reset_sources pdata function pointer
In reply to Paul WalmsleyThe OMAP watchdog timer driver directly calls a function exported by code in arch/arm/mach-omap2. This is not good; it tightly couples this driver to the mach-omap2 integration code. Instead, add a temporary platform_data function pointer to abstract this function call. A subsequent patch will convert the watchdog driver to use this function pointer.
This patch also moves the device creation code out of arch/arm/mach-omap2/devices.c and into arch/arm/mach-omap2/wd_timer.c. This is another step towards the removal of arch/arm/mach-omap2/devices.c.
--- arch/arm/mach-omap1/devices.c | 21 +++++++++++++-- arch/arm/mach-omap2/devices.c | 26 ------------------ arch/arm/mach-omap2/wd_timer.c | 33 +++++++++++++++++++++++ include/linux/platform_data/omap-wd-timer.h | 38 +++++++++++++++++++++++++++ 4 files changed, 89 insertions(+), 29 deletions(-) create mode 100644 include/linux/platform_data/omap-wd-timer.h
arch/arm/mach-omap1/devices.c +18 -3
@@ -17,6 +17,8 @@#include <linux/platform_device.h> #include <linux/spi/spi.h> +#include <linux/platform_data/omap-wd-timer.h> +#include <asm/mach/map.h> #include <plat/tc.h>
@@ -439,18 +441,31 @@ static struct resource wdt_resources[] = { };static struct platform_device omap_wdt_device = { - .name ="omap_wdt" , - .id =-1 , + .name ="omap_wdt" , + .id =-1 , .num_resources =ARRAY_SIZE (wdt_resources), .resource = wdt_resources, };static int __init omap_init_wdt (void ) { +struct omap_wd_timer_platform_data pdata; +int ret; +if (!cpu_is_omap16xx ())return -ENODEV ; -return platform_device_register (&omap_wdt_device); + pdata.read_reset_sources = omap1_read_reset_sources; + + ret =platform_device_register (&omap_wdt_device); +if (!ret) { + ret =platform_device_add_data (&omap_wdt_device, &pdata, +sizeof (pdata)); +if (ret) +platform_device_del (&omap_wdt_device); + } + +return ret; }subsys_initcall (omap_init_wdt);#endif
arch/arm/mach-omap2/devices.c +0 -26
@@ -644,29 +644,3 @@ static int __init omap2_init_devices(void)return 0 ; }arch_initcall (omap2_init_devices); - -#if defined(CONFIG_OMAP_WATCHDOG ) || defined(CONFIG_OMAP_WATCHDOG_MODULE ) -static int __init omap_init_wdt (void ) -{ -int id =-1 ; -struct platform_device *pdev; -struct omap_hwmod *oh; -char *oh_name ="wd_timer2" ; -char *dev_name ="omap_wdt" ; - -if (!cpu_class_is_omap2 () ||of_have_populated_dt ()) -return 0 ; - - oh =omap_hwmod_lookup (oh_name); -if (!oh) { -pr_err ("Could not look up wd_timer%d hwmod\n" , id); -return -EINVAL ; - } - - pdev =omap_device_build (dev_name, id, oh,NULL ,0 ,NULL ,0 ,0 ); -WARN (IS_ERR (pdev),"Can't build omap_device for %s:%s.\n" , - dev_name, oh->name); -return 0 ; -} -subsys_initcall (omap_init_wdt); -#endif
arch/arm/mach-omap2/wd_timer.c +33 -0
@@ -11,10 +11,14 @@#include <linux/io.h> #include <linux/err.h> +#include <linux/platform_data/omap-wd-timer.h> +#include <plat/omap_hwmod.h> +#include <plat/omap_device.h> #include "wd_timer.h" #include "common.h" +#include "prm.h" /* * In order to avoid any assumptions from bootloader regarding WDT
@@ -99,3 +103,32 @@ int omap2_wd_timer_reset(struct omap_hwmod *oh)return (c ==MAX_MODULE_SOFTRESET_WAIT ) ? -ETIMEDOUT :omap2_wd_timer_disable (oh); } + +static int __init omap_init_wdt (void ) +{ +int id =-1 ; +struct platform_device *pdev; +struct omap_hwmod *oh; +char *oh_name ="wd_timer2" ; +char *dev_name ="omap_wdt" ; +struct omap_wd_timer_platform_data pdata; + +if (!cpu_class_is_omap2 ()) +return 0 ; + + oh =omap_hwmod_lookup (oh_name); +if (!oh) { +pr_err ("Could not look up wd_timer%d hwmod\n" , id); +return -EINVAL ; + } + + pdata.read_reset_sources = prm_read_reset_sources; + + pdev =omap_device_build (dev_name, id, oh, &pdata, +sizeof (struct omap_wd_timer_platform_data ), +NULL ,0 ,0 ); +WARN (IS_ERR (pdev),"Can't build omap_device for %s:%s.\n" , + dev_name, oh->name); +return 0 ; +} +subsys_initcall (omap_init_wdt);
include/linux/platform_data/omap-wd-timer.h new file +38 -0
@@ -0,0 +1,38 @@ +/* +* OMAP2+ WDTIMER-specific function prototypes +* +* Copyright (C) 2012 Texas Instruments, Inc. +* Paul Walmsley +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +*/ + +#ifndef __LINUX_PLATFORM_DATA_OMAP_WD_TIMER_H +#define __LINUX_PLATFORM_DATA_OMAP_WD_TIMER_H + +#include <linux/types.h> + +/* +* Standardized OMAP reset source bits +* +* This is a subset of the ones listed in arch/arm/mach-omap2/prm.h +* and are the only ones needed in the watchdog driver. +*/ +#define OMAP_MPU_WD_RST_SRC_ID_SHIFT 3 + +/** +* struct omap_wd_timer_platform_data - WDTIMER integration to the host SoC +* @read_reset_sources - fn ptr for the SoC to indicate the last reset cause +* +* The function pointed to by @read_reset_sources must return its data +* in a standard format - search for RST_SRC_ID_SHIFT in +* arch/arm/mach-omap2 +*/ +struct omap_wd_timer_platform_data { +u32 (*read_reset_sources)(void ); +}; + +#endif
Re: [PATCH 5/7] ARM: OMAP2+: WDT: move init; add read_reset_sources pdata function pointer
Hi Paul,
Quoted 7 lines
The OMAP watchdog timer driver directly calls a function exported by code in
arch/arm/mach-omap2. This is not good; it tightly couples this driver to the mach-omap2 integration code. Instead, add a temporaryplatform_datafunction pointer to abstract this function call. A subsequent patch will convert the watchdog driver to use this function pointer.
Quoted 7 lines
This patch also moves the device creation code out of
arch/arm/mach-omap2/devices.cand intoarch/arm/mach-omap2/wd_timer.c. This is another step towards the removal ofarch/arm/mach-omap2/devices.c.Signed-off-by Paul Walmsley <[email protected]>Cc Wim Van Sebroeck <[email protected]>
Kind regards,
Wim.
Aaro Koskinen
maintainerPATCH 5/7 ARM: OMAP2+: WDT: move init; add read_reset_sources pdata function pointer
In reply to Paul WalmsleyHi,
Quoted 6 lines · Paul Walmsley
The OMAP watchdog timer driver directly calls a function exported by code in
arch/arm/mach-omap2. This is not good; it tightly couples this driver to the mach-omap2 integration code. Instead, add a temporaryplatform_datafunction pointer to abstract this function call. A subsequent patch will convert the watchdog driver to use this function pointer.
Why a function is needed? Reset cause won't change until the next reset, so it should be enough to read it once during the init and store it into the platform data.
A.
Paul Walmsley
maintainerPATCH 5/7 ARM: OMAP2+: WDT: move init; add read_reset_sources pdata function pointer
Terve,
Quoted 11 lines · Aaro Koskinen
Quoted 6 lines · Paul Walmsley
The OMAP watchdog timer driver directly calls a function exported by code in
arch/arm/mach-omap2. This is not good; it tightly couples this driver to the mach-omap2 integration code. Instead, add a temporaryplatform_datafunction pointer to abstract this function call. A subsequent patch will convert the watchdog driver to use this function pointer.Why a function is needed? Reset cause won't change until the next reset, so it should be enough to read it once during the init and store it into the platform data.
Once the PRM/CM drivers and DT conversion is complete, this driver won't have any platform_data. There won't be any watchdog driver initialization code in arch/arm/mach-omap2. At that point in time, the driver will just call a function from the PRM driver that provides the reset source data.
As you say, the watchdog can certainly do this from its probe code; it would be more efficient. Just didn't want to make that change now; seems like it would be best done as a separate optimization patch.
- Paul
Tony Lindgren
maintainerPATCH 5/7 ARM: OMAP2+: WDT: move init; add read_reset_sources pdata function pointer
Quoted 16 lines · Paul Walmsley
Terve,
Quoted 11 lines · Aaro Koskinen
Quoted 6 lines · Paul Walmsley
The OMAP watchdog timer driver directly calls a function exported by code in
arch/arm/mach-omap2. This is not good; it tightly couples this driver to the mach-omap2 integration code. Instead, add a temporaryplatform_datafunction pointer to abstract this function call. A subsequent patch will convert the watchdog driver to use this function pointer.Why a function is needed? Reset cause won't change until the next reset, so it should be enough to read it once during the init and store it into the platform data.
Quoted 8 lines
Once the PRM/CM drivers and DT conversion is complete, this driver won't have any
platform_data. There won't be any watchdog driver initialization code inarch/arm/mach-omap2. At that point in time, the driver will just call a function from the PRM driver that provides the reset source data.As you say, the watchdog can certainly do this from its probe code; it would be more efficient. Just didn't want to make that change now; seems like it would be best done as a separate optimization patch.
Ideally we'd have some Linux generic function to implement in the PRM/CM drivers for getting the bootreason. But I guess we don't?
Regards,
Tony
Paul Walmsley
maintainerPATCH 5/7 ARM: OMAP2+: WDT: move init; add read_reset_sources pdata function pointer
Quoted 2 lines · Tony Lindgren
Ideally we'd have some Linux generic function to implement in the PRM/CM drivers for getting the bootreason. But I guess we don't?
Do you know of one, apart from WDIOC_GETBOOTSTATUS?
- Paul
Tony Lindgren
maintainerPATCH 5/7 ARM: OMAP2+: WDT: move init; add read_reset_sources pdata function pointer
Quoted 6 lines · Paul Walmsley
Quoted 2 lines · Tony Lindgren
Ideally we'd have some Linux generic function to implement in the PRM/CM drivers for getting the bootreason. But I guess we don't?
Do you know of one, apart from
WDIOC_GETBOOTSTATUS?
I wonder if we can now with multiple watchdogs supported to have also PRM/CM implement omap_prcm_wdt_ioctl() that just handles WDIOC_GETBOOTSTATUS and then just remove that handling from the other omap watchdog drivers?
Regards,
Tony
Paul Walmsley
maintainerPATCH 5/7 ARM: OMAP2+: WDT: move init; add read_reset_sources pdata function pointer
Quoted 4 lines · Tony Lindgren
I wonder if we can now with multiple watchdogs supported to have also PRM/CM implement
omap_prcm_wdt_ioctl()that just handlesWDIOC_GETBOOTSTATUSand then just remove that handling from the other omap watchdog drivers?
The watchdog ioctl code needs access to internal watchdog state and functions, for example WDIOC_KEEPALIVE and WDIOC_SETTIMEOUT. How would the approach you're thinking of implement those operations?
- Paul
Tony Lindgren
maintainerPATCH 5/7 ARM: OMAP2+: WDT: move init; add read_reset_sources pdata function pointer
Quoted 10 lines · Paul Walmsley
Quoted 4 lines · Tony Lindgren
I wonder if we can now with multiple watchdogs supported to have also PRM/CM implement
omap_prcm_wdt_ioctl()that just handlesWDIOC_GETBOOTSTATUSand then just remove that handling from the other omap watchdog drivers?The watchdog ioctl code needs access to internal watchdog state and functions, for example
WDIOC_KEEPALIVEandWDIOC_SETTIMEOUT. How would the approach you're thinking of implement those operations?
I have not looked how the watchdog subsystem handles multiple watchdogs, but.. Can't we have the omap watchdog and twl watchdog return -ENOTSUPP for WDIOC_GETBOOTSTATUS and have the watchdog core fail over to the third wathcdog omap_prcm_wdt_ioctl() that only implements WDIOC_GETBOOTSTATUS? Or something like that.
Regards,
Tony
Tony Lindgren
maintainerPATCH 5/7 ARM: OMAP2+: WDT: move init; add read_reset_sources pdata function pointer
Quoted 12 lines · Tony Lindgren
Quoted 10 lines · Paul Walmsley
Quoted 4 lines · Tony Lindgren
I wonder if we can now with multiple watchdogs supported to have also PRM/CM implement
omap_prcm_wdt_ioctl()that just handlesWDIOC_GETBOOTSTATUSand then just remove that handling from the other omap watchdog drivers?The watchdog ioctl code needs access to internal watchdog state and functions, for example
WDIOC_KEEPALIVEandWDIOC_SETTIMEOUT. How would the approach you're thinking of implement those operations?
Quoted 5 lines
I have not looked how the watchdog subsystem handles multiple watchdogs, but.. Can't we have the omap watchdog and twl watchdog return
-ENOTSUPPforWDIOC_GETBOOTSTATUSand have the watchdog core fail over to the third wathcdogomap_prcm_wdt_ioctl()that only implementsWDIOC_GETBOOTSTATUS? Or something like that.
After poking around a bit, probably the way to do this would be to have watchdog core bootstatus in addition to the bootstatus in struct watchdog_device?
Then the omap_prcm watchdog could just initialize the watchdog core bootstatus, and the other omap watchdog drivers would just return the watchdog core bootstatus.
Not that it's related to this patchset, just trying to figure out how it could be done in a generic way :)
Regards,
Tony
Paul Walmsley
maintainerPATCH 5/7 ARM: OMAP2+: WDT: move init; add read_reset_sources pdata function pointer
In reply to Tony LindgrenQuoted 2 lines · Tony Lindgren
I have not looked how the watchdog subsystem handles multiple watchdogs, but..
In the new watchdog core code, each watchdog driver gets a separate /dev/watchdog* character device. The ioctls are called on those device nodes.
[ As an aside, neither the OMAP watchdog driver, nor the TWL watchdog driver have been updated to use the new watchdog core code. So they both can't be loaded at the same time until one or both are fixed. ]
Quoted 4 lines
Can't we have the omap watchdog and twl watchdog return
-ENOTSUPPforWDIOC_GETBOOTSTATUSand have the watchdog core fail over to the third wathcdogomap_prcm_wdt_ioctl()that only implementsWDIOC_GETBOOTSTATUS? Or something like that.
Sounds like a question better asked of Alan Cox and Wim, who wrote the watchdog core code.
Two other observations:
- It's possible that two different watchdogs could report different boot reasons. The TWL might store its own watchdog boot reason which could be different from what's reported via the OMAP PRM. For example, the TWL can record a thermal shutdown reset event, STS_BOOT.TS, which wouldn't be reflected in the PRM reset source data, which would just see some kind of external reset or power-off event.
- The PRM doesn't contain a hardware watchdog, so not sure it makes sense to create a watchdog driver for it.
- Paul
Aaro Koskinen
maintainerPATCH 5/7 ARM: OMAP2+: WDT: move init; add read_reset_sources pdata function pointer
Hi,
Quoted 3 lines · Paul Walmsley
[ As an aside, neither the OMAP watchdog driver, nor the TWL watchdog driver have been updated to use the new watchdog core code. So they both can't be loaded at the same time until one or both are fixed. ]
FYI, this is being done currently:
- OMAP wdt: https://lkml.org/lkml/2012/10/10/402
- TWL wdt: http://marc.info/?l=linux-omap&m=134734329319385&w=2
A.
Paul Walmsley
maintainerPATCH 5/7 ARM: OMAP2+: WDT: move init; add read_reset_sources pdata function pointer
Quoted 9 lines · Aaro Koskinen
Quoted 3 lines · Paul Walmsley
[ As an aside, neither the OMAP watchdog driver, nor the TWL watchdog driver have been updated to use the new watchdog core code. So they both can't be loaded at the same time until one or both are fixed. ]
FYI, this is being done currently:
- OMAP wdt: https://lkml.org/lkml/2012/10/10/402
- TWL wdt: http://marc.info/?l=linux-omap&m=134734329319385&w=2
Thanks, that's good news.
- Paul
Paul Walmsley
maintainerPATCH 5/7 ARM: OMAP2+: WDT: move init; add read_reset_sources pdata function pointer
In reply to Paul WalmsleyQuoted 7 lines · Paul Walmsley
The OMAP watchdog timer driver directly calls a function exported by code in
arch/arm/mach-omap2. This is not good; it tightly couples this driver to the mach-omap2 integration code. Instead, add a temporaryplatform_datafunction pointer to abstract this function call. A subsequent patch will convert the watchdog driver to use this function pointer.
Quoted 7 lines
This patch also moves the device creation code out of
arch/arm/mach-omap2/devices.cand intoarch/arm/mach-omap2/wd_timer.c. This is another step towards the removal ofarch/arm/mach-omap2/devices.c.Signed-off-by Paul Walmsley <[email protected]>Cc Wim Van Sebroeck <[email protected]>
This patch missed the change from commit 6e152231995aa4ed5eafd87a6a8348563248f843 ("ARM: OMAP: avoid build wdt platform device if with dt support") to skip the mach-omap2/ device build if the DT blob was present. This resulted in the watchdog getting probed twice. This didn't result in any problems, aside from a message in the kernel log.
Anyway, here's an update with that change added.
- Paul
From: Paul Walmsley <[email protected]>
Date: Mon, 29 Oct 2012 20:49:44 -0600
Subject: [PATCH] ARM: OMAP2+: WDT: move init; add read_reset_sources pdata
function pointer
The OMAP watchdog timer driver directly calls a function exported by code in arch/arm/mach-omap2. This is not good; it tightly couples this driver to the mach-omap2 integration code. Instead, add a temporary platform_data function pointer to abstract this function call. A subsequent patch will convert the watchdog driver to use this function pointer.
This patch also moves the device creation code out of arch/arm/mach-omap2/devices.c and into arch/arm/mach-omap2/wd_timer.c. This is another step towards the removal of arch/arm/mach-omap2/devices.c.
--- arch/arm/mach-omap1/devices.c | 21 ++++++++++++--- arch/arm/mach-omap2/devices.c | 26 ------------------ arch/arm/mach-omap2/wd_timer.c | 35 +++++++++++++++++++++++- include/linux/platform_data/omap-wd-timer.h | 38 +++++++++++++++++++++++++++ 4 files changed, 90 insertions(+), 30 deletions(-) create mode 100644 include/linux/platform_data/omap-wd-timer.h
arch/arm/mach-omap1/devices.c +18 -3
@@ -17,6 +17,8 @@#include <linux/platform_device.h> #include <linux/spi/spi.h> +#include <linux/platform_data/omap-wd-timer.h> +#include <asm/mach/map.h> #include <mach/tc.h>
@@ -448,18 +450,31 @@ static struct resource wdt_resources[] = { };static struct platform_device omap_wdt_device = { - .name ="omap_wdt" , - .id =-1 , + .name ="omap_wdt" , + .id =-1 , .num_resources =ARRAY_SIZE (wdt_resources), .resource = wdt_resources, };static int __init omap_init_wdt (void ) { +struct omap_wd_timer_platform_data pdata; +int ret; +if (!cpu_is_omap16xx ())return -ENODEV ; -return platform_device_register (&omap_wdt_device); + pdata.read_reset_sources = omap1_get_reset_sources; + + ret =platform_device_register (&omap_wdt_device); +if (!ret) { + ret =platform_device_add_data (&omap_wdt_device, &pdata, +sizeof (pdata)); +if (ret) +platform_device_del (&omap_wdt_device); + } + +return ret; }subsys_initcall (omap_init_wdt);#endif
arch/arm/mach-omap2/devices.c +0 -26
@@ -646,29 +646,3 @@ static int __init omap2_init_devices(void)return 0 ; }arch_initcall (omap2_init_devices); - -#if defined(CONFIG_OMAP_WATCHDOG ) || defined(CONFIG_OMAP_WATCHDOG_MODULE ) -static int __init omap_init_wdt (void ) -{ -int id =-1 ; -struct platform_device *pdev; -struct omap_hwmod *oh; -char *oh_name ="wd_timer2" ; -char *dev_name ="omap_wdt" ; - -if (!cpu_class_is_omap2 () ||of_have_populated_dt ()) -return 0 ; - - oh =omap_hwmod_lookup (oh_name); -if (!oh) { -pr_err ("Could not look up wd_timer%d hwmod\n" , id); -return -EINVAL ; - } - - pdev =omap_device_build (dev_name, id, oh,NULL ,0 ,NULL ,0 ,0 ); -WARN (IS_ERR (pdev),"Can't build omap_device for %s:%s.\n" , - dev_name, oh->name); -return 0 ; -} -subsys_initcall (omap_init_wdt); -#endif
arch/arm/mach-omap2/wd_timer.c +34 -1
@@ -11,10 +11,14 @@#include <linux/io.h> #include <linux/err.h> -#include "omap_hwmod.h" +#include <linux/platform_data/omap-wd-timer.h> +#include "omap_hwmod.h" +#include "omap_device.h" #include "wd_timer.h" #include "common.h" +#include "prm.h" +#include "soc.h" /* * In order to avoid any assumptions from bootloader regarding WDT
@@ -99,3 +103,32 @@ int omap2_wd_timer_reset(struct omap_hwmod *oh)return (c ==MAX_MODULE_SOFTRESET_WAIT ) ? -ETIMEDOUT :omap2_wd_timer_disable (oh); } + +static int __init omap_init_wdt (void ) +{ +int id =-1 ; +struct platform_device *pdev; +struct omap_hwmod *oh; +char *oh_name ="wd_timer2" ; +char *dev_name ="omap_wdt" ; +struct omap_wd_timer_platform_data pdata; + +if (!cpu_class_is_omap2 () ||of_have_populated_dt ()) +return 0 ; + + oh =omap_hwmod_lookup (oh_name); +if (!oh) { +pr_err ("Could not look up wd_timer%d hwmod\n" , id); +return -EINVAL ; + } + + pdata.read_reset_sources = prm_read_reset_sources; + + pdev =omap_device_build (dev_name, id, oh, &pdata, +sizeof (struct omap_wd_timer_platform_data ), +NULL ,0 ,0 ); +WARN (IS_ERR (pdev),"Can't build omap_device for %s:%s.\n" , + dev_name, oh->name); +return 0 ; +} +subsys_initcall (omap_init_wdt);
include/linux/platform_data/omap-wd-timer.h new file +38 -0
@@ -0,0 +1,38 @@ +/* +* OMAP2+ WDTIMER-specific function prototypes +* +* Copyright (C) 2012 Texas Instruments, Inc. +* Paul Walmsley +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +*/ + +#ifndef __LINUX_PLATFORM_DATA_OMAP_WD_TIMER_H +#define __LINUX_PLATFORM_DATA_OMAP_WD_TIMER_H + +#include <linux/types.h> + +/* +* Standardized OMAP reset source bits +* +* This is a subset of the ones listed in arch/arm/mach-omap2/prm.h +* and are the only ones needed in the watchdog driver. +*/ +#define OMAP_MPU_WD_RST_SRC_ID_SHIFT 3 + +/** +* struct omap_wd_timer_platform_data - WDTIMER integration to the host SoC +* @read_reset_sources - fn ptr for the SoC to indicate the last reset cause +* +* The function pointed to by @read_reset_sources must return its data +* in a standard format - search for RST_SRC_ID_SHIFT in +* arch/arm/mach-omap2 +*/ +struct omap_wd_timer_platform_data { +u32 (*read_reset_sources)(void ); +}; + +#endif
Signature · 1 line
1.7.10.4
Paul Walmsley
maintainerPATCH 6/7 watchdog: OMAP: use standard GETBOOTSTATUS interface; use platform_data fn ptr
In reply to Paul WalmsleyPreviously the OMAP watchdog driver used a non-standard way to report the chip reset source via the GETBOOTSTATUS ioctl. This patch converts the driver to use the standard WDIOF_* flags for this purpose.
This patch may break existing userspace code that uses the existing non-standard data format returned by the OMAP watchdog driver's GETBOOTSTATUS ioctl. To fetch detailed reset source information, userspace code will need to retrieve it directly from the CGRM or PRM drivers when those are completed.
Previously, to fetch the reset source, the driver either read a register outside the watchdog IP block (OMAP1), or called a function exported directly from arch/arm/mach-omap2. Both approaches are broken. This patch also converts the driver to use a platform_data function pointer. This approach is temporary, and is due to the lack of drivers for the OMAP16xx+ Clock Generation and Reset Management IP block and the OMAP2+ Power and Reset Management IP block. Once drivers are available for those IP blocks, the watchdog driver can be converted to call exported drivers from those functions directly. At that point, the platform_data function pointer can be removed.
In the short term, this patch is needed to allow the PRM code to be removed from arch/arm/mach-omap2 (it is being moved to a driver).
--- drivers/watchdog/omap_wdt.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-)
drivers/watchdog/omap_wdt.c +12 -14
@@ -46,8 +46,8 @@#include <linux/slab.h> #include <linux/pm_runtime.h> #include <mach/hardware.h> -#include <plat/cpu.h> -#include <plat/prcm.h> + +#include <linux/platform_data/omap-wd-timer.h> #include "omap_wdt.h"
@@ -202,8 +202,10 @@ static ssize_t omap_wdt_write(struct file *file, const char __user *data,static long omap_wdt_ioctl (struct file *file,unsigned int cmd,unsigned long arg) { +struct omap_wd_timer_platform_data *pdata;struct omap_wdt_dev *wdev; -int new_margin; +u32 rs; +int new_margin, bs;static const struct watchdog_info ident = { .identity ="OMAP Watchdog" , .options =WDIOF_SETTIMEOUT ,
@@ -211,6 +213,7 @@ static long omap_wdt_ioctl(struct file *file, unsigned int cmd, }; wdev = file->private_data; + pdata = wdev->dev->platform_data;switch (cmd) {case WDIOC_GETSUPPORT :
@@ -219,17 +222,12 @@ static long omap_wdt_ioctl(struct file *file, unsigned int cmd,case WDIOC_GETSTATUS :return put_user (0 , (int __user *)arg);case WDIOC_GETBOOTSTATUS : -#ifdef CONFIG_ARCH_OMAP1 -if (cpu_is_omap16xx ()) -return put_user (__raw_readw (ARM_SYSST ), - (int __user *)arg); -#endif -#ifdef CONFIG_ARCH_OMAP2PLUS -if (cpu_is_omap24xx ()) -return put_user (omap_prcm_get_reset_sources (), - (int __user *)arg); -#endif -return put_user (0 , (int __user *)arg); +if (!pdata->read_reset_sources) +return put_user (0 , (int __user *)arg); + rs = pdata->read_reset_sources (); + bs = (rs & (1 <<OMAP_MPU_WD_RST_SRC_ID_SHIFT )) ? +WDIOF_CARDRESET :0 ; +return put_user (bs, (int __user *)arg);case WDIOC_KEEPALIVE :spin_lock (&wdt_lock);omap_wdt_ping (wdev);
Re: [PATCH 6/7] watchdog: OMAP: use standard GETBOOTSTATUS interface; use platform_data fn ptr
Hi Paul,
Quoted 22 lines
Previously the OMAP watchdog driver used a non-standard way to report the chip reset source via the GETBOOTSTATUS ioctl. This patch converts the driver to use the standard WDIOF_* flags for this purpose.
This patch may break existing userspace code that uses the existing non-standard data format returned by the OMAP watchdog driver's GETBOOTSTATUS ioctl. To fetch detailed reset source information, userspace code will need to retrieve it directly from the CGRM or PRM drivers when those are completed.
Previously, to fetch the reset source, the driver either read a register outside the watchdog IP block (OMAP1), or called a function exported directly from
arch/arm/mach-omap2. Both approaches are broken. This patch also converts the driver to use aplatform_datafunction pointer. This approach is temporary, and is due to the lack of drivers for the OMAP16xx+ Clock Generation and Reset Management IP block and the OMAP2+ Power and Reset Management IP block. Once drivers are available for those IP blocks, the watchdog driver can be converted to call exported drivers from those functions directly. At that point, theplatform_datafunction pointer can be removed.
Quoted 5 lines
In the short term, this patch is needed to allow the PRM code to be removed from
arch/arm/mach-omap2(it is being moved to a driver).Signed-off-by Paul Walmsley <[email protected]>Cc Wim Van Sebroeck <[email protected]>
Kind regards,
Wim.
PATCH 6/7 watchdog: OMAP: use standard GETBOOTSTATUS interface; use platform_data fn ptr
In reply to Paul WalmsleyHi Paul,
Quoted 73 lines · Paul Walmsley
Previously the OMAP watchdog driver used a non-standard way to report the chip reset source via the GETBOOTSTATUS ioctl. This patch converts the driver to use the standard WDIOF_* flags for this purpose.
This patch may break existing userspace code that uses the existing non-standard data format returned by the OMAP watchdog driver's GETBOOTSTATUS ioctl. To fetch detailed reset source information, userspace code will need to retrieve it directly from the CGRM or PRM drivers when those are completed.
Previously, to fetch the reset source, the driver either read a register outside the watchdog IP block (OMAP1), or called a function exported directly from
arch/arm/mach-omap2. Both approaches are broken. This patch also converts the driver to use aplatform_datafunction pointer. This approach is temporary, and is due to the lack of drivers for the OMAP16xx+ Clock Generation and Reset Management IP block and the OMAP2+ Power and Reset Management IP block. Once drivers are available for those IP blocks, the watchdog driver can be converted to call exported drivers from those functions directly. At that point, theplatform_datafunction pointer can be removed.In the short term, this patch is needed to allow the PRM code to be removed from
arch/arm/mach-omap2(it is being moved to a driver).Signed-off-by Paul Walmsley <[email protected]>Cc Wim Van Sebroeck <[email protected]>--- drivers/watchdog/omap_wdt.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-)drivers/watchdog/omap_wdt.c +6
-6@@ -46,8 +46,8 @@#include <linux/slab.h> #include <linux/pm_runtime.h> #include <mach/hardware.h> -#include <plat/cpu.h> -#include <plat/prcm.h> + +#include <linux/platform_data/omap-wd-timer.h> #include "omap_wdt.h" @@ -202,8 +202,10 @@ static ssize_t omap_wdt_write(struct file *file, const char __user *data,static long omap_wdt_ioctl (struct file *file,unsigned int cmd,unsigned long arg) { +struct omap_wd_timer_platform_data *pdata;struct omap_wdt_dev *wdev; -int new_margin; +u32 rs; +int new_margin, bs;static const struct watchdog_info ident = { .identity ="OMAP Watchdog" , .options =WDIOF_SETTIMEOUT ,@@ -211,6 +213,7 @@ static long omap_wdt_ioctl(struct file *file, unsigned int cmd, }; wdev = file->private_data; + pdata = wdev->dev->platform_data;switch (cmd) {case WDIOC_GETSUPPORT :@@ -219,17 +222,12 @@ static long omap_wdt_ioctl(struct file *file, unsigned int cmd,case WDIOC_GETSTATUS :return put_user (0 , (int __user *)arg);case WDIOC_GETBOOTSTATUS : -#ifdef CONFIG_ARCH_OMAP1 -if (cpu_is_omap16xx ()) - return put_user(__raw_readw(ARM_SYSST),
drivers/watchdog/omap_wdt.c static long omap_wdt_ioctl(struct file *file, unsigned int cmd, · line 226
Quoted 10 lines
drivers/watchdog/omap_wdt.c +2
-8- (int __user *)arg); -#endif -#ifdef CONFIG_ARCH_OMAP2PLUS -if (cpu_is_omap24xx ()) -return put_user (omap_prcm_get_reset_sources (), - (int __user *)arg); -#endif -return put_user (0 , (int __user *)arg); +if (!pdata->read_reset_sources) +return put_user (0 , (int __user *)arg);
In the case of booting with device-tree, pdata could be null and so should we check for this too? In other words ...
+ if (!pdata || !pdata->read_reset_sources)
+ return put_user(0, (int __user *)arg);
Cheers
Jon
Paul Walmsley
maintainerPATCH 6/7 watchdog: OMAP: use standard GETBOOTSTATUS interface; use platform_data fn ptr
Review
Quoted 8 lines · Jon Hunter
drivers/watchdog/omap_wdt.c static long omap_wdt_ioctl(struct file *file, unsigned int cmd, · line 226
Quoted 2 lines
drivers/watchdog/omap_wdt.c +2
-0+if (!pdata->read_reset_sources) +return put_user (0 , (int __user *)arg);In the case of booting with device-tree, pdata could be null and so should we check for this too? In other words ...
(quoted diff) +2
-0+ if (!pdata || !pdata->read_reset_sources) + return put_user(0, (int __user *)arg);
Thanks, good catch, will integrate that fix.
- Paul
Paul Walmsley
maintainerPATCH 6/7 watchdog: OMAP: use standard GETBOOTSTATUS interface; use platform_data fn ptr
Quoted 9 lines · Paul Walmsley
Review
Quoted 5 lines · Jon Hunter
In the case of booting with device-tree, pdata could be null and so should we check for this too? In other words ...
(quoted diff) +2
-0+ if (!pdata || !pdata->read_reset_sources) + return put_user(0, (int __user *)arg);Thanks, good catch, will integrate that fix.
Here's the updated patch.
- Paul
From: Paul Walmsley <[email protected]>
Date: Sun, 7 Oct 2012 20:13:26 -0600
Subject: [PATCH] watchdog: OMAP: use standard GETBOOTSTATUS interface; use
platform_data fn ptr
Previously the OMAP watchdog driver used a non-standard way to report the chip reset source via the GETBOOTSTATUS ioctl. This patch converts the driver to use the standard WDIOF_* flags for this purpose.
This patch may break existing userspace code that uses the existing non-standard data format returned by the OMAP watchdog driver's GETBOOTSTATUS ioctl. To fetch detailed reset source information, userspace code will need to retrieve it directly from the CGRM or PRM drivers when those are completed.
Previously, to fetch the reset source, the driver either read a register outside the watchdog IP block (OMAP1), or called a function exported directly from arch/arm/mach-omap2. Both approaches are broken. This patch also converts the driver to use a platform_data function pointer. This approach is temporary, and is due to the lack of drivers for the OMAP16xx+ Clock Generation and Reset Management IP block and the OMAP2+ Power and Reset Management IP block. Once drivers are available for those IP blocks, the watchdog driver can be converted to call exported drivers from those functions directly. At that point, the platform_data function pointer can be removed.
In the short term, this patch is needed to allow the PRM code to be removed from arch/arm/mach-omap2 (it is being moved to a driver).
This version integrates a fix from Jon Hunter <[email protected]> that avoids a NULL pointer dereference in a DT-only boot.
--- drivers/watchdog/omap_wdt.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-)
drivers/watchdog/omap_wdt.c +12 -14
@@ -46,8 +46,8 @@#include <linux/slab.h> #include <linux/pm_runtime.h> #include <mach/hardware.h> -#include <plat/cpu.h> -#include <plat/prcm.h> + +#include <linux/platform_data/omap-wd-timer.h> #include "omap_wdt.h"
@@ -202,8 +202,10 @@ static ssize_t omap_wdt_write(struct file *file, const char __user *data,static long omap_wdt_ioctl (struct file *file,unsigned int cmd,unsigned long arg) { +struct omap_wd_timer_platform_data *pdata;struct omap_wdt_dev *wdev; -int new_margin; +u32 rs; +int new_margin, bs;static const struct watchdog_info ident = { .identity ="OMAP Watchdog" , .options =WDIOF_SETTIMEOUT ,
@@ -211,6 +213,7 @@ static long omap_wdt_ioctl(struct file *file, unsigned int cmd, }; wdev = file->private_data; + pdata = wdev->dev->platform_data;switch (cmd) {case WDIOC_GETSUPPORT :
@@ -219,17 +222,12 @@ static long omap_wdt_ioctl(struct file *file, unsigned int cmd,case WDIOC_GETSTATUS :return put_user (0 , (int __user *)arg);case WDIOC_GETBOOTSTATUS : -#ifdef CONFIG_ARCH_OMAP1 -if (cpu_is_omap16xx ()) -return put_user (__raw_readw (ARM_SYSST ), - (int __user *)arg); -#endif -#ifdef CONFIG_ARCH_OMAP2PLUS -if (cpu_is_omap24xx ()) -return put_user (omap_prcm_get_reset_sources (), - (int __user *)arg); -#endif -return put_user (0 , (int __user *)arg); +if (!pdata || !pdata->read_reset_sources) +return put_user (0 , (int __user *)arg); + rs = pdata->read_reset_sources (); + bs = (rs & (1 <<OMAP_MPU_WD_RST_SRC_ID_SHIFT )) ? +WDIOF_CARDRESET :0 ; +return put_user (bs, (int __user *)arg);case WDIOC_KEEPALIVE :spin_lock (&wdt_lock);omap_wdt_ping (wdev);
Signature · 1 line
1.7.10.4
PATCH 6/7 watchdog: OMAP: use standard GETBOOTSTATUS interface; use platform_data fn ptr
Quoted 32 lines · Paul Walmsley
Quoted 9 lines · Paul Walmsley
drivers/watchdog/omap_wdt.c static long omap_wdt_ioctl(struct file *file, unsigned int cmd, · line 226
Quoted 5 lines · Jon Hunter
In the case of booting with device-tree, pdata could be null and so should we check for this too? In other words ...
drivers/watchdog/omap_wdt.c +2
-0+if (!pdata || !pdata->read_reset_sources) +return put_user (0 , (int __user *)arg);Thanks, good catch, will integrate that fix.
Here's the updated patch.
- Paul
From: Paul Walmsley <[email protected]>
Date: Sun, 7 Oct 2012 20:13:26 -0600
Subject: [PATCH] watchdog: OMAP: use standard GETBOOTSTATUS interface; use
platform_datafn ptrPreviously the OMAP watchdog driver used a non-standard way to report the chip reset source via the GETBOOTSTATUS ioctl. This patch converts the driver to use the standard WDIOF_* flags for this purpose.
This patch may break existing userspace code that uses the existing non-standard data format returned by the OMAP watchdog driver's GETBOOTSTATUS ioctl. To fetch detailed reset source information, userspace code will need to retrieve it directly from the CGRM or PRM drivers when those are completed.
Quoted 9 lines
Previously, to fetch the reset source, the driver either read a register outside the watchdog IP block (OMAP1), or called a function exported directly from
arch/arm/mach-omap2. Both approaches are broken. This patch also converts the driver to use aplatform_datafunction pointer. This approach is temporary, and is due to the lack of drivers for the OMAP16xx+ Clock Generation and Reset Management IP block and the OMAP2+ Power and Reset Management IP block. Once drivers are available for those IP blocks, the watchdog driver can be converted to call exported drivers from those functions directly.
should be "exported functions from those drivers directly."
Signature · 8 lines
balbi -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20121025/83e5922c/attachment-0001.sig>
Paul Walmsley
maintainerPATCH 6/7 watchdog: OMAP: use standard GETBOOTSTATUS interface; use platform_data fn ptr
Quoted 1 line · Felipe Balbi
should be "exported functions from those drivers directly."
Thanks, will update the patch description.
- Paul
Paul Walmsley
maintainerPATCH 7/7 ARM: OMAP2+: PRCM: remove omap_prcm_get_reset_sources()
In reply to Paul Walmsleyomap_prcm_get_reset_sources() is now unused; so, remove it.
--- arch/arm/mach-omap2/prcm.c | 12 ------------ arch/arm/plat-omap/include/plat/prcm.h | 1 - 2 files changed, 13 deletions(-)
arch/arm/mach-omap2/prcm.c +0 -12
@@ -46,18 +46,6 @@ void __iomem *prcm_mpu_base;#define MAX_MODULE_ENABLE_WAIT 100000 -u32 omap_prcm_get_reset_sources (void ) -{ -/* XXX This presumably needs modification for 34XX */ -if (cpu_is_omap24xx () ||cpu_is_omap34xx ()) -return omap2_prm_read_mod_reg (WKUP_MOD ,OMAP2_RM_RSTST ) &0x7f ; -if (cpu_is_omap44xx ()) -return omap2_prm_read_mod_reg (WKUP_MOD ,OMAP4_RM_RSTST ) &0x7f ; - -return 0 ; -} -EXPORT_SYMBOL (omap_prcm_get_reset_sources); -/* Resets clock rates and reboots the system. Only called from system.h */ void omap_prcm_restart (char mode,const char *cmd) {
arch/arm/plat-omap/include/plat/prcm.h +0 -1
@@ -27,7 +27,6 @@#ifndef __ASM_ARM_ARCH_OMAP_PRCM_H#define __ASM_ARM_ARCH_OMAP_PRCM_H -u32 omap_prcm_get_reset_sources (void );int omap2_cm_wait_idlest (void __iomem *reg,u32 mask,u8 idlest,const char *name);
cover ARM: OMAP: second set of PRM/CM/CGRM cleanup patches for 3.8
In reply to Paul WalmsleyHi Paul,
What is CGRM? Is it a typo?
Regards,
Benoit
Quoted 70 lines · Paul Walmsley
This series removes the
omap_prcm_get_reset_sources()function. This was exported fromarch/arm/mach-omap2/prcm.cfor use by the OMAP watchdog driver to report the "boot reason". This series reimplements this using aplatform_datafunction pointer for the time being, but after the upcoming PRM/CM drivers are merged, the watchdog driver can be patched to use an exported function from the drivers.This series will also be used as a base for other PRM/CM cleanup during the 3.8 time frame, since it adds the
prm_register()andprm_unregister()functions. These are called by SoC-specific PRM IP block drivers to register function pointers with the PRM subsystem.This series changes the format of the watchdog's boot reason data to conform with the watchdog subsystem standard (the WDIOF_* flags). If users need more detail than that interface provides, either the watchdog interface can be patched, or those users can get that information from the upcoming PRM drivers.
- Paul
---
prcm_cleanup_b_3.8
text data bss dec hex filename
7519295 696796 5613996 13830087 d307c7 vmlinux.omap2plus_defconfig.orig
7520203 696868 5613996 13831067 d30b9b vmlinux.omap2plus_defconfigPaul Walmsley (7):
ARM: OMAP2+: PRM: prepare for use ofprm_ll_datafunction pointers
ARM: OMAP2+: CM: prepare for use ofcm_ll_datafunction pointers
ARM: OMAP1: createread_reset_sources()function (for initial use by watchdog)
ARM: OMAP2+: PRM: create PRM reset source API for the watchdog timer driver
ARM: OMAP2+: WDT: move init; addread_reset_sourcespdata function pointer
watchdog: OMAP: use standard GETBOOTSTATUS interface; useplatform_datafn ptr
ARM: OMAP2+: PRCM: removeomap_prcm_get_reset_sources()arch/arm/mach-omap1/common.h | 2 + arch/arm/mach-omap1/devices.c | 21 ++++++- arch/arm/mach-omap1/reset.c | 39 +++++++++++++ arch/arm/mach-omap2/Makefile | 2 - arch/arm/mach-omap2/cm.h | 12 ++++ arch/arm/mach-omap2/cm_common.c | 71 +++++++++++++++++++++++ arch/arm/mach-omap2/devices.c | 26 -------- arch/arm/mach-omap2/prcm.c | 12 ---- arch/arm/mach-omap2/prm-regbits-24xx.h | 4 + arch/arm/mach-omap2/prm-regbits-34xx.h | 10 +++ arch/arm/mach-omap2/prm.h | 53 +++++++++++++++++ arch/arm/mach-omap2/prm2xxx.c | 68 ++++++++++++++++++++++ arch/arm/mach-omap2/prm2xxx.h | 4 + arch/arm/mach-omap2/prm2xxx_3xxx.h | 2 + arch/arm/mach-omap2/prm3xxx.c | 65 +++++++++++++++++++++ arch/arm/mach-omap2/prm3xxx.h | 2 + arch/arm/mach-omap2/prm44xx.c | 83 ++++++++++++++++++++++++++- arch/arm/mach-omap2/prm44xx.h | 2 + arch/arm/mach-omap2/prm_common.c | 78 +++++++++++++++++++++++++ arch/arm/mach-omap2/wd_timer.c | 33 +++++++++++ arch/arm/plat-omap/include/plat/prcm.h | 1 drivers/watchdog/omap_wdt.c | 26 ++++---- include/linux/platform_data/omap-wd-timer.h | 38 ++++++++++++ 23 files changed, 594 insertions(+), 60 deletions(-) create mode 100644 arch/arm/mach-omap2/cm_common.c create mode 100644 include/linux/platform_data/omap-wd-timer.h--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Paul Walmsley
maintainercover ARM: OMAP: second set of PRM/CM/CGRM cleanup patches for 3.8
Quoted 1 line · Benoit Cousson
What is CGRM? Is it a typo?
That's the OMAP1 Clock Generation and Reset Module that contains the ARM_SYSST register:
http://www.ti.com/lit/ug/spru678a/spru678a.pdf
- Paul
cover ARM: OMAP: second set of PRM/CM/CGRM cleanup patches for 3.8
Quoted 6 lines · Paul Walmsley
Quoted 1 line · Benoit Cousson
What is CGRM? Is it a typo?
That's the OMAP1 Clock Generation and Reset Module that contains the
ARM_SYSSTregister:
Outch, that's pretty old stuff. Thanks for the clarification.
Regards,
Benoit