From patchwork Fri Nov 17 08:21:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Ying-22455 X-Patchwork-Id: 838898 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3ydWkZ35H0z9s0g for ; Fri, 17 Nov 2017 19:39:34 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965503AbdKQIjd (ORCPT ); Fri, 17 Nov 2017 03:39:33 -0500 Received: from mail-bn3nam01on0065.outbound.protection.outlook.com ([104.47.33.65]:2592 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S965444AbdKQIjc (ORCPT ); Fri, 17 Nov 2017 03:39:32 -0500 Received: from MWHPR03CA0013.namprd03.prod.outlook.com (10.175.133.151) by CO2PR03MB2359.namprd03.prod.outlook.com (10.166.93.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.239.5; Fri, 17 Nov 2017 08:39:31 +0000 Received: from BN1AFFO11FD040.protection.gbl (2a01:111:f400:7c10::119) by MWHPR03CA0013.outlook.office365.com (2603:10b6:300:117::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.239.5 via Frontend Transport; Fri, 17 Nov 2017 08:39:30 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1AFFO11FD040.mail.protection.outlook.com (10.58.52.251) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.197.9 via Frontend Transport; Fri, 17 Nov 2017 08:39:30 +0000 Received: from titan.ap.freescale.net ([10.192.208.233]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id vAH8dPRR006450; Fri, 17 Nov 2017 01:39:28 -0700 From: To: CC: Zhang Ying-22455 Subject: [PATCH 2/2] i2c: imx: implement bus recovery with gpio for Layerscape Date: Fri, 17 Nov 2017 16:21:04 +0800 Message-ID: <20171117082104.18140-2-ying.zhang22455@nxp.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171117082104.18140-1-ying.zhang22455@nxp.com> References: <20171117082104.18140-1-ying.zhang22455@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131553815701771278; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7966004)(336005)(39860400002)(346002)(376002)(39380400002)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(8676002)(77096006)(53936002)(47776003)(36756003)(8936002)(4326008)(81166006)(81156014)(50986999)(76176999)(86152003)(104016004)(68736007)(48376002)(50466002)(316002)(305945005)(356003)(16586007)(106466001)(50226002)(33646002)(2351001)(1076002)(8656006)(6666003)(2950100002)(575784001)(86362001)(105606002)(85426001)(2906002)(498600001)(6916009)(97736004)(189998001)(5660300001)(2876002)(5003940100001); DIR:OUT; SFP:1101; SCL:1; SRVR:CO2PR03MB2359; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD040; 1:lnY66Ed5QXDX8aEcxWA9AeTGQWIRsezWPiXXGlri/OOFktNb7sUlSXbyXutKx/JraBbKkpngQKg40oAPDqrkxTjCmo7KqCYZaGlxJbPLylW1EIcV7gz631TbnC2Wd3Ev MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: da3d1e24-721f-4d4d-f2ad-08d52d96b834 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(4534020)(4628075)(201703131517081)(2017052603199); SRVR:CO2PR03MB2359; X-Microsoft-Exchange-Diagnostics: 1; CO2PR03MB2359; 3:UbasYyr9kH5KgC/k6ykgZn/sbPOmILFgVfzX5W5KbSI6Ajdy7VZgKiSnBxexPEq9W7v+1ZmVnRZtQ7aruunDIs/V5pCGrfsVHKa4d3fP3x7NR4G7OpZ4MZ9LnGo6BxReiBE0sgQmpfWyhYyPCjOqJ7l1Bhdogr9wilaU2iP2hrM9Dh41DLF0vM7zeV+0DdSWN44CpAz7P1y3PlzXkvZTuVHdYwbVdyIHI0nBXLEOD0pOAtsmvaTyoyq0TrujthI7rpcrcE0saKJ6kZCrYx9F+zzuphkIzGtBp2DavOyi6kz84zVEXYS+hVsySfV8tGorliHrvkMm6nCPzJDQiDIeuY5+D9K30jLYtdLNcqB36RE=; 25:NVU8opJWnS9qGPYinsUZVDczFpaUtrZUURAMsYsa60qx3J5loT+Km+ZXfrQiEK9wq3C+h9SszBOxkydDC1Yg3jw/dZ276LZWzdlcYwnd4pXYAF20kMAOYGjoJQqQFF+v+9eEqzgVORcM8xyTy8k+ogMbVYDZf8Zm+ZARL2uUmeMyGs7wH9/6Z6dbmeopS87xZVYRViVneqy0a0CMsEQbWA2OjhPLCOkAtiYW911r4UIrMeoBQEys1t2f/9ZePQNVtNcpZxU4bWvpljabf+XcyAwFAvIYNJfPwQSnh2+ipkt3ulI4iFs+UoC6KzT6mOEH8AYj9ZBHGyDVOkCW4yNs9Q== X-MS-TrafficTypeDiagnostic: CO2PR03MB2359: X-Microsoft-Exchange-Diagnostics: 1; CO2PR03MB2359; 31:3M9uqtQoK1o6HX5dE0luujSs+seK6mWR2weSIbBjFk8dB/Gp/X25YxGkCRPInHsge+M0leflRL5Qx5snPlvzNHhdKXv/tGmRZejDt1z3qSRwrLgCiSqtFXw1LMgXREUnHDqlljuS1zAakG2gtHIxZ2P/zlUp0wePacqyZDNKyoOxMGxRUQEitgzxpJF8Ndjict8TpLH4DIBcvAg0NixPB8ZDtGryu1olJuob7jWuS/Y=; 4:O4hn2zBl5Da2iTidYAnh52R5knnHSMHA3i8RZOZvo3ntpuwQOJ+Rn7WFbwXGfk8CvhzG/xXNz+v1pG3CRfBxW3YcL6YinMEwef2vklaUz2N0vtbI6v5lkUdguv8aLwzF+qVkFVW5nNb4CKp9atnVZuKgzeiHZ+deUTozdvFoUucfoHtbDnhcwCGofnaDzJDvfweHN/kAqeJXQhsil00YhWkAPmBySFuhRt5g27JiLpsCUc4YebIHhqiN4pCqUtTMi+E861rijEV9lkpzRiR5NIhEbnZjSVhUsDGw3clSIN50204N7xjrXrvmzmwk6PRj73HXN3WkhoeByyWBKBP2EBGR07NIjux3CR4fzurxlWudMtVyfKsDA2gft7TzBxPr X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(20558992708506)(185117386973197)(21532816269658); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6095135)(2401047)(5005006)(8121501046)(100000703101)(100105400095)(3002001)(10201501046)(93006095)(93001095)(3231022)(6055026)(6096035)(20161123559100)(20161123565025)(20161123563025)(20161123556025)(201703131430075)(201703131441075)(201703131448075)(201703131433075)(201703161259150)(20161123561025)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:CO2PR03MB2359; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(400006)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:CO2PR03MB2359; X-Forefront-PRVS: 049486C505 X-Microsoft-Exchange-Diagnostics: 1; CO2PR03MB2359; 23:a4VmUHvcC2gwiPTrel6dC0p6C1JgSz36dTYPW7CPmMmpHkJuexS9GlA3+v20ma8GcM1Kw06s9CO4bWkxO0xHq3845+sgCb4jkbV4Z2OM2qRqFNDETu2AkaHaUbHSuqCarZpGC+GVRzn9fbomezuT5IWamYC7+jjQswtQXnejMN0KdcyUEsKv54HdgnBNU6wKxk4yqSWq3trAdlRMFB39bBfzL74k2K1Inwi8qZWf+EKpTlpu8YyB9uOGQ9VwjQejm/Y0As7r4Kv7gQcvNVIxnHsjq5ytgN3eC+NPJ/P4hbXagS4WNyodga+qaEJlVm5pVsA8N6iKoiXBGz/fRMrppEvMSFP+c8BS13lKpUFhqonnBNfbmmrAe8/kAjtTPduc6GYjet/psl27bnasTf0Du3dOK3nTsDuedCkMKFLlezRCFc8IjHeLGEW/uOBD2uCCTwA4GWwMAsYbI559rb0pvPtmuBz/+ew/vT7oIh6YtRoZd/T6VCXODbso+Ar8GUHsdFRrY+QIoPoLfgnchF1FXtxH7ShahRvRCagNFo0F6jeOsjYLPN9VM63lAYVSO7BxJlyw8xhQX6+eT+DYBUz6xlRyM9xewXnnJiO5wNqRqZsyvN6QpHd+1hn8hP+u+FBOXihYWSkiErRd2zCa0Q69y2YA12agIC2DIv9v6AeOj4bvOWCY4ma7hSsetHFlqrGn7H0foEqRz7cQvjp8WVZ+K5auLpCwmX2bUfXx4zc4nEzSX/5GLy63B7PXHnXusUtjlEUSVZLJMON8qhtgs1GhK0M5O+5yGg13N9Nzxb0wuviEt/iyu6wmnQ1Vr/TTG5BdxlM9g4aXCxZ3Oa/Gq+80AUxbzV0VD8lEdyriROKF6CsAgZEFVIuemtRnmsZVRm6sjfr7vE5imGhzhMH7yBJWc3LFR2VqFYhiNdYV38SxkGNdCHBhsS1GxQQtplaLfNWOeLZVpyuKc/XZpYBlpkojsEeqaYbUX0w07NsFJxtpv26p1sKhopVvZFJ5RKKTFMwYBRTPnCPr3Uq7HMy1cPBEOVilmOiKj7QlH3jsiYUo5ZLrJha4JCuYSQYm8rvPJn1N83YpdeBiFg6Q7HF6Uq0u6TOIV1Gc7Aa0xO4D654mKbjNyYOsVNIW0Lks5HA7jDA6vgClQc5rb59ZFh+6B11cYLNtlqJn2OLDNlXhSF6+LT2XuvzD2BEE6u2LMYrACIVmRYk368rJ9Ws03VLXzP8bng6TdAwsVdreLSdsUIrqehk= X-Microsoft-Exchange-Diagnostics: 1; CO2PR03MB2359; 6:DnHF6m0GqGHLw1F5yI0QYv5ATB8PMQr9qbX9DYQSL3D+3D/kl9dUdZFR15L2dDSsm5d3/qO05vtyBy5aVHCQaholMMBWFLFoddGyos9E/IvUxaK71ItmNisIyO84cH0Q1bggpB+9PP34RVANTebESmCpW8cV76QEghAN0k+s0fT4ervGeKgTYyyTK21dI30nuQwUnyJTX6Yy3jaaXP+Y/D8F+yQ3S4ZvIJ08VmPpGfAJW0RBACScoaAaWChOtGUozg4d3lhAQB+RV4x/BhqcsQ4iN6ZnO/S0F7MoiFon9tcbfFzrk9qjx+lqUDrPMUSY5oo0RuPSSuqTilN5ieAoME8lvZ2Qyakzph7b4Dr0HJA=; 5:zCnm+B2V097EWtMHLBxBA/5P+awZ1ojdQl4f+19PJZ0EUgOXtAyuLXmFFsTdcisKltQvjxcY12jYZ9rb6FPCofW4oLN54yxxlh5F9Ze28n280KGQap5p8I6BmYAqivAdRl+jAExMIWrgVRSeR26CL7Yw1iE6Y8GRdYcUIVDmGNg=; 24:cFReLHwURHzxvyfb4565WeoXHHOYSy1RD/PVrQVgZ3GcUWJ1Y5OrIC3+hkjWmzq71C0Xr2SIkhX+Q8gLM0F6uck6sXA1D0u5Pxnoj9Vv/XY=; 7:rZ4LWgQJQtKUncbxL0JPJhASN9LntH206TgVeCffOcgAJHrzpCf5PrZDmJA7K5tL0Ywr8VqD1zSvab/b8qyl7Qqcl4GhuOXaZuYEUjLottPQXMjLcCefDpKy0lWcC0gojwT2E2dj983OENeO9tEM0+6652tvX/eTSaMek9F0qevR4FjUIJ8DhfAEx3pUqbGr6jh6okLHdCsi5S326fbV1+amj9r+sVmgwAQpAam4CDL9uqhgj2cwPBA9xIi7qCiu SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2017 08:39:30.0055 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: da3d1e24-721f-4d4d-f2ad-08d52d96b834 X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO2PR03MB2359 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org From: Zhang Ying-22455 Based on the I2C specification, if the data line (SDA) is stuck low, the master should send nine clock pulses. The I2C slave device that held the bus low should release it sometime within those nine clocks. Because pinctrl is not support on Layerscape, Current bus recovery it not avalible for Layerscape. This patch use an open drain GPIO pin to connect to the IICx_SCL to drive nine clock pulses to unlock the I2C bus. Signed-off-by: Zhang Ying-22455 --- drivers/i2c/busses/i2c-imx.c | 175 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 173 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index 5df381c5f70d..ff6d0b20e0a2 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c @@ -53,6 +53,11 @@ #include #include #include +#include +#include +#include +#include +#include /* This will be the driver name the kernel reports */ #define DRIVER_NAME "imx-i2c" @@ -117,6 +122,39 @@ #define I2C_PM_TIMEOUT 10 /* ms */ +enum pinmux_endian_type { + BIG_ENDIAN, + LITTLE_ENDIAN, +}; + +struct pinmux_cfg { + enum pinmux_endian_type big_endian; /* endian of RCWPMUXCR0 */ + u32 pmuxcr_set_bit; /* pin mux of RCWPMUXCR0 */ +}; + +static struct pinmux_cfg ls1012a_pinmux_cfg = { + .big_endian = BIG_ENDIAN, + .pmuxcr_set_bit = 0x10, +}; + +static struct pinmux_cfg ls1043a_pinmux_cfg = { + .big_endian = BIG_ENDIAN, + .pmuxcr_set_bit = 0x10, +}; + +static struct pinmux_cfg ls1046a_pinmux_cfg = { + .big_endian = BIG_ENDIAN, + .pmuxcr_set_bit = 0x80000000, +}; + +static const struct of_device_id pinmux_of_match[] = { + { .compatible = "fsl,ls1012a-vf610-i2c", .data = &ls1012a_pinmux_cfg}, + { .compatible = "fsl,ls1043a-vf610-i2c", .data = &ls1043a_pinmux_cfg}, + { .compatible = "fsl,ls1046a-vf610-i2c", .data = &ls1046a_pinmux_cfg}, + {}, +}; +MODULE_DEVICE_TABLE(of, pinmux_of_match); + /* * sorted list of clock divider, register value pairs * taken from table 26-5, p.26-9, Freescale i.MX @@ -210,6 +248,12 @@ struct imx_i2c_struct { struct pinctrl_state *pinctrl_pins_gpio; struct imx_i2c_dma *dma; + int bus_recover; + int gpio; + int need_set_pmuxcr; + int pmuxcr_set; + int pmuxcr_endia; + void __iomem *pmuxcr_addr; }; static const struct imx_i2c_hwdata imx1_i2c_hwdata = { @@ -879,6 +923,78 @@ static int i2c_imx_read(struct imx_i2c_struct *i2c_imx, struct i2c_msg *msgs, bo return 0; } +/* + * Based on the I2C specification, if the data line (SDA) is + * stuck low, the master should send nine * clock pulses. + * The I2C slave device that held the bus low should release it + * sometime within * those nine clocks. Due to this erratum, + * the I2C controller cannot generate nine clock pulses. + */ +static int i2c_imx_recovery_for_layerscape(struct imx_i2c_struct *i2c_imx) +{ + u32 ulPMUXCR0 = 0; + int ret; + unsigned int i, temp; + + /* configure IICx_SCL/GPIO pin as a GPIO */ + if (i2c_imx->need_set_pmuxcr == 1) { + ulPMUXCR0 = ioread32be(i2c_imx->pmuxcr_addr); + if (i2c_imx->pmuxcr_endia == BIG_ENDIAN) + iowrite32be(i2c_imx->pmuxcr_set|ulPMUXCR0, + i2c_imx->pmuxcr_addr); + else + iowrite32(i2c_imx->pmuxcr_set|ulPMUXCR0, + i2c_imx->pmuxcr_addr); + } + + ret = gpio_request(i2c_imx->gpio, i2c_imx->adapter.name); + if (ret != 0) { + dev_err(&i2c_imx->adapter.dev, + "can't get gpio: %d\n", ret); + return ret; + } + + /* Configure GPIO pin as an output and open drain. */ + gpio_direction_output(i2c_imx->gpio, 1); + udelay(10); + + /* Write data to generate 9 pulses */ + for (i = 0; i < 9; i++) { + gpio_set_value(i2c_imx->gpio, 1); + udelay(10); + gpio_set_value(i2c_imx->gpio, 0); + udelay(10); + } + /* ensure that the last level sent is always high */ + gpio_set_value(i2c_imx->gpio, 1); + + /* + * Set I2Cx_IBCR = 0h00 to generate a STOP and then + * set I2Cx_IBCR = 0h80 to reset + */ + temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR); + temp &= ~(I2CR_MSTA | I2CR_MTX); + imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2CR); + + /* Restore the saved value of the register SCFG_RCWPMUXCR0 */ + if (i2c_imx->need_set_pmuxcr == 1) { + if (i2c_imx->pmuxcr_endia == BIG_ENDIAN) + iowrite32be(ulPMUXCR0, i2c_imx->pmuxcr_addr); + else + iowrite32(ulPMUXCR0, i2c_imx->pmuxcr_addr); + } + /* + * Set I2C_IBSR[IBAL] to clear the IBAL bit if- + * I2C_IBSR[IBAL] = 1 + */ + temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2SR); + if (temp & I2SR_IAL) { + temp &= ~I2SR_IAL; + imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2SR); + } + return 0; +} + static int i2c_imx_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, int num) { @@ -894,8 +1010,13 @@ static int i2c_imx_xfer(struct i2c_adapter *adapter, * before switching to master mode and attempting a Start cycle */ result = i2c_imx_bus_busy(i2c_imx, 0); - if (result) - goto out; + if (result) { + /* timeout */ + if ((result == -ETIMEDOUT) && (i2c_imx->bus_recover == 1)) + i2c_imx_recovery_for_layerscape(i2c_imx); + else + goto out; + } result = pm_runtime_get_sync(i2c_imx->adapter.dev.parent); if (result < 0) @@ -1039,6 +1160,51 @@ static int i2c_imx_init_recovery_info(struct imx_i2c_struct *i2c_imx, return 0; } +/* + * switch SCL and SDA to their GPIO function and do some bitbanging + * for bus recovery. + * There are platforms such as Layerscape that don't support pinctrl, so add + * workaround for layerscape, it has no effect for other platforms. + */ +static int i2c_imx_init_recovery_for_layerscape( + struct imx_i2c_struct *i2c_imx, + struct platform_device *pdev) +{ + const struct of_device_id *of_id; + struct device_node *np = pdev->dev.of_node; + struct resource *r; + struct pinmux_cfg *pinmux_cfg; + + i2c_imx->gpio = of_get_named_gpio(np, "fsl-scl-gpio", 0); + if (!gpio_is_valid(i2c_imx->gpio)) { + dev_info(&pdev->dev, "recovery information incomplete\n"); + return 0; + } + pinmux_cfg = devm_kzalloc(&pdev->dev, sizeof(*pinmux_cfg), GFP_KERNEL); + if (!pinmux_cfg) + return -ENOMEM; + + of_id = of_match_node(pinmux_of_match, np); + if (of_id) { + i2c_imx->need_set_pmuxcr = 1; + pinmux_cfg = (struct pinmux_cfg *)of_id->data; + i2c_imx->pmuxcr_endia = pinmux_cfg->big_endian; + i2c_imx->pmuxcr_set = pinmux_cfg->pmuxcr_set_bit; + r = platform_get_resource_byname(pdev, IORESOURCE_MEM, + "SCFG_RCWPMUXCR0"); + if (r) { + i2c_imx->pmuxcr_addr = devm_ioremap_resource(&pdev->dev, r); + if (IS_ERR(i2c_imx->pmuxcr_addr)) + return PTR_ERR(i2c_imx->pmuxcr_addr); + } else { + i2c_imx->need_set_pmuxcr = 0; + } + } + + i2c_imx->bus_recover = 1; + return 0; +} + static u32 i2c_imx_func(struct i2c_adapter *adapter) { return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL @@ -1094,6 +1260,11 @@ static int i2c_imx_probe(struct platform_device *pdev) i2c_imx->adapter.dev.of_node = pdev->dev.of_node; i2c_imx->base = base; + /* Init optional bus recovery for layerscape */ + ret = i2c_imx_init_recovery_for_layerscape(i2c_imx, pdev); + if (ret != 0) + return ret; + /* Get I2C clock */ i2c_imx->clk = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(i2c_imx->clk)) {