From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chin Liang See Date: Tue, 4 Mar 2014 17:45:31 -0600 Subject: [U-Boot] [PATCH v4 1/2] watchdog/denali: Adding DesignWare watchdog driver support In-Reply-To: <53106555.1070405@monstr.eu> References: <1393530784-2397-1-git-send-email-clsee@altera.com> <53106555.1070405@monstr.eu> Message-ID: <1393976731.2356.0.camel@clsee-VirtualBox.altera.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Fri, 2014-02-28 at 11:30 +0100, Michal Simek wrote: > On 02/27/2014 08:53 PM, Chin Liang See wrote: > > To add the DesignWare watchdog driver support. It required > > information such as register base address and clock info from > > configuration header file within include/configs folder. > > > > Signed-off-by: Chin Liang See > > Cc: Anatolij Gustschin > > Cc: Albert Aribaud > > Cc: Heiko Schocher > > Cc: Tom Rini > > --- > > Changes for v4 > > - Add 2014 to license header > > Changes for v3 > > - Split to 2 series patch > > Changes for v2 > > - Enable this driver at socfpga_cyclone5 board > > --- > > drivers/watchdog/Makefile | 1 + > > drivers/watchdog/designware_wdt.c | 73 +++++++++++++++++++++++++++++++++++++ > > 2 files changed, 74 insertions(+) > > create mode 100644 drivers/watchdog/designware_wdt.c > > > > diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile > > index 06ced10..0276a10 100644 > > --- a/drivers/watchdog/Makefile > > +++ b/drivers/watchdog/Makefile > > @@ -15,3 +15,4 @@ obj-$(CONFIG_S5P) += s5p_wdt.o > > obj-$(CONFIG_XILINX_TB_WATCHDOG) += xilinx_tb_wdt.o > > obj-$(CONFIG_BFIN_WATCHDOG) += bfin_wdt.o > > obj-$(CONFIG_OMAP_WATCHDOG) += omap_wdt.o > > +obj-$(CONFIG_DESIGNWARE_WATCHDOG) += designware_wdt.o > > diff --git a/drivers/watchdog/designware_wdt.c b/drivers/watchdog/designware_wdt.c > > new file mode 100644 > > index 0000000..6abee81 > > --- /dev/null > > +++ b/drivers/watchdog/designware_wdt.c > > @@ -0,0 +1,73 @@ > > +/* > > + * Copyright (C) 2013-2014 Altera Corporation > > + * > > + * SPDX-License-Identifier: GPL-2.0+ > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > + > > +#define DW_WDT_CR 0x00 > > +#define DW_WDT_TORR 0x04 > > +#define DW_WDT_CRR 0x0C > > + > > +#define DW_WDT_CR_EN_OFFSET 0x00 > > +#define DW_WDT_CR_RMOD_OFFSET 0x01 > > +#define DW_WDT_CR_RMOD_VAL 0x00 > > +#define DW_WDT_CRR_RESTART_VAL 0x76 > > + > > +/* > > + * Set the watchdog time interval. > > + * Counter is 32 bit. > > + */ > > +int designware_wdt_settimeout(unsigned int timeout) > > +{ > > + signed int i; > > + /* calculate the timeout range value */ > > + i = (log_2_n_round_up(timeout * CONFIG_DW_WDT_CLOCK_KHZ)) - 16; > > + if (i > 15) > > + i = 15; > > + if (i < 0) > > + i = 0; > > + > > + writel((i | (i<<4)), (CONFIG_DW_WDT_BASE + DW_WDT_TORR)); > > i << 4 Fixed > > > > + return 0; > > +} > > + > > +void designware_wdt_enable(void) > > +{ > > + writel(((DW_WDT_CR_RMOD_VAL << DW_WDT_CR_RMOD_OFFSET) | > > + (0x1 << DW_WDT_CR_EN_OFFSET)), > > + (CONFIG_DW_WDT_BASE + DW_WDT_CR)); > > +} > > + > > +unsigned int designware_wdt_is_enabled(void) > > +{ > > + unsigned long val; > > + val = readl((CONFIG_DW_WDT_BASE + DW_WDT_CR)); > > + return val & 0x1; > > +} > > all 3 functions above I believe should be static because > you use them just here. Yup, I can enhance that. Thanks Chin Liang > > Thanks, > Michal >