From patchwork Thu Sep 1 11:34:34 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 112883 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 1AF50B6F6F for ; Thu, 1 Sep 2011 21:37:02 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E21BB28191; Thu, 1 Sep 2011 13:36:44 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wkHWsbf1IXTX; Thu, 1 Sep 2011 13:36:44 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 81D962815F; Thu, 1 Sep 2011 13:36:33 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A889F28168 for ; Thu, 1 Sep 2011 13:36:29 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WOp-IDeSSc7u for ; Thu, 1 Sep 2011 13:36:28 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-bw0-f44.google.com (mail-bw0-f44.google.com [209.85.214.44]) by theia.denx.de (Postfix) with ESMTPS id A6E1528147 for ; Thu, 1 Sep 2011 13:36:28 +0200 (CEST) Received: by mail-bw0-f44.google.com with SMTP id r4so1508588bka.3 for ; Thu, 01 Sep 2011 04:36:28 -0700 (PDT) Received: by 10.204.136.154 with SMTP id r26mr960937bkt.327.1314876988542; Thu, 01 Sep 2011 04:36:28 -0700 (PDT) Received: from Pali-EliteBook.kolej.mff.cuni.cz (rohar.kolej.mff.cuni.cz [78.128.193.202]) by mx.google.com with ESMTPS id a17sm159596bku.56.2011.09.01.04.36.27 (version=SSLv3 cipher=OTHER); Thu, 01 Sep 2011 04:36:27 -0700 (PDT) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: u-boot@lists.denx.de Date: Thu, 1 Sep 2011 13:34:34 +0200 Message-Id: <1314876881-9669-8-git-send-email-pali.rohar@gmail.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1314876881-9669-1-git-send-email-pali.rohar@gmail.com> References: <201109011304.46581.marek.vasut@gmail.com> <1314876881-9669-1-git-send-email-pali.rohar@gmail.com> Subject: [U-Boot] [PATCH 08/15] RX-51: Add support for resetting twl4030 watchdog X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de * use test_and_set_bit and __clear_bit to access twl4030 i2c bus only once at same time * do not reset watchdog too often (max every 2 seconds) --- board/nokia/rx51/rx51.c | 25 +++++++++++++++++++++++-- include/configs/nokia_rx51.h | 1 + 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/board/nokia/rx51/rx51.c b/board/nokia/rx51/rx51.c index 96e65d6..a90e4dd 100644 --- a/board/nokia/rx51/rx51.c +++ b/board/nokia/rx51/rx51.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -192,6 +193,23 @@ int rx51_kp_init(void) return ret; } +static unsigned long int twl_wd_start = 0; +static volatile unsigned long int twl_chip_lock; + +void hw_watchdog_reset(void) +{ + + if ( get_timer(twl_wd_start) < 2 * CONFIG_SYS_HZ ) + return; + + if ( test_and_set_bit(0, &twl_chip_lock) ) + return; + twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, 31, TWL4030_PM_RECEIVER_WATCHDOG_CFG); + __clear_bit(0, &twl_chip_lock); + + twl_wd_start = get_timer(0); +} + char rx51_kp_fill(u8 k, u8 mods) { if (mods & 2) { /* fn */ @@ -217,6 +235,9 @@ int rx51_kp_tstc(void) u8 intr; u8 mods; + if ( test_and_set_bit(0, &twl_chip_lock) ) + return 0; + /* twl4030 remembers up to 2 events */ for (i = 0; i < 2; i++) { @@ -249,6 +270,7 @@ int rx51_kp_tstc(void) } } } + __clear_bit(0, &twl_chip_lock); return (KEYBUF_SIZE + keybuf_tail - keybuf_head)%KEYBUF_SIZE; } @@ -256,7 +278,6 @@ int rx51_kp_getc(void) { keybuf_head %= KEYBUF_SIZE; while (!rx51_kp_tstc()) - ; + udelay(10000); return keybuf[keybuf_head++]; } - diff --git a/include/configs/nokia_rx51.h b/include/configs/nokia_rx51.h index 6da56f5..6d93146 100644 --- a/include/configs/nokia_rx51.h +++ b/include/configs/nokia_rx51.h @@ -144,6 +144,7 @@ #define CONFIG_SYS_I2C_BUS 0 #define CONFIG_SYS_I2C_BUS_SELECT 1 #define CONFIG_DRIVER_OMAP34XX_I2C 1 +#define CONFIG_HW_WATCHDOG /* * TWL4030