From patchwork Fri Mar 6 17:21:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 184287 Delivered-To: patches@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp7667174ile; Fri, 6 Mar 2020 09:21:19 -0800 (PST) X-Received: by 2002:a17:902:b404:: with SMTP id x4mr4100185plr.80.1583515279497; Fri, 06 Mar 2020 09:21:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583515279; cv=none; d=google.com; s=arc-20160816; b=jpGFDDeqOZZlEyy/R2+60qGjrb/AJfDuwe1Do7NLvUnMDSUarmAdhtQITQYHQTdDmX 7qp/IW+GAiq+hbQQcrmCDQdju4sfr1pit0kwWWhV48yWKYBvYD/EvtsSOOosFXurzXGM 7AvC6l9/C3ZRUx5TMSHGM4up53wo1EZUSczJLKxKq+OPebqqqCEylXFI2hBYJf6VLOxK xPgePKICeDHatG726htB7GGR19L7nbmtZt0Jdmr0muuVYFfahncVK+9ZO89t6BypHUqu IWJybZsnA5Ym1KLjJaSa1uQF+ZWVjkaPqJNRvC7EmgSBIdNbyCAkh2VC8ZI0/MUA+aoa GONA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature; bh=ZCslXV7+BYNwc16oI1VHhg6O3Q9jB+EK4lVW99vpz8A=; b=0dpG9zp5o2uETcEyy0HUNv/UAHBIq4JzFTXZvqzo5pRqQQz+tAbvoJcXrVkYD3N8Md y311wcArdrhBHbgWhU/ofhq95Evu5e8V8SjL2gvDaXs1GnTvUAEx5yEukDcc1h3FVXN8 +pMHqlJ5gR6MJx9eTLn9pA/7cj2eqDaxO4Hrv2MaoQclRVCXjqWh+uQ9gPuHrPSic/TA 6AtqPjZoNKiSrwwTi6eyVo+kbGW3KAuMCHTumbs51Q1rzAav8Z6vR6Ki9bcyF2ac/3xg ulRixnadRWyhQ8JwicPKF8YDSTh81YgWiJFSre+/skjLOiKMpgbav5K80J5yAkOuWu9h E52g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tLiimlWZ; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id z23sor3390162plo.48.2020.03.06.09.21.19 for (Google Transport Security); Fri, 06 Mar 2020 09:21:19 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tLiimlWZ; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=ZCslXV7+BYNwc16oI1VHhg6O3Q9jB+EK4lVW99vpz8A=; b=tLiimlWZypLzW+H9Kkg20KNLErAOSyI8M6Exl4NgiZ8El8PMltlSPN5E95HHHxKgL5 okf2t5tC3kDKwAZCojVrWeZTrtZ896CZIyKHeDuIxTxRu6JRzCCUkefu97O0fZ4P8PSB rZya3kschpxwcwfWImQ+GxrlkwyUCAyPmKfn5obLROrFtbFTE786KMG4MIab6eOl4tGO 0ZgBGyDoDiQN3xiIeHSKU7xIoTZtpYLtEKVzerkyyIt2TMYuZ5JMaDsNgz4xGoDHzILm bbuGmCsEcmrHozIekbU3aG8yCkr5GAEB7siX4hrSj62WASLbm4X2Laqv6guk/zrRevD9 7G7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ZCslXV7+BYNwc16oI1VHhg6O3Q9jB+EK4lVW99vpz8A=; b=WOHTn11djEbf+ERDJaS20ifv5M+zFg4xaPqjhIa14M5E0qNhl58gHgihAKd+urDJQR lxEMX27CEkZ5EUDuXszmF8z/ItALKh4pyYF2BOs3CqH1gMYPN1nUaQ+7iIrRlxHbM1ry yxD5t1tgXIsmmMvrgvRd+iDcRMFS/vQQu/06xmDdMyWSdcYZYKEEHVKGT2gZpuM9cPMu 4GQPY4ao0FPFZZ0wbX8nlbj43GbveERZPBhif9eocrgSDEXn6LoDqHM6Xk7hUKowz2db f0r0HN9L8IqnEG88/n1pXF/6fdHZ5VhqKei3Lq9gMZSckTWqqoRpRntXTopc4ou3F1wo P1tw== X-Gm-Message-State: ANhLgQ2Pqcvc5tt0NdH4Y8uyLNAZaVVlPxJEbt6blEYykGay3F8lS19E ormhNm31By5VbFc6YumXcMyyjLofRFuS4w== X-Google-Smtp-Source: ADFU+vvqp7tpD24ATuMs8NWAlMf5JlfX9cjLBq6me/SQRkgMh1asrJUC2dtdLV6SGav3wK81WYUpuQ== X-Received: by 2002:a17:902:9a42:: with SMTP id x2mr4227371plv.194.1583515279031; Fri, 06 Mar 2020 09:21:19 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id mp5sm9956189pjb.48.2020.03.06.09.21.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2020 09:21:18 -0800 (PST) From: John Stultz To: lkml Cc: Peter Griffin , Philipp Zabel , Enrico Weigelt , John Stultz Subject: [PATCH v3] reset: hi6220: Add support for AO reset controller Date: Fri, 6 Mar 2020 17:21:13 +0000 Message-Id: <20200306172113.50738-1-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 From: Peter Griffin This is required to bring Mali450 gpu out of reset. Cc: Philipp Zabel Cc: Peter Griffin Cc: Enrico Weigelt Signed-off-by: Peter Griffin [jstultz: Added comment, Fix void return build issue Reported-by: kbuild test robot ] Signed-off-by: John Stultz --- v2: * Updated to v2 of Peter's patch from here: https://lkml.org/lkml/2019/4/19/253 * Added a comment to explain ordering question brought up on the list. v3: * Fix build issue Reported-by: kbuild test robot --- drivers/reset/hisilicon/hi6220_reset.c | 69 +++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/drivers/reset/hisilicon/hi6220_reset.c b/drivers/reset/hisilicon/hi6220_reset.c index 24e6d420b26b..19926506d033 100644 --- a/drivers/reset/hisilicon/hi6220_reset.c +++ b/drivers/reset/hisilicon/hi6220_reset.c @@ -33,6 +33,7 @@ enum hi6220_reset_ctrl_type { PERIPHERAL, MEDIA, + AO, }; struct hi6220_reset_data { @@ -92,6 +93,65 @@ static const struct reset_control_ops hi6220_media_reset_ops = { .deassert = hi6220_media_deassert, }; +#define AO_SCTRL_SC_PW_CLKEN0 0x800 +#define AO_SCTRL_SC_PW_CLKDIS0 0x804 + +#define AO_SCTRL_SC_PW_RSTEN0 0x810 +#define AO_SCTRL_SC_PW_RSTDIS0 0x814 + +#define AO_SCTRL_SC_PW_ISOEN0 0x820 +#define AO_SCTRL_SC_PW_ISODIS0 0x824 +#define AO_MAX_INDEX 12 + +static int hi6220_ao_assert(struct reset_controller_dev *rc_dev, + unsigned long idx) +{ + struct hi6220_reset_data *data = to_reset_data(rc_dev); + struct regmap *regmap = data->regmap; + int ret; + + ret = regmap_write(regmap, AO_SCTRL_SC_PW_RSTEN0, BIT(idx)); + if (ret) + return ret; + + ret = regmap_write(regmap, AO_SCTRL_SC_PW_ISOEN0, BIT(idx)); + if (ret) + return ret; + + ret = regmap_write(regmap, AO_SCTRL_SC_PW_CLKDIS0, BIT(idx)); + return ret; +} + +static int hi6220_ao_deassert(struct reset_controller_dev *rc_dev, + unsigned long idx) +{ + struct hi6220_reset_data *data = to_reset_data(rc_dev); + struct regmap *regmap = data->regmap; + int ret; + + /* + * It was suggested to disable isolation before enabling + * the clocks and deasserting reset, to avoid glitches. + * But this order is preserved to keep it matching the + * vendor code. + */ + ret = regmap_write(regmap, AO_SCTRL_SC_PW_RSTDIS0, BIT(idx)); + if (ret) + return ret; + + ret = regmap_write(regmap, AO_SCTRL_SC_PW_ISODIS0, BIT(idx)); + if (ret) + return ret; + + ret = regmap_write(regmap, AO_SCTRL_SC_PW_CLKEN0, BIT(idx)); + return ret; +} + +static const struct reset_control_ops hi6220_ao_reset_ops = { + .assert = hi6220_ao_assert, + .deassert = hi6220_ao_deassert, +}; + static int hi6220_reset_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; @@ -117,9 +177,12 @@ static int hi6220_reset_probe(struct platform_device *pdev) if (type == MEDIA) { data->rc_dev.ops = &hi6220_media_reset_ops; data->rc_dev.nr_resets = MEDIA_MAX_INDEX; - } else { + } else if (type == PERIPHERAL) { data->rc_dev.ops = &hi6220_peripheral_reset_ops; data->rc_dev.nr_resets = PERIPH_MAX_INDEX; + } else { + data->rc_dev.ops = &hi6220_ao_reset_ops; + data->rc_dev.nr_resets = AO_MAX_INDEX; } return reset_controller_register(&data->rc_dev); @@ -134,6 +197,10 @@ static const struct of_device_id hi6220_reset_match[] = { .compatible = "hisilicon,hi6220-mediactrl", .data = (void *)MEDIA, }, + { + .compatible = "hisilicon,hi6220-aoctrl", + .data = (void *)AO, + }, { /* sentinel */ }, }; MODULE_DEVICE_TABLE(of, hi6220_reset_match);