From patchwork Mon Jun 15 15:49:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Hiremath X-Patchwork-Id: 49881 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 11814205DE for ; Mon, 15 Jun 2015 15:53:57 +0000 (UTC) Received: by labnp3 with SMTP id np3sf7780950lab.1 for ; Mon, 15 Jun 2015 08:53:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=g/TvmFgUKhAPyG07rvzOn/zPOrp4zmTbHwesOpyJhhw=; b=BDj2WfSyw2P7kHwdu1zQJD42em7OhGZdkpN6pklwrBE90Qsimf9Eg5SfJ0UrvmhUPb qUf7VE1lxIg6QU+Zi4D+2oB3Pl2fHlmkvbteCv9c+EtHjclB9VXYrFGVSmuEoNI2gCLG pFP/Ii54EVNon3bRrU/wg0BQTvUcrpaivIwja94bLEuT1DLWQnUBSogO+lW8SDBwSRR8 1EPb8U06oqurDQIy0MWeFKioo4EeHR5AAcAXtX2iNyZYXdYI7U+yyvZW23NLN+irj3LH LRRWyAoMI7Ncy+QJz1d5hIKCH4Qq/AADS7HIwjJglrgzwu1a2pMou7MHfApBmxylgoZV wEmw== X-Gm-Message-State: ALoCoQmdFsSYQxkaZy6HMnT47R6Dt8nj3kULJPQMm9dpI8JdWZHer23gmFVxqWw8+rgte/fxi4WK X-Received: by 10.194.175.36 with SMTP id bx4mr30369872wjc.1.1434383636015; Mon, 15 Jun 2015 08:53:56 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.29.7 with SMTP id f7ls835432lah.48.gmail; Mon, 15 Jun 2015 08:53:55 -0700 (PDT) X-Received: by 10.112.186.35 with SMTP id fh3mr914049lbc.82.1434383635850; Mon, 15 Jun 2015 08:53:55 -0700 (PDT) Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com. [209.85.217.173]) by mx.google.com with ESMTPS id ot8si10776573lbb.177.2015.06.15.08.53.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Jun 2015 08:53:55 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) client-ip=209.85.217.173; Received: by lbbti3 with SMTP id ti3so18912469lbb.1 for ; Mon, 15 Jun 2015 08:53:55 -0700 (PDT) X-Received: by 10.112.97.194 with SMTP id ec2mr908958lbb.88.1434383635500; Mon, 15 Jun 2015 08:53:55 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp1509009lbb; Mon, 15 Jun 2015 08:53:54 -0700 (PDT) X-Received: by 10.66.148.34 with SMTP id tp2mr49692228pab.65.1434383633625; Mon, 15 Jun 2015 08:53:53 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i6si18495084pdr.64.2015.06.15.08.53.52; Mon, 15 Jun 2015 08:53:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-i2c-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755811AbbFOPxw (ORCPT + 1 other); Mon, 15 Jun 2015 11:53:52 -0400 Received: from mail-pd0-f177.google.com ([209.85.192.177]:33463 "EHLO mail-pd0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755826AbbFOPxv (ORCPT ); Mon, 15 Jun 2015 11:53:51 -0400 Received: by pdjn11 with SMTP id n11so75772402pdj.0 for ; Mon, 15 Jun 2015 08:53:51 -0700 (PDT) X-Received: by 10.68.135.136 with SMTP id ps8mr50278772pbb.78.1434383631124; Mon, 15 Jun 2015 08:53:51 -0700 (PDT) Received: from localhost.localdomain ([202.62.77.106]) by mx.google.com with ESMTPSA id fs16sm12662484pdb.12.2015.06.15.08.53.47 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Jun 2015 08:53:49 -0700 (PDT) From: Vaibhav Hiremath To: linux-i2c@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, wsa@the-dreams.de, robert.jarzmik@free.fr, Vaibhav Hiremath , "Jett.Zhou" , Yi Zhang Subject: [PATCH-V2 10/12] i2c: pxa: Add support for pxa910/988 & new configuration features Date: Mon, 15 Jun 2015 21:19:57 +0530 Message-Id: <1434383399-2370-11-git-send-email-vaibhav.hiremath@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1434383399-2370-1-git-send-email-vaibhav.hiremath@linaro.org> References: <1434383399-2370-1-git-send-email-vaibhav.hiremath@linaro.org> Sender: linux-i2c-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-i2c@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: vaibhav.hiremath@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , PXA910 family of devices supports SCLK adjustment through TWSI_ILCR & TWSI_IWCR registers (for all supported modes). This patch also adds these two new register entries to "struct pxa_reg_layout" and "struct pxa_i2c". As discussed in the previous patch-series, the idea here is to add standard DT properties for ilcr and iwcr configuration fields. In case of Master ilcr is used for low/high time and in case of slave mode of operation iwcr is used for setup/hold time. Signed-off-by: Jett.Zhou Signed-off-by: Yi Zhang Signed-off-by: Vaibhav Hiremath --- drivers/i2c/busses/i2c-pxa.c | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c index c753411..97f9c7c 100644 --- a/drivers/i2c/busses/i2c-pxa.c +++ b/drivers/i2c/busses/i2c-pxa.c @@ -46,12 +46,15 @@ struct pxa_reg_layout { u32 icr; u32 isr; u32 isar; + u32 ilcr; + u32 iwcr; }; enum pxa_i2c_types { REGS_PXA2XX, REGS_PXA3XX, REGS_CE4100, + REGS_PXA910, }; /* @@ -79,12 +82,22 @@ static struct pxa_reg_layout pxa_reg_layout[] = { .isr = 0x04, /* no isar register */ }, + [REGS_PXA910] = { + .ibmr = 0x00, + .idbr = 0x08, + .icr = 0x10, + .isr = 0x18, + .isar = 0x20, + .ilcr = 0x28, + .iwcr = 0x30, + }, }; static const struct platform_device_id i2c_pxa_id_table[] = { { "pxa2xx-i2c", REGS_PXA2XX }, { "pxa3xx-pwri2c", REGS_PXA3XX }, { "ce4100-i2c", REGS_CE4100 }, + { "pxa910-i2c", REGS_PXA910 }, { }, }; MODULE_DEVICE_TABLE(platform, i2c_pxa_id_table); @@ -124,6 +137,24 @@ MODULE_DEVICE_TABLE(platform, i2c_pxa_id_table); #define ISR_SAD (1 << 9) /* slave address detected */ #define ISR_BED (1 << 10) /* bus error no ACK/NAK */ +/* bit field shift & mask */ +#define ILCR_SLV_SHIFT 0 +#define ILCR_SLV_MASK (0x1FF << ILCR_SLV_SHIFT) +#define ILCR_FLV_SHIFT 9 +#define ILCR_FLV_MASK (0x1FF << ILCR_FLV_SHIFT) +#define ILCR_HLVL_SHIFT 18 +#define ILCR_HLVL_MASK (0x1FF << ILCR_HLVL_SHIFT) +#define ILCR_HLVH_SHIFT 27 +#define ILCR_HLVH_MASK (0x1F << ILCR_HLVH_SHIFT) + +#define IWCR_CNT_SHIFT 0 +#define IWCR_CNT_MASK (0x1F << IWCR_CNT_SHIFT) +#define IWCR_HS_CNT1_SHIFT 5 +#define IWCR_HS_CNT1_MASK (0x1F << IWCR_HS_CNT1_SHIFT) +#define IWCR_HS_CNT2_SHIFT 10 +#define IWCR_HS_CNT2_MASK (0x1F << IWCR_HS_CNT2_SHIFT) + + struct pxa_i2c { spinlock_t lock; wait_queue_head_t wait; @@ -150,6 +181,8 @@ struct pxa_i2c { void __iomem *reg_icr; void __iomem *reg_isr; void __iomem *reg_isar; + void __iomem *reg_ilcr; + void __iomem *reg_iwcr; unsigned long iobase; unsigned long iosize; @@ -169,6 +202,8 @@ struct pxa_i2c { #define _ICR(i2c) ((i2c)->reg_icr) #define _ISR(i2c) ((i2c)->reg_isr) #define _ISAR(i2c) ((i2c)->reg_isar) +#define _ILCR(i2c) ((i2c)->reg_ilcr) +#define _IWCR(i2c) ((i2c)->reg_iwcr) /* * I2C Slave mode address @@ -1141,7 +1176,7 @@ static const struct i2c_algorithm i2c_pxa_pio_algorithm = { static const struct of_device_id i2c_pxa_dt_ids[] = { { .compatible = "mrvl,pxa-i2c", .data = (void *)REGS_PXA2XX }, { .compatible = "mrvl,pwri2c", .data = (void *)REGS_PXA3XX }, - { .compatible = "mrvl,mmp-twsi", .data = (void *)REGS_PXA2XX }, + { .compatible = "mrvl,mmp-twsi", .data = (void *)REGS_PXA910 }, {} }; MODULE_DEVICE_TABLE(of, i2c_pxa_dt_ids); @@ -1255,6 +1290,11 @@ static int i2c_pxa_probe(struct platform_device *dev) if (i2c_type != REGS_CE4100) i2c->reg_isar = i2c->reg_base + pxa_reg_layout[i2c_type].isar; + if (i2c_type == REGS_PXA910) { + i2c->reg_ilcr = i2c->reg_base + pxa_reg_layout[i2c_type].ilcr; + i2c->reg_iwcr = i2c->reg_base + pxa_reg_layout[i2c_type].iwcr; + } + i2c->iobase = res->start; i2c->iosize = resource_size(res);