From patchwork Tue Jan 27 01:04:23 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ed Swierk X-Patchwork-Id: 20364 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from wf-out-1516.google.com (wf-out-1516.google.com [209.85.200.161]) by ozlabs.org (Postfix) with ESMTP id 6CB2EDE105 for ; Tue, 27 Jan 2009 12:04:34 +1100 (EST) Received: by wf-out-1516.google.com with SMTP id r34so1794366wfc.41 for ; Mon, 26 Jan 2009 17:04:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=domainkey-signature:received:received:x-sender:x-apparently-to :received:received:received-spf:authentication-results:received :received:received:subject:from:to:mime-version:content-type:date :message-id:x-mailer:reply-to:sender:precedence:x-google-loop :mailing-list:list-id:list-post:list-help:list-unsubscribe :x-beenthere-env:x-beenthere; bh=byjLc0shP9mK1lKkTI/T9d1Nm/K/lxMUuMYGwqvi1V0=; b=yzLJn9U9/HdFWdCAOARd0H6jNWWe67QLZoirQrvVhHC1qZHIgCK7cmJ+RbrF9zbdT3 Dsrrl/p4cuQap9yywcnz1MThPmI5y+u0jC/90NUkyjraIWUFZjToJhapPHSb9Jsq+LhY 9vPm7233lQWjOnB4441BrBcqrymkKNqkTDjQc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlegroups.com; s=beta; h=x-sender:x-apparently-to:received-spf:authentication-results :subject:from:to:mime-version:content-type:date:message-id:x-mailer :reply-to:sender:precedence:x-google-loop:mailing-list:list-id :list-post:list-help:list-unsubscribe:x-beenthere-env:x-beenthere; b=RRwUByNA/Zc1pe7FLK/xjoS5S9JfQspKx2HJ77JcE4+bdw6BDmXsSy4qEvlTUfpnQa XgkT78QIP0IrU4iQyWiSDIvOJBL8/5sZ2SdYdlXT9o12/4vc9+N6XsLB/8ISwH3j7BES g/3b/p6T9gH3FB6HRDvNCaGrtYhE0YwyBtKtQ= Received: by 10.142.14.20 with SMTP id 20mr1246018wfn.15.1233018269516; Mon, 26 Jan 2009 17:04:29 -0800 (PST) Received: by 10.106.144.6 with SMTP id r6gr1858prd.0; Mon, 26 Jan 2009 17:04:29 -0800 (PST) X-Sender: eswierk@aristanetworks.com X-Apparently-To: rtc-linux@googlegroups.com Received: by 10.115.110.15 with SMTP id n15mr1727898wam.11.1233018269039; Mon, 26 Jan 2009 17:04:29 -0800 (PST) Received: from rv-out-0506.google.com (rv-out-0506.google.com [209.85.198.226]) by mx.google.com with ESMTP id k32si645241wah.1.2009.01.26.17.04.29; Mon, 26 Jan 2009 17:04:29 -0800 (PST) Received-SPF: pass (google.com: domain of eswierk@aristanetworks.com designates 209.85.198.226 as permitted sender) client-ip=209.85.198.226; Authentication-Results: mx.google.com; spf=pass (google.com: domain of eswierk@aristanetworks.com designates 209.85.198.226 as permitted sender) smtp.mail=eswierk@aristanetworks.com Received: by rv-out-0506.google.com with SMTP id k40so6128335rvb.1 for ; Mon, 26 Jan 2009 17:04:29 -0800 (PST) Received: by 10.142.126.6 with SMTP id y6mr223807wfc.83.1233018268811; Mon, 26 Jan 2009 17:04:28 -0800 (PST) Received: from ?172.17.2.29? (65-119-47-100.dia.static.qwest.net [65.119.47.100]) by mx.google.com with ESMTPS id 28sm13483241wfd.34.2009.01.26.17.04.27 (version=SSLv3 cipher=RC4-MD5); Mon, 26 Jan 2009 17:04:28 -0800 (PST) Subject: [rtc-linux] [PATCH] x86: i2c rtc instead of cmos rtc From: Ed Swierk To: a.zummo@towertech.it, rtc-linux@googlegroups.com, tglx@linutronix.de, mingo@redhat.com, linux-kernel@vger.kernel.org Mime-Version: 1.0 Date: Mon, 26 Jan 2009 17:04:23 -0800 Message-Id: <1233018263.14510.112.camel@localhost.localdomain> X-Mailer: Evolution 2.24.3 (2.24.3-1.fc10) Reply-To: rtc-linux@googlegroups.com Sender: rtc-linux@googlegroups.com Precedence: bulk X-Google-Loop: groups Mailing-List: list rtc-linux@googlegroups.com; contact rtc-linux+owner@googlegroups.com List-Id: List-Post: List-Help: List-Unsubscribe: , X-BeenThere-Env: rtc-linux@googlegroups.com X-BeenThere: rtc-linux@googlegroups.com Allows the user to ignore the cmos real-time clock normally found on x86 boards, and to use an i2c rtc in its place. This is intended to be used with with CONFIG_RTC_HCTOSYS=y to set the system clock from the rtc automatically during boot, and with CONFIG_RTC_SYSTOHC=y to have ntpd update the rtc (see separate patch). Passing rtc.cmos=0 on the kernel command line ignores the cmos rtc, and passing a parameter like rtc.i2c=ds1339,1,0x68 enables the i2c rtc named ds1339 on i2c bus 1, device address 0x68. The appropriate driver must be compiled into the kernel to be available when the initcall is triggered (device_initcall_sync to ensure the i2c device has already been added). Signed-off-by: Ed Swierk --- --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. -~----------~----~----~----~------~----~------~--~--- Index: linux-2.6.28.2/arch/x86/kernel/rtc.c =================================================================== --- linux-2.6.28.2.orig/arch/x86/kernel/rtc.c +++ linux-2.6.28.2/arch/x86/kernel/rtc.c @@ -220,6 +220,9 @@ static struct platform_device rtc_device .num_resources = ARRAY_SIZE(rtc_resources), }; +static int cmos = 1; +module_param(cmos, bool, 0); + static __init int add_rtc_cmos(void) { #ifdef CONFIG_PNP @@ -228,7 +231,11 @@ static __init int add_rtc_cmos(void) struct pnp_dev *dev; struct pnp_id *id; int i; +#endif + if (!cmos) + return 0; +#ifdef CONFIG_PNP pnp_for_each_dev(dev) { for (id = dev->id; id; id = id->next) { for (i = 0; i < ARRAY_SIZE(ids); i++) { @@ -245,3 +252,41 @@ static __init int add_rtc_cmos(void) return 0; } device_initcall(add_rtc_cmos); + +#include + +static char *i2c[3] = { NULL, NULL, NULL }; +module_param_array(i2c, charp, NULL, 0); + +static int setup_rtc_i2c(void) +{ + struct i2c_adapter *adapter; + struct i2c_board_info info = {}; + int adapter_id; + unsigned short addrs[] = { 0, I2C_CLIENT_END }; + struct i2c_client *c; + unsigned long num; + + if (!i2c[0] || !i2c[1] || !i2c[2]) + return 0; + + strlcpy(info.type, i2c[0], I2C_NAME_SIZE); + if (strict_strtoul(i2c[1], 0, &num)) + return 0; + adapter_id = num; + if (strict_strtoul(i2c[2], 0, &num)) + return 0; + addrs[0] = num; + + adapter = i2c_get_adapter(adapter_id); + if (!adapter) + return 0; + + c = i2c_new_probed_device(adapter, &info, addrs); + if (c && c->driver == NULL) { + i2c_unregister_device(c); + } + i2c_put_adapter(adapter); + return 0; +} +device_initcall_sync(setup_rtc_i2c);