From patchwork Thu Dec 1 11:04:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Perier X-Patchwork-Id: 701458 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3tTvZC3GNyz9t0v for ; Thu, 1 Dec 2016 22:04:51 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755747AbcLALEr (ORCPT ); Thu, 1 Dec 2016 06:04:47 -0500 Received: from mail.free-electrons.com ([62.4.15.54]:55424 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755559AbcLALEp (ORCPT ); Thu, 1 Dec 2016 06:04:45 -0500 Received: by mail.free-electrons.com (Postfix, from userid 110) id 928CE21CFE; Thu, 1 Dec 2016 12:04:42 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from latitudeE7470 (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 6EFA920B57; Thu, 1 Dec 2016 12:04:42 +0100 (CET) From: Romain Perier To: Wolfram Sang , linux-i2c@vger.kernel.org Cc: devicetree@vger.kernel.org, Rob Herring , Ian Campbell , Pawel Moll , Mark Rutland , Kumar Gala , linux-arm-kernel@lists.infradead.org, Jason Cooper , Andrew Lunn , Sebastian Hesselbarth , Gregory Clement , Thomas Petazzoni , Nadav Haklai , Omri Itach , Shadi Ammouri , Yahuda Yitschak , Hanna Hawa , Neta Zur Hershkovits , Igal Liberman , Marcin Wojtas Subject: [PATCH v7 2/4] i2c: pxa: Add support for the I2C units found in Armada 3700 Date: Thu, 1 Dec 2016 12:04:38 +0100 Message-Id: <20161201110440.27530-3-romain.perier@free-electrons.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20161201110440.27530-1-romain.perier@free-electrons.com> References: <20161201110440.27530-1-romain.perier@free-electrons.com> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org The Armada 3700 has two I2C controllers that is compliant with the I2C Bus Specificiation 2.1, supports multi-master and different bus speed: Standard mode (up to 100 KHz), Fast mode (up to 400 KHz), High speed mode (up to 3.4 Mhz). This IP block has a lot of similarity with the PXA, except some register offsets and bitfield. This commits adds a basic support for this I2C unit. Signed-off-by: Romain Perier Tested-by: Gregory CLEMENT --- Changes in v6: - Revert back A3700_REGS, as asked by Wolfram and define fm_mask and hs_mask in the register layout. I moved the generic code for fm_mask and hs_mask to a seperated commit (1/4) Changes in v5: - Don't define registers for armada-3700, we can re-use the ones for PXA3XX. - Define registers mask when OF is not used, in probe_pdata. Changes in v4: - Replaced the type of hs_mask and fm_mask by u32, instead of unsigned int, As writel() take an u32 as first argument... Changes in v3: - Replaced the type of hs_mask and fm_mask by unsigned int, instead of unsigned long. drivers/i2c/busses/Kconfig | 2 +- drivers/i2c/busses/i2c-pxa.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index d252276..2f56a26 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -763,7 +763,7 @@ config I2C_PUV3 config I2C_PXA tristate "Intel PXA2XX I2C adapter" - depends on ARCH_PXA || ARCH_MMP || (X86_32 && PCI && OF) + depends on ARCH_PXA || ARCH_MMP || ARCH_MVEBU || (X86_32 && PCI && OF) help If you have devices in the PXA I2C bus, say yes to this option. This driver can also be built as a module. If so, the module diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c index b4ac235..6cf333e 100644 --- a/drivers/i2c/busses/i2c-pxa.c +++ b/drivers/i2c/busses/i2c-pxa.c @@ -57,8 +57,12 @@ enum pxa_i2c_types { REGS_PXA3XX, REGS_CE4100, REGS_PXA910, + REGS_A3700, }; +#define ICR_BUSMODE_FM (1 << 16) /* shifted fast mode for armada-3700 */ +#define ICR_BUSMODE_HS (1 << 17) /* shifted high speed mode for armada-3700 */ + /* * I2C registers definitions */ @@ -93,6 +97,15 @@ static struct pxa_reg_layout pxa_reg_layout[] = { .ilcr = 0x28, .iwcr = 0x30, }, + [REGS_A3700] = { + .ibmr = 0x00, + .idbr = 0x04, + .icr = 0x08, + .isr = 0x0c, + .isar = 0x10, + .fm = ICR_BUSMODE_FM, + .hs = ICR_BUSMODE_HS, + }, }; static const struct platform_device_id i2c_pxa_id_table[] = { @@ -100,6 +113,7 @@ static const struct platform_device_id i2c_pxa_id_table[] = { { "pxa3xx-pwri2c", REGS_PXA3XX }, { "ce4100-i2c", REGS_CE4100 }, { "pxa910-i2c", REGS_PXA910 }, + { "armada-3700-i2c", REGS_A3700 }, { }, }; MODULE_DEVICE_TABLE(platform, i2c_pxa_id_table); @@ -1141,6 +1155,7 @@ 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_PXA910 }, + { .compatible = "marvell,armada-3700-i2c", .data = (void *)REGS_A3700 }, {} }; MODULE_DEVICE_TABLE(of, i2c_pxa_dt_ids);