From patchwork Mon Mar 2 17:40:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 184093 Delivered-To: patches@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp2664392ile; Mon, 2 Mar 2020 09:40:22 -0800 (PST) X-Received: by 2002:a17:902:8eca:: with SMTP id x10mr310646plo.94.1583170822570; Mon, 02 Mar 2020 09:40:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583170822; cv=none; d=google.com; s=arc-20160816; b=q3516it1yIvY0D9WSnyOJ8V/M3lYZh+EVYzETEPMl8LcTEcpVjRi1pC9rFPpX4wGkO kT0Po3qiy6hZusHtd+b+UnisWJLYJUJZD9ekNg8Y6yCHMn0x40BTXLsogwR7zDB4NFhL W0h+kMkJ1AvsmM75bE/7lFFhTHlYJ70jXiCyR04espLlWYuKJIvUd8O3GsFWzV03U/7P CCEZRxb5ZbMSVaZ7QP5i05rKsRCOprJMj+6gF/jloFVY5l8/YPU7glDMER3Y/ZW40oz/ Umzi23bueOjtHuf2o/pNwXmh3gYXlkyWXHGkI12cjMchedgBXS9OA6fGeWOILtVdWsl2 Hwyg== 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=Mimd8L0KkuEU3z0SotImD5hnuEckWKEuDddwOjBPweo=; b=NJbvYIi1PSa4j8Du9Jt77PFpFx3bFpBkVpRZbKg/r3U/NQdoWKybDF95yr0I7xQumC BPXcjRtTaQXyI0G7ypwJ4mKfgb19gAjM211QFO/kmJxiKMLeX9+O5tUIaQGdhbAPeD/u U001Zp5DPxHd75I0gw8i0TaeTjhPPRdTu9jw7Uk2uenkolFAp+knW0xZf0Utrp9yIY6n yVFiqM5XlnNAwFRWh7mCzdgAY/Fw5Pb2rKktvbDsTAfAEzrRp9SjXTpL/2AsoLb2VnY9 fTqUvFIDU2cC1Mo4qDAVyjkdrW26UQKGCAItD1cmUqNQ2U/VN1kGtfToJ5fklJQisCjO gjCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FA0toS2T; 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 z2sor170277pjt.6.2020.03.02.09.40.22 for (Google Transport Security); Mon, 02 Mar 2020 09:40:22 -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=FA0toS2T; 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=Mimd8L0KkuEU3z0SotImD5hnuEckWKEuDddwOjBPweo=; b=FA0toS2TJ35J4SYiSuP9vUMDFMhFen/aWgOBpH1DNn0wPewzhpyYK9wYqc0nliBdhh QvvhQf5kdDrdDCoD9sDN7up5hR9MxhopeBEZUdHD7Cp/EM0BshYO0MtNG4ufKsbT1bdQ 2wX8HnXHdPY5T9ZM8DO4386+uwLh6JrGQ8ZpqHQNBUdhexlEOzdtqsy/ChMzUcTbg+zE MlYQoer3Gnx2r5msXaN2SXxxgRIX6lWGwE4j4IOu7uKTGaSDgzOxCR73RwqXYSUSo+EV oGdNfAteZf2MxUIaE5asCzGWdkZOrSoX4gwpuXFn/wCVY+ecGGzk31Qsf6LkHDOFHxeB zEhQ== 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=Mimd8L0KkuEU3z0SotImD5hnuEckWKEuDddwOjBPweo=; b=VyznAcBnnXmJ2eVkv+I+RQhWIUSSn3geRK+N7ys9upxLM6W0F78+Qj9UffMl4psDTK hTS6Bk+z85x4xdGCs9tpIe/OO9uFTR/HvzI1vdSX8GLbBMYNTfkwNmlZ87ZOX7OxEHxS aonU2KALjjukDSGf7rsJ7hopgvhdHwa4HZPS7I2R62XVYx3KqB185YMA5b56bW6JQ9DZ CGiMJJMCiW3imRpiyWRLcIJNAGDxl1MTSsyscoehINdJ2M2lYwxOYkDSRhltYO19Dd4y ij9Z8zU0CGKAdxo+2VyQSn/toj7Oh2Z5JNb8F0uy+DTZHnurhI8IbrgZeITn5BNKczeS DsfA== X-Gm-Message-State: ANhLgQ1aD5MeW/A9QOW2cLQEA512c3dzJATEECj2qKzUqxPMA2AY8QhN G5ICTwvMwdvbiKGw4DE3nyGJuegW X-Google-Smtp-Source: ADFU+vtRSmzvVppFbky+IP0O5uIEaF2zwuYdCebEmTKJg+sSXwxFIwVfettFZlUJXjbAjb5qNYD67Q== X-Received: by 2002:a17:90a:3364:: with SMTP id m91mr48721pjb.112.1583170822136; Mon, 02 Mar 2020 09:40:22 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id k24sm20738947pgf.59.2020.03.02.09.40.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Mar 2020 09:40:21 -0800 (PST) From: John Stultz To: lkml Cc: Peter Griffin , Philipp Zabel , Enrico Weigelt , John Stultz Subject: [PATCH v2] reset: hi6220: Add support for AO reset controller Date: Mon, 2 Mar 2020 17:40:15 +0000 Message-Id: <20200302174015.52363-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 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. --- drivers/reset/hisilicon/hi6220_reset.c | 71 +++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/drivers/reset/hisilicon/hi6220_reset.c b/drivers/reset/hisilicon/hi6220_reset.c index 24e6d420b26b..a85ed276ab83 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,67 @@ 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)); + if (ret) + 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)); + if (ret) + 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 +179,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 +199,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);