From patchwork Mon Oct 30 03:44:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 117438 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp2090580qgn; Sun, 29 Oct 2017 20:44:58 -0700 (PDT) X-Google-Smtp-Source: ABhQp+RJ8MEylf1+3PTtpqTVAuZkxqXPCO4rgPRO96JTs0jGRB+aeDhXSPgSOes8Lq+O9oaF1U1N X-Received: by 10.98.207.71 with SMTP id b68mr7365949pfg.125.1509335098327; Sun, 29 Oct 2017 20:44:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509335098; cv=none; d=google.com; s=arc-20160816; b=SiP43sEkNXXM2eVFmWXB8te4L959HyxAZJKlS4MHBDaQZ0ZT9oaoeK1JB0iYwg03mj IQNXFeGzSPymT1hIh+nfNeJFg1OMhYuU3yGVU8fWlBQe4zEuGqZYHXBUTjb69zMqRQ9L FO8jTWDm8AtE76qRnyCrNxCY5QW0jBWNHVjMpkyGdudAKiPRdwf3on9pqjQDh9MdwE5y T2YkAfGyH0YEdaFjOcdtPzknpiMQiPiHZMTc7St45PPwFLO1zBLuFhT6OBTUlLyGEyJn mCGgmwa0PiJMMY7csZfaUifHDA4JpyKyLnuGNgsusf4G0JGg4YYvSH2cSuEMpm7n4j3Q KT7w== 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=J3KhLoKJv9rpg7ZrsHT1+Y1ccl/2OaWegleypCYVqLM=; b=CJSlery2iNR0b1fbItX1qhnxmN+3p948BPqqeFiVh2MoEnXTsGK4gi4pg0mqqpgyNB 6xq0TBKkoBkUoe3hiRhNoC/lmZ5+8AU/lNpG8YYXOUwLe1ieqni/vQXGomgYpB38/2B/ tHn7Dl8c6S6dmYdrOd1RJW5b+GD0aTC6cVlQIljYLj8zjzsL1ilrpT3JwebGN5RVTRY1 kw8SDjRKs8RfPC3yiNCFAhVjmg1nrxoZZdwyE22l1Vtk3uLFsRK9CrETZScS9TmJkp2v qFgA6Y3VnmMLjNI1uImEMpLHpQdg98XIkzwzPRvj+v+yEsqk/10kUPZmaOta/Zbnf/h2 nHaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Z9jmtRtI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 r7si3229430pgf.738.2017.10.29.20.44.58; Sun, 29 Oct 2017 20:44:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=Z9jmtRtI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752239AbdJ3Do4 (ORCPT + 27 others); Sun, 29 Oct 2017 23:44:56 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:48671 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752213AbdJ3Dox (ORCPT ); Sun, 29 Oct 2017 23:44:53 -0400 Received: by mail-pg0-f67.google.com with SMTP id v78so10351476pgb.5; Sun, 29 Oct 2017 20:44:53 -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=J3KhLoKJv9rpg7ZrsHT1+Y1ccl/2OaWegleypCYVqLM=; b=Z9jmtRtISTbvzx3trZ/E8mnI67IV3oOKT/kesHxau2w/FFStQKzK9Dxxm3PATLG9VQ aPLmRfcZsLO+1ZMkr9psxnFCt+G7yq+vxEAvTg5PLVCiUSn82mlmtaP+Nm7AcxNnObOL PvSDZSLrXInMbzjbLYBJUC2u/kjvU9Gya37HdHEFD8pAnbMVMuaUL+dUmTLGoQNKPvuG QFU2A6lVHt80o9VSBko8Cab3h3w9YNPvZjqEtAhHyF417oda1BZQUm3RP5AyOXvZPO7/ 9hPpnnmo/1pxzuNCPJFgAJ17KQLgSFgxRJIwYor7Mqeh1gKgAKEvWP06RxciBUn1plJ/ Giqw== 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=J3KhLoKJv9rpg7ZrsHT1+Y1ccl/2OaWegleypCYVqLM=; b=lb4zBEw+sXDRiVGeq6pYZcZbtkEr66Neh3AnNQ72ilpzfbf4fY90cxPBvNYcnIMdZp HQRGSH77GaBvHhj708vUt6+aND0MXA+L/Fdfz9Ie6eLjUFdCocepFCShM0fjQA49689V hAQgSxlsQpQZK/Zm3iqRzC5a8oSQn0iH7L8uUWhtnN2XX1VcVLgDk1m3cCuYZomPZT23 1SbJJmQGJbORLyp6xAz7IymD9zFeAKyfgjJ7v1qr0acQeQnNKkCxakqaOxOtZN3sp60z 2qs6vAPpOIgGQXwc5r1nyPNvERwUduQKdAMNg+QK3JmqLLrH5StlrxitX/9VRC1SGpX2 36Zg== X-Gm-Message-State: AMCzsaXf2qAceYHgZD2RVVRzIMnhuNzy0IUaYx/AxA86NPOgCJ84wKqv FLjft43nhDLAlpZkpN+/13o= X-Received: by 10.99.109.75 with SMTP id i72mr6611428pgc.268.1509335093033; Sun, 29 Oct 2017 20:44:53 -0700 (PDT) Received: from aurora.jms.id.au ([203.0.153.9]) by smtp.gmail.com with ESMTPSA id d8sm26311935pfh.178.2017.10.29.20.44.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 29 Oct 2017 20:44:51 -0700 (PDT) Received: by aurora.jms.id.au (sSMTP sendmail emulation); Mon, 30 Oct 2017 14:14:45 +1030 From: Joel Stanley To: Wolfram Sang Cc: Brendan Higgins , Philipp Zabel , Benjamin Herrenschmidt , Andrew Jeffery , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3] i2c: aspeed: Deassert reset in probe Date: Mon, 30 Oct 2017 14:14:38 +1030 Message-Id: <20171030034438.26482-1-joel@jms.id.au> X-Mailer: git-send-email 2.14.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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. Reviewed-by: Brendan Higgins Reviewed-by: Philipp Zabel Signed-off-by: Joel Stanley --- v3: Check for bad reset controller probe (caused by eg. bad device tree) and set ->rst to NULL so assert/desassert does not cause a warning to be printed v2: Sort the headers --- drivers/i2c/busses/i2c-aspeed.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) -- 2.14.1 diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c index 284f8670dbeb..5dec00d663eb 100644 --- a/drivers/i2c/busses/i2c-aspeed.c +++ b/drivers/i2c/busses/i2c-aspeed.c @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -27,6 +28,7 @@ #include #include #include +#include #include /* I2C Register */ @@ -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,13 @@ 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); + if (IS_ERR(bus->rst)) { + dev_err(&pdev->dev, "invalid reset controller in device tree"); + bus->rst = NULL; + } else + reset_control_deassert(bus->rst); + ret = of_property_read_u32(pdev->dev.of_node, "bus-frequency", &bus->bus_frequency); if (ret < 0) { @@ -919,6 +929,8 @@ static int aspeed_i2c_remove_bus(struct platform_device *pdev) i2c_del_adapter(&bus->adap); + reset_control_assert(bus->rst); + return 0; }