From patchwork Tue Oct 10 04:48:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 115332 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3321615qgn; Mon, 9 Oct 2017 21:48:48 -0700 (PDT) X-Received: by 10.84.240.204 with SMTP id l12mr10958029plt.360.1507610928626; Mon, 09 Oct 2017 21:48:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507610928; cv=none; d=google.com; s=arc-20160816; b=yZczY0jkU05wsfX1g/B/7rM77ukXAs8WG5Sdg5zQL9kRHL5xPKNNDBnu3oKEybYZXQ +6ekhCDnt1s9wsqSS2cQ8XF6NNAdc41FBLk7IGBLE+KtDZ5/8QJDKkZnamxTWhqt4bVT tzQfUJ+DPc+/Nb1ykThOAoB73mLZnNqqY5HoIRFoV610CnVLx4eBTQzoZh/wfz8ng+cF B7NpUNoGPWbnFZ+7yZTmHiCfimIPtYNuRsGVxn9M0/+D9VR+OLhF4EFNXkgqw3jMBKuT bBWl3g1XKACvzVjNhoOZAOdKBaq493m7e9hc6IqohuhA8BK88YlnBV0rbjqoo86HNB3r 0f9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=8ZMdgB63Sluy1pW3whCxPWBVkvIQGZikSBsT5KWdMwE=; b=jF7UFSsY+NrN8oT7+m5aPPrAJSEAU2HYk0ZuiFLGxtSIrr/gDsTtaTK3x9d6ijrgTT jtIVTSQdgjTQi8QAuzUwbpzkXmDMg2WFm+5nmGBlz9veBnpNACSskWxOFBzhwjES+gx3 Ha/e657MXe/D6qw/ZfHGwM4AZQDrQthEY7EUkjJPtfdpxo4Alae9iyEZs7BeWrr/XUyC WuC8wbvq2MXyk6IRb4MqG+tVRPXI61uO/xEKPA9OFCOfszoLuifcWN09ipitYzocCtCw KRILKM9dIDpsZYc8aHQYZaB5H31Ax2FICrMLPNQ5KnEHx/12y096AbaFwsz3BAAIXpVL AtVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=tBGTQ53Y; spf=pass (google.com: best guess record for domain of linux-i2c-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-i2c-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k6si7439798pgt.280.2017.10.09.21.48.48; Mon, 09 Oct 2017 21:48: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; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=tBGTQ53Y; spf=pass (google.com: best guess record for domain of linux-i2c-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-i2c-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750950AbdJJEsq (ORCPT + 3 others); Tue, 10 Oct 2017 00:48:46 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:34787 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750734AbdJJEsp (ORCPT ); Tue, 10 Oct 2017 00:48:45 -0400 Received: by mail-pf0-f195.google.com with SMTP id b85so12371938pfj.1; Mon, 09 Oct 2017 21:48:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=8ZMdgB63Sluy1pW3whCxPWBVkvIQGZikSBsT5KWdMwE=; b=tBGTQ53YMUJWwkyvCk8qPizjtLI45vRq92vB1NA1bhtk/ILDwAN86p8c9AF0YWwEO0 JY0VwtZHOG5FiHXnsLDHvvulp+Cq5EmSYD6NFFGpZdyJYUmawi2YlFAoMbRIrec940jt bsXG1A5QCQqgGCJIw77IdRxOxe9RuH0C2LZfhU+W2hFC2ZBhZVL6M+/vfFx6SkuWffOV RQyOOYph0zI/VfNFKVBNrcejiCy9JV/MmBfNT2o6drJl8aP89Bd252L2s+Hx1HoIzb1y 4i8TI2rn6y+85sOXxnBADPZ++T47AcT3WIiAyaRdZLDQINj5XL0L1JPRwCU30mWBYdLR VZKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=8ZMdgB63Sluy1pW3whCxPWBVkvIQGZikSBsT5KWdMwE=; b=OvcMDIbM92jOxlzhD9jfFfIcfq/RVn/4P9x7JaASQpBd8ENeoE4HnZ6tjt5XQh2xvS I0nnzZthxZRb8XWc1vIVLT02quyZN+P27BhgHxQ5bE77LFcIvaV7jYf16myPLdJGdu5i JD0sh4QxU6HeiXNDNA5juPtF3P/iZSsUAWt/7iuKbkRRt5r0vjuBA+zVX7f4PHy2dlVD uy82dTuiQSgSSYIaGeL78OVnpPTz6LkGnDXfbE5MG6uDox+iJYfm+g/FWFyDqxcqpGHm pVz3m9Sebnyf/ZoaSvUhcZLLBzXF7VU3lGjjrAS+xRhWPzvGumOWHIpX/9i7Pdv6Sg+D y+2A== X-Gm-Message-State: AMCzsaWSvAiM+nWP1rGzyF7kQxwTzI8bYsu6c5oCS5GE08kS5wsos716 gFBJNTXiVNKiJzdbB9SVoeNybCCXIDE= X-Google-Smtp-Source: AOwi7QA4sF1G1SVwA4H675UILSzKju8qsbwh2TKyJXCtpxqo0GlRyOV2vKqi2D41l3fqP2XFh1DpNw== X-Received: by 10.101.76.139 with SMTP id m11mr11286688pgt.103.1507610924286; Mon, 09 Oct 2017 21:48:44 -0700 (PDT) Received: from aurora.jms.id.au ([203.0.153.9]) by smtp.gmail.com with ESMTPSA id d74sm574211pfe.167.2017.10.09.21.48.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Oct 2017 21:48:42 -0700 (PDT) Received: by aurora.jms.id.au (sSMTP sendmail emulation); Tue, 10 Oct 2017 15:18:33 +1030 From: Joel Stanley To: Wolfram Sang Cc: Brendan Higgins , Benjamin Herrenschmidt , Andrew Jeffery , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] i2c: aspeed: Deassert reset in probe Date: Tue, 10 Oct 2017 15:18:28 +1030 Message-Id: <20171010044828.20913-1-joel@jms.id.au> X-Mailer: git-send-email 2.14.1 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org In order to use i2c from a cold boot, the i2c peripheral must be taken out of reset. We request a shared reset controller each time a bus driver is loaded, as the reset is shared between the 14 i2c buses. On remove the reset is asserted, which only touches the hardware once the last i2c bus is removed. The request is optional, so if a device tree does not specify a reset controller (or the driver is not built in), the driver continues to probe. Signed-off-by: Joel Stanley --- drivers/i2c/busses/i2c-aspeed.c | 8 ++++++++ 1 file changed, 8 insertions(+) -- 2.14.1 diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c index 284f8670dbeb..ad06f902f90f 100644 --- a/drivers/i2c/busses/i2c-aspeed.c +++ b/drivers/i2c/busses/i2c-aspeed.c @@ -28,6 +28,8 @@ #include #include #include +#include +#include /* I2C Register */ #define ASPEED_I2C_FUN_CTRL_REG 0x00 @@ -132,6 +134,7 @@ struct aspeed_i2c_bus { struct i2c_adapter adap; struct device *dev; void __iomem *base; + struct reset_control *rst; /* Synchronizes I/O mem access to base. */ spinlock_t lock; struct completion cmd_complete; @@ -847,6 +850,9 @@ static int aspeed_i2c_probe_bus(struct platform_device *pdev) /* We just need the clock rate, we don't actually use the clk object. */ devm_clk_put(&pdev->dev, parent_clk); + bus->rst = devm_reset_control_get_optional_shared(&pdev->dev, NULL); + reset_control_deassert(bus->rst); + ret = of_property_read_u32(pdev->dev.of_node, "bus-frequency", &bus->bus_frequency); if (ret < 0) { @@ -919,6 +925,8 @@ static int aspeed_i2c_remove_bus(struct platform_device *pdev) i2c_del_adapter(&bus->adap); + reset_control_assert(bus->rst); + return 0; }