From patchwork Wed Jun 5 11:19:22 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grygorii Strashko X-Patchwork-Id: 249001 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-pb0-x240.google.com (mail-pb0-x240.google.com [IPv6:2607:f8b0:400e:c01::240]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 7769A2C0099 for ; Wed, 5 Jun 2013 21:23:06 +1000 (EST) Received: by mail-pb0-f64.google.com with SMTP id wz12sf397618pbc.29 for ; Wed, 05 Jun 2013 04:23:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=x-beenthere:from:to:cc:subject:date:message-id:x-mailer :mime-version:x-original-sender:x-original-authentication-results :reply-to:precedence:mailing-list:list-id:x-google-group-id :list-post:list-help:list-archive:sender:list-subscribe :list-unsubscribe:content-type; bh=kmiFj5cINCTcBJBuI+5ENZdmjZNd9MvDz3aQkSS4DB4=; b=D/tLD8GhLBG0Em6ZySwr3eW3tIcViUPCdziX0t1fk6vRQkx08/cuJIXA1raSojWxId BS++wpNHnI7Dl92NiqrK2jwXU5CFCwFzdWtz2gdjOQn25xrPM9XT33kRu4sUoJ5XYSkK PP/U/HvqvDe7/U/Iv7q3DXaDAX24aFJSNMpDrxSxJV7EquKLvFFbQiuAaKEziwIA2ufs LbTSH5iwtJkM9KzTaGjK654WuPWE5+f7d1/Ym2YFoYhiF2+GKaTtZw7isK1ILotwcnZg QRLY9JEY1L5C0PgyLOhZy698vwdeycUihE5a76r+WB4fbyvzvSidwHCi8F/+XAW5DcM+ mjPg== X-Received: by 10.50.108.104 with SMTP id hj8mr707968igb.13.1370431384481; Wed, 05 Jun 2013 04:23:04 -0700 (PDT) X-BeenThere: rtc-linux@googlegroups.com Received: by 10.50.111.138 with SMTP id ii10ls3481819igb.33.canary; Wed, 05 Jun 2013 04:23:03 -0700 (PDT) X-Received: by 10.42.64.143 with SMTP id g15mr23149607ici.30.1370431383851; Wed, 05 Jun 2013 04:23:03 -0700 (PDT) Received: from bear.ext.ti.com (bear.ext.ti.com. [192.94.94.41]) by gmr-mx.google.com with ESMTPS id s11si488280ign.0.2013.06.05.04.23.03 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 05 Jun 2013 04:23:03 -0700 (PDT) Received-SPF: pass (google.com: domain of grygorii.strashko@ti.com designates 192.94.94.41 as permitted sender) client-ip=192.94.94.41; Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id r55BN2ED003648; Wed, 5 Jun 2013 06:23:02 -0500 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id r55BN2Th019169; Wed, 5 Jun 2013 06:23:02 -0500 Received: from dlelxv22.itg.ti.com (172.17.1.197) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.2.342.3; Wed, 5 Jun 2013 06:23:02 -0500 Received: from localhost (uglx0174654.ucm2.emeaucm.ext.ti.com [10.167.145.172]) by dlelxv22.itg.ti.com (8.13.8/8.13.8) with ESMTP id r55BN1Xf032464; Wed, 5 Jun 2013 06:23:01 -0500 From: Grygorii Strashko To: , Andrew Morton CC: , , Grygorii Strashko , Alessandro Zummo , Tony Lindgren Subject: [rtc-linux] [PATCH] rtc: rtc-twl: fix initialization sequence Date: Wed, 5 Jun 2013 14:19:22 +0300 Message-ID: <1370431162-24185-1-git-send-email-grygorii.strashko@ti.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 X-Original-Sender: grygorii.strashko@ti.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of grygorii.strashko@ti.com designates 192.94.94.41 as permitted sender) smtp.mail=grygorii.strashko@ti.com Reply-To: rtc-linux@googlegroups.com Precedence: list Mailing-list: list rtc-linux@googlegroups.com; contact rtc-linux+owners@googlegroups.com List-ID: X-Google-Group-Id: 712029733259 List-Post: , List-Help: , List-Archive: Sender: rtc-linux@googlegroups.com List-Subscribe: , List-Unsubscribe: , The twl-rtc has the following dependencies from other drivers during the boot: pinctrl |-i2c-omap |- twl-core |- twl-rtc The i2c-omap probe may be deferred because pinctrl iss not ready yet. As result, i2c-omap will be probed at late init time. Which, in turn, will delay twl-core initialization till late init time too. But, the twl-rtc driver is registered from finction twl_rtc_init() at module(device) init time and contains part of its initialization code within it. Unfortunatelly, this code depends on twl-core which may be not ready at that moment and, as result, wrong register map will be selected (on OMAP3 twl6030_rtc_reg_map will be selected instead of twl4030_rtc_reg_map). static int __init twl_rtc_init(void) { if (twl_class_is_4030()) <--- twl-core might be not ready here <--- and twl_class_is_4030() will return 0 rtc_reg_map = (u8 *) twl4030_rtc_reg_map; else rtc_reg_map = (u8 *) twl6030_rtc_reg_map; return platform_driver_register(&twl4030rtc_driver); } Hence, move register map selection code in twl_rtc_probe() to solve this issue. Cc: Alessandro Zummo Cc: Andrew Morton Cc: Tony Lindgren Signed-off-by: Grygorii Strashko --- drivers/rtc/rtc-twl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/rtc/rtc-twl.c b/drivers/rtc/rtc-twl.c index bbda0fd..1698115 100644 --- a/drivers/rtc/rtc-twl.c +++ b/drivers/rtc/rtc-twl.c @@ -481,6 +481,11 @@ static int twl_rtc_probe(struct platform_device *pdev) if (irq <= 0) goto out1; + if (twl_class_is_4030()) + rtc_reg_map = (u8 *) twl4030_rtc_reg_map; + else + rtc_reg_map = (u8 *) twl6030_rtc_reg_map; + ret = twl_rtc_read_u8(&rd_reg, REG_RTC_STATUS_REG); if (ret < 0) goto out1; @@ -622,11 +627,6 @@ static struct platform_driver twl4030rtc_driver = { static int __init twl_rtc_init(void) { - if (twl_class_is_4030()) - rtc_reg_map = (u8 *) twl4030_rtc_reg_map; - else - rtc_reg_map = (u8 *) twl6030_rtc_reg_map; - return platform_driver_register(&twl4030rtc_driver); } module_init(twl_rtc_init);