From patchwork Thu Aug 18 10:10:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 9287373 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C7EEC607FF for ; Thu, 18 Aug 2016 10:51:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B96F728A31 for ; Thu, 18 Aug 2016 10:51:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AE29128A32; Thu, 18 Aug 2016 10:51:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8AFC628D68 for ; Thu, 18 Aug 2016 10:51:41 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1baKv8-0002wO-Gg; Thu, 18 Aug 2016 10:51:34 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1baKt1-0000E3-FX for linux-amlogic@bombadil.infradead.org; Thu, 18 Aug 2016 10:49:23 +0000 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]) by merlin.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1baKIc-0000Ih-Hd for linux-amlogic@lists.infradead.org; Thu, 18 Aug 2016 10:11:46 +0000 Received: by mail-wm0-x22d.google.com with SMTP id q128so235266806wma.1 for ; Thu, 18 Aug 2016 03:11:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=spCrnNGzrORXozVD4MBnuwTPSzb93vmTC1g98J5WIp0=; b=Y7OJGjhP7aNW8aVUK1WhDaLxR6zFkDgP3mCLm2n0JqIEyOOPpvASX0kCEHpyu55Zbg X0rGJ7wu810VyXk0fbkjpUv1tH0rHgzltWb4Tnl+eOlqkZeC70zPwvUJ8rXwvvZJy0gJ OIkCo/qtbAjJL1XKgnwapruagiy9yDddPrEkypA+zo2cawor1Ol6As7862EOhen30bC7 +5sVYU3jToP5MohqjNk5kkRhOU9yRuIpz9VWzaoYg6yDYl9+E822ldatKb+dhHdLOQVq NYzgKaudQ3u8mxEH3hRplYLXEtPR/mMcJY4M7TsBaJf74/n4CYcdE+Wo2uGWyaM7bp/r dDNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=spCrnNGzrORXozVD4MBnuwTPSzb93vmTC1g98J5WIp0=; b=RZBLYGof59w6Er9AQq4J7fJSXJbCjykFpYf8KZ62dQPVnxlUwlQCr1YPaYqbuCRfkl lKDqbeOrRG0Lx7aRfml6NoWGrZ2M75tja5eZJ0kIn0liADZBhz0yMiFzL0yDeN0+iyfS 73J1FUfsFg+zGyK1X2zXQwGy5QCVuT4u0QV9ZA8mlGrSmJxUaPDSyu6h0lEZeKUfqGn4 bPO1OHj3AEQZR7aT/yYhPtliwTiuOepVf82IzaS31+t1uv2II0UD1u3BHP1Hjqbbz7XZ xZL0+mbL+npcYERNAAJzAiUyS0/WyLEt790XjUe7JoKMj54tnj1u0RMG5Ub+/BCyJG/j dttw== X-Gm-Message-State: AEkoouuMuJrhM3Cc5kGehsOjhS8MGUCc5bnjEeiAX3pDUH6+6xLj5ahaFdS7/YiUSxHl8LLT X-Received: by 10.194.42.202 with SMTP id q10mr1365003wjl.190.1471515084565; Thu, 18 Aug 2016 03:11:24 -0700 (PDT) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id f4sm30915247wmf.8.2016.08.18.03.11.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Aug 2016 03:11:24 -0700 (PDT) From: Neil Armstrong To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, sudeep.holla@arm.com Subject: [PATCH 04/13] scpi: Add legacy SCP functions calling legacy_scpi_send_message Date: Thu, 18 Aug 2016 12:10:57 +0200 Message-Id: <1471515066-3626-5-git-send-email-narmstrong@baylibre.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1471515066-3626-1-git-send-email-narmstrong@baylibre.com> References: <1471515066-3626-1-git-send-email-narmstrong@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160818_061146_716615_07A2C294 X-CRM114-Status: GOOD ( 13.11 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: heiko@sntech.de, Neil Armstrong , frank.wang@rock-chips.com, khilman@baylibre.com, linux-amlogic@lists.infradead.org, wxt@rock-chips.com MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP In order to support legacy SCP functions from kernel-wide driver, add legacy functions using the legacy command enums and calling legacy_scpi_send_message. Signed-off-by: Neil Armstrong --- drivers/firmware/arm_scpi.c | 118 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) diff --git a/drivers/firmware/arm_scpi.c b/drivers/firmware/arm_scpi.c index 50b1297..bb9965f 100644 --- a/drivers/firmware/arm_scpi.c +++ b/drivers/firmware/arm_scpi.c @@ -578,6 +578,8 @@ scpi_clk_get_range(u16 clk_id, unsigned long *min, unsigned long *max) return ret; } +/* scpi_clk_get_range not available for legacy */ + static unsigned long scpi_clk_get_val(u16 clk_id) { int ret; @@ -589,6 +591,18 @@ static unsigned long scpi_clk_get_val(u16 clk_id) return ret ? ret : le32_to_cpu(clk.rate); } +static unsigned long legacy_scpi_clk_get_val(u16 clk_id) +{ + int ret; + struct clk_get_value clk; + __le16 le_clk_id = cpu_to_le16(clk_id); + + ret = legacy_scpi_send_message(LEGACY_SCPI_CMD_GET_CLOCK_VALUE, + &le_clk_id, sizeof(le_clk_id), + &clk, sizeof(clk)); + return ret ? ret : le32_to_cpu(clk.rate); +} + static int scpi_clk_set_val(u16 clk_id, unsigned long rate) { int stat; @@ -601,6 +615,19 @@ static int scpi_clk_set_val(u16 clk_id, unsigned long rate) &stat, sizeof(stat)); } +static int legacy_scpi_clk_set_val(u16 clk_id, unsigned long rate) +{ + int stat; + struct legacy_clk_set_value clk = { + .id = cpu_to_le16(clk_id), + .rate = cpu_to_le32(rate) + }; + + return legacy_scpi_send_message(LEGACY_SCPI_CMD_SET_CLOCK_VALUE, + &clk, sizeof(clk), + &stat, sizeof(stat)); +} + static int scpi_dvfs_get_idx(u8 domain) { int ret; @@ -611,6 +638,17 @@ static int scpi_dvfs_get_idx(u8 domain) return ret ? ret : dvfs_idx; } +static int legacy_scpi_dvfs_get_idx(u8 domain) +{ + int ret; + u8 dvfs_idx; + + ret = legacy_scpi_send_message(LEGACY_SCPI_CMD_GET_DVFS, + &domain, sizeof(domain), + &dvfs_idx, sizeof(dvfs_idx)); + return ret ? ret : dvfs_idx; +} + static int scpi_dvfs_set_idx(u8 domain, u8 index) { int stat; @@ -620,6 +658,16 @@ static int scpi_dvfs_set_idx(u8 domain, u8 index) &stat, sizeof(stat)); } +static int legacy_scpi_dvfs_set_idx(u8 domain, u8 index) +{ + int stat; + struct dvfs_set dvfs = {domain, index}; + + return legacy_scpi_send_message(LEGACY_SCPI_CMD_SET_DVFS, + &dvfs, sizeof(dvfs), + &stat, sizeof(stat)); +} + static int opp_cmp_func(const void *opp1, const void *opp2) { const struct scpi_opp *t1 = opp1, *t2 = opp2; @@ -627,6 +675,13 @@ static int opp_cmp_func(const void *opp1, const void *opp2) return t1->freq - t2->freq; } +static int legacy_scpi_dvfs_get_info(u8 domain, struct dvfs_info *buf) +{ + return legacy_scpi_send_message(LEGACY_SCPI_CMD_GET_DVFS_INFO, + &domain, sizeof(domain), + buf, sizeof(*buf)); +} + static struct scpi_dvfs_info *scpi_dvfs_get_info(u8 domain) { struct scpi_dvfs_info *info; @@ -683,6 +738,20 @@ static int scpi_sensor_get_capability(u16 *sensors) return ret; } +static int legacy_scpi_sensor_get_capability(u16 *sensors) +{ + struct sensor_capabilities cap_buf; + int ret; + + ret = legacy_scpi_send_message(LEGACY_SCPI_CMD_SENSOR_CAPABILITIES, + NULL, 0, + &cap_buf, sizeof(cap_buf)); + if (!ret) + *sensors = le16_to_cpu(cap_buf.sensors); + + return ret; +} + static int scpi_sensor_get_info(u16 sensor_id, struct scpi_sensor_info *info) { __le16 id = cpu_to_le16(sensor_id); @@ -699,6 +768,24 @@ static int scpi_sensor_get_info(u16 sensor_id, struct scpi_sensor_info *info) return ret; } +static int legacy_scpi_sensor_get_info(u16 sensor_id, + struct scpi_sensor_info *info) +{ + __le16 id = cpu_to_le16(sensor_id); + struct _scpi_sensor_info _info; + int ret; + + ret = legacy_scpi_send_message(LEGACY_SCPI_CMD_SENSOR_INFO, + &id, sizeof(id), + &_info, sizeof(_info)); + if (!ret) { + memcpy(info, &_info, sizeof(*info)); + info->sensor_id = le16_to_cpu(_info.sensor_id); + } + + return ret; +} + static int scpi_sensor_get_value(u16 sensor, u64 *val) { __le16 id = cpu_to_le16(sensor); @@ -714,6 +801,21 @@ static int scpi_sensor_get_value(u16 sensor, u64 *val) return ret; } +static int legacy_scpi_sensor_get_value(u16 sensor, u64 *val) +{ + __le16 id = cpu_to_le16(sensor); + struct legacy_sensor_value buf; + int ret; + + ret = legacy_scpi_send_message(LEGACY_SCPI_CMD_SENSOR_VALUE, + &id, sizeof(id), + &buf, sizeof(buf)); + if (!ret) + *val = (u64)le32_to_cpu(buf.val); + + return ret; +} + static int scpi_device_get_power_state(u16 dev_id) { int ret; @@ -773,6 +875,22 @@ static int scpi_init_versions(struct scpi_drvinfo *info) return ret; } +static int legacy_scpi_init_versions(struct scpi_drvinfo *info) +{ + int ret; + struct scp_capabilities caps; + + ret = legacy_scpi_send_message(LEGACY_SCPI_CMD_SCPI_CAPABILITIES, + NULL, 0, + &caps, sizeof(caps)); + if (!ret) { + info->protocol_version = le32_to_cpu(caps.protocol_version); + info->firmware_version = le32_to_cpu(caps.platform_version); + } + + return ret; +} + static ssize_t protocol_version_show(struct device *dev, struct device_attribute *attr, char *buf) {