From patchwork Thu May 28 13:03:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Hiremath X-Patchwork-Id: 49105 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 2DCB9202A3 for ; Thu, 28 May 2015 13:06:52 +0000 (UTC) Received: by lani11 with SMTP id i11sf10967238lan.3 for ; Thu, 28 May 2015 06:06:51 -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=0TLAm0S82vqBsFrP+f4AkOiL8Ksxp63UmUp8jiPD3K8=; b=VXY18m6DyU0eJSP8TZGm9OjqNcrU2HKj/8JxpRHW+XqbZBC/L7oVzXPzKOv+VMzo+7 4tUjmjW1HOVuzDrZYtZ0sCJlawSef+JLeffm7VqB4hGGD0VLSV3KmRNTlciadxC5CTfc LJKeVPURHJgLpfET8+5yTCS6q1ER+qRJ2956u+J1rYjLkS2KhmVTTE1PmVsDLVZtWJy+ OHMxxeSS+FLYRqWtkWtj5LJedSt/2nB9fEPh5HlO4ams52Z1s+po/swNta5+Zxw/wfpN gfTVF7IXRhxDyPERaqpJYeZveXuMw5dpw9W+3fvGN61sw9PrqiRnXlSsIy9TVgRKQqek FaXg== X-Gm-Message-State: ALoCoQl+cJA2ts7J3rQkDlbU7qEsqKBM/dZwYOTE2QgDfNTQSqFK+hBQ51pA3E9w0zRiHQKUL6Xn X-Received: by 10.194.202.229 with SMTP id kl5mr2609947wjc.3.1432818411140; Thu, 28 May 2015 06:06:51 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.88.41 with SMTP id bd9ls15580lab.109.gmail; Thu, 28 May 2015 06:06:50 -0700 (PDT) X-Received: by 10.112.13.98 with SMTP id g2mr2774229lbc.102.1432818410819; Thu, 28 May 2015 06:06:50 -0700 (PDT) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id u9si1921208lau.48.2015.05.28.06.06.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 May 2015 06:06:50 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by labpy14 with SMTP id py14so19439564lab.0 for ; Thu, 28 May 2015 06:06:50 -0700 (PDT) X-Received: by 10.112.220.7 with SMTP id ps7mr2680657lbc.72.1432818410687; Thu, 28 May 2015 06:06:50 -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 hn6csp1144391lbb; Thu, 28 May 2015 06:06:49 -0700 (PDT) X-Received: by 10.68.200.69 with SMTP id jq5mr3521011pbc.111.1432818408658; Thu, 28 May 2015 06:06:48 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id em5si3485083pbb.256.2015.05.28.06.06.47; Thu, 28 May 2015 06:06:48 -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 S1752781AbbE1NGn (ORCPT + 1 other); Thu, 28 May 2015 09:06:43 -0400 Received: from mail-pd0-f171.google.com ([209.85.192.171]:36712 "EHLO mail-pd0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753675AbbE1NGl (ORCPT ); Thu, 28 May 2015 09:06:41 -0400 Received: by pdfh10 with SMTP id h10so41416049pdf.3 for ; Thu, 28 May 2015 06:06:40 -0700 (PDT) X-Received: by 10.66.159.106 with SMTP id xb10mr5187629pab.129.1432818400862; Thu, 28 May 2015 06:06:40 -0700 (PDT) Received: from localhost.localdomain ([202.62.77.106]) by mx.google.com with ESMTPSA id dc5sm2392557pbc.53.2015.05.28.06.06.37 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 May 2015 06:06:39 -0700 (PDT) From: Vaibhav Hiremath To: linux-i2c@vger.kernel.org Cc: Wolfram Sang , linux-arm-kernel@lists.infradead.org, "Jett.Zhou" , Yi Zhang , Vaibhav Hiremath Subject: [PATCH 04/12] i2c: pxa: Add support for pxa910/988 & new configuration features Date: Thu, 28 May 2015 18:33:36 +0530 Message-Id: <1432818224-17070-5-git-send-email-vaibhav.hiremath@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1432818224-17070-1-git-send-email-vaibhav.hiremath@linaro.org> References: <1432818224-17070-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.215.52 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: , From: "Jett.Zhou" TWSI_ILCR & TWSI_IWCR registers are used to adjust clock rate of standard & fast mode in pxa910/988; so this patch adds these two new entries to "struct pxa_reg_layout" and "struct pxa_i2c" and also adds two new DT properties to take configuration value for the same. Note that, DT binding document is also updated. Signed-off-by: Jett.Zhou Signed-off-by: Yi Zhang [vaibhav.hiremath@linaro.org: Updated kernel doc for new DT properties and updated Changelog] Signed-off-by: Vaibhav Hiremath Signed-off-by: Vaibhav Hiremath --- Documentation/devicetree/bindings/i2c/i2c-pxa.txt | 7 ++++ drivers/i2c/busses/i2c-pxa.c | 44 +++++++++++++++++++++-- include/linux/i2c/pxa-i2c.h | 2 ++ 3 files changed, 51 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/i2c/i2c-pxa.txt b/Documentation/devicetree/bindings/i2c/i2c-pxa.txt index 12b78ac..5750bff 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-pxa.txt +++ b/Documentation/devicetree/bindings/i2c/i2c-pxa.txt @@ -18,6 +18,13 @@ Recommended properties : status register of i2c controller instead. - mrvl,i2c-fast-mode : Enable fast mode of i2c controller. +Optional Properties (Applicable to PXA910 family): + + - mrvl,i2c-ilcr : Load Count Register: Allows minor adjustment to SCL clk to + achieve std, normal and fast mode of operation. + - mrvl,i2c-iwcr : Wait Count Register - controls the setup and hold time + together with mrvl,i2c-ilcr + Examples: twsi1: i2c@d4011000 { compatible = "mrvl,mmp-twsi"; diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c index a76c901..8ca5552 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); @@ -149,6 +162,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; @@ -160,6 +175,8 @@ struct pxa_i2c { unsigned char master_code; unsigned long rate; bool highmode_enter; + unsigned int ilcr; + unsigned int iwcr; }; #define _IBMR(i2c) ((i2c)->reg_ibmr) @@ -167,6 +184,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 @@ -467,11 +486,16 @@ static void i2c_pxa_reset(struct pxa_i2c *i2c) if (i2c->reg_isar) writel(i2c->slave_addr, _ISAR(i2c)); #endif - /* set control register values */ writel(I2C_ICR_INIT | (i2c->fast_mode ? ICR_FM : 0), _ICR(i2c)); writel(readl(_ICR(i2c)) | (i2c->high_mode ? ICR_HS : 0), _ICR(i2c)); + if (i2c->ilcr) + writel(i2c->ilcr, _ILCR(i2c)); + if (i2c->iwcr) + writel(i2c->iwcr, _IWCR(i2c)); + udelay(2); + #ifdef CONFIG_I2C_PXA_SLAVE dev_info(&i2c->adap.dev, "Enabling slave mode\n"); writel(readl(_ICR(i2c)) | ICR_SADIE | ICR_ALDIE | ICR_SSDIE, _ICR(i2c)); @@ -1098,7 +1122,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); @@ -1106,6 +1130,7 @@ MODULE_DEVICE_TABLE(of, i2c_pxa_dt_ids); static int i2c_pxa_probe_dt(struct platform_device *pdev, struct pxa_i2c *i2c, enum pxa_i2c_types *i2c_types) { + int ret; struct device_node *np = pdev->dev.of_node; const struct of_device_id *of_id = of_match_device(i2c_pxa_dt_ids, &pdev->dev); @@ -1121,6 +1146,16 @@ static int i2c_pxa_probe_dt(struct platform_device *pdev, struct pxa_i2c *i2c, if (of_get_property(np, "mrvl,i2c-fast-mode", NULL)) i2c->fast_mode = 1; *i2c_types = (u32)(of_id->data); + + if (of_device_is_compatible(np, "mrvl,mmp-twsi")) { + ret = of_property_read_u32(np, "mrvl,i2c-ilcr", &i2c->ilcr); + if (ret) + return ret; + ret = of_property_read_u32(np, "mrvl,i2c-iwcr", &i2c->iwcr); + if (ret) + return ret; + } + return 0; } @@ -1206,6 +1241,9 @@ 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; + 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); @@ -1219,6 +1257,8 @@ static int i2c_pxa_probe(struct platform_device *dev) i2c->slave_addr = plat->slave_addr; i2c->slave = plat->slave; #endif + i2c->ilcr = plat->ilcr; + i2c->iwcr = plat->iwcr; i2c->adap.class = plat->class; } diff --git a/include/linux/i2c/pxa-i2c.h b/include/linux/i2c/pxa-i2c.h index 53aab24..d1a44e8 100644 --- a/include/linux/i2c/pxa-i2c.h +++ b/include/linux/i2c/pxa-i2c.h @@ -70,6 +70,8 @@ struct i2c_pxa_platform_data { unsigned int high_mode:1; unsigned char master_code; unsigned long rate; + unsigned int ilcr; + unsigned int iwcr; }; extern void pxa_set_i2c_info(struct i2c_pxa_platform_data *info);