From patchwork Wed May 23 05:20:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 136615 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp449742lji; Tue, 22 May 2018 22:21:09 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq3mjd3PfZwr43+7Vekj0IA8ua+o4YUn+Yo/EEFazh0nDT4wQH3lMDsJW1m3GaNfQDOVleO X-Received: by 2002:a63:b046:: with SMTP id z6-v6mr1131851pgo.16.1527052869562; Tue, 22 May 2018 22:21:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527052869; cv=none; d=google.com; s=arc-20160816; b=u4Ecesk2+9gWr7HaJkkJUkd8CRgsz2KyP3+X5IlzClt83h6+A6m120iANoLzguhfdW +9PmVH95PHsdKzN/kFwIdFLdJtEoLI2EJXrnOIjw7SQ3rUivPWeoYkmB7q6t0L5lNuDU pbT2vypzUpkPdfLLrhf5Y9fH0SannyNWb53LNag/wWzkwZi6yPpA7S+F0LolO3iZ6oIq eMR5KQNnwCy5lLoU0a/Ii948j4VahbyDEpDqL658+aI0DparSZ8CC3rF2gD8cDTLsNUs IwjdkbJk/KxqLghtDbgzSl3QY8yBOsz6LorSXQcAJNFxWPIJTN8Qtya6K/S0O2VFesfY t8bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=mMuZ30ydMlpAKJdnZzJGRRao+UNlvkY24uRwi/xCojY=; b=gouRQ3lC3WMTS1/fFW14he9t63er7nanAkwOTiEOXrDtWlZdYoHl4wZ80kGT2OHMiW 7rwq9LnpaygJqO1sXGZ6d6CHYsl+zaWXsBCb7W7PLAfBwYrK9IWEicBDQureghkYLNTS znLlqNqnxXKXt5vcglump+Xmx0ureHfdFxnKTSLIHn3p9lj9MN6fp12/TdNCJjUmlcSm xv/lqJHfWTVerTMU7ylW75jST1V95ZMbfziRHr7OkrVKDWdnoWmEk+H0trDJS1F0QptR kbxayoDce/WqApLaHE1gyqYoVUxuJL8hyv36w5XGZWMnxUNK84y8Dq+sibO8FsFSh4p9 HywQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZUVDLQft; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e125-v6si17937518pfg.112.2018.05.22.22.21.09; Tue, 22 May 2018 22:21:09 -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=pass header.i=@linaro.org header.s=google header.b=ZUVDLQft; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754111AbeEWFVH (ORCPT + 30 others); Wed, 23 May 2018 01:21:07 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:40240 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754072AbeEWFVA (ORCPT ); Wed, 23 May 2018 01:21:00 -0400 Received: by mail-pf0-f196.google.com with SMTP id f189-v6so9893860pfa.7 for ; Tue, 22 May 2018 22:20:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mMuZ30ydMlpAKJdnZzJGRRao+UNlvkY24uRwi/xCojY=; b=ZUVDLQfthQOvdvYCVgZ1+Z2zN3n2nR5f9ee7PmL46P+uJpvInRSioFjsPeWNw4XDTN Gaid80HgBmUzAKVPESRlW5S3ae35Ogjed4zDgpxipbRcXX1Ukl1DF48WaLIeIeh5VGvo uBjuKjiOwF4brtXHeGrGQpyOLzurhHrbxtaC0= 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:in-reply-to :references; bh=mMuZ30ydMlpAKJdnZzJGRRao+UNlvkY24uRwi/xCojY=; b=Pf6vOBxJ85JmEXNtH5519GdlKL20WBAKqdk/muuS27B49nua28HKshT1IE035gMjNO dDYQU9V55A8Cpcl049wRsGhLkTzSmxnMsG1QeUG8axoNFgixDq+OeAF1eaDVk2gho8qV s19fuV6zc9e+Xax67ncQ7jUU97p7byxZ94s7IU+goheVpkPFxO13YkaYzQw89oPHtuhb 1fcTQjbXYbLu7Kz8CsK4rEvgah3mo0xJkkMbvMzsz06Ywcx7PXglgOczotXoaUvk5pe/ Cl1MC+5cMKNXCu1jiUi9KHMpWuP9Wv79fS6bgtNnqqDFi1chFDSQcWEBalKdNTx4fZ9M UZWw== X-Gm-Message-State: ALKqPwcp1WZZkhCtC0nj7QiHCEXSXysi3TUN6gMiMx2hq1R6qX5yHb7k j0DifU24MlCH9akWbiNzgL74pg== X-Received: by 2002:a62:fb14:: with SMTP id x20-v6mr1432288pfm.48.1527052859193; Tue, 22 May 2018 22:20:59 -0700 (PDT) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id r76-v6sm34401146pfl.1.2018.05.22.22.20.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 May 2018 22:20:58 -0700 (PDT) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson , Sricharan R , Sibi Sankar , Rohit kumar , Andy Gross Cc: linux-kernel@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [RFC PATCH 1/5] remoteproc: qcom: mdt_loader: Make the firmware authentication optional Date: Tue, 22 May 2018 22:20:50 -0700 Message-Id: <20180523052054.19025-2-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180523052054.19025-1-bjorn.andersson@linaro.org> References: <20180523052054.19025-1-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sricharan R qcom_mdt_load function loads the mdt type firmware and initialises the secure memory as well. Make the initialisation only when requested by the caller, so that the function can be used by self-authenticating remoteproc as well. Acked-by: Bjorn Andersson Signed-off-by: Sricharan R Signed-off-by: Bjorn Andersson --- No changes from Sricharan's V6. drivers/soc/qcom/mdt_loader.c | 87 ++++++++++++++++++++--------- include/linux/soc/qcom/mdt_loader.h | 4 ++ 2 files changed, 66 insertions(+), 25 deletions(-) -- 2.17.0 diff --git a/drivers/soc/qcom/mdt_loader.c b/drivers/soc/qcom/mdt_loader.c index dc09d7ac905f..1c488024c698 100644 --- a/drivers/soc/qcom/mdt_loader.c +++ b/drivers/soc/qcom/mdt_loader.c @@ -74,23 +74,10 @@ ssize_t qcom_mdt_get_size(const struct firmware *fw) } EXPORT_SYMBOL_GPL(qcom_mdt_get_size); -/** - * qcom_mdt_load() - load the firmware which header is loaded as fw - * @dev: device handle to associate resources with - * @fw: firmware object for the mdt file - * @firmware: name of the firmware, for construction of segment file names - * @pas_id: PAS identifier - * @mem_region: allocated memory region to load firmware into - * @mem_phys: physical address of allocated memory region - * @mem_size: size of the allocated memory region - * @reloc_base: adjusted physical address after relocation - * - * Returns 0 on success, negative errno otherwise. - */ -int qcom_mdt_load(struct device *dev, const struct firmware *fw, - const char *firmware, int pas_id, void *mem_region, - phys_addr_t mem_phys, size_t mem_size, - phys_addr_t *reloc_base) +static int __qcom_mdt_load(struct device *dev, const struct firmware *fw, + const char *firmware, int pas_id, void *mem_region, + phys_addr_t mem_phys, size_t mem_size, + phys_addr_t *reloc_base, bool pas_init) { const struct elf32_phdr *phdrs; const struct elf32_phdr *phdr; @@ -121,10 +108,12 @@ int qcom_mdt_load(struct device *dev, const struct firmware *fw, if (!fw_name) return -ENOMEM; - ret = qcom_scm_pas_init_image(pas_id, fw->data, fw->size); - if (ret) { - dev_err(dev, "invalid firmware metadata\n"); - goto out; + if (pas_init) { + ret = qcom_scm_pas_init_image(pas_id, fw->data, fw->size); + if (ret) { + dev_err(dev, "invalid firmware metadata\n"); + goto out; + } } for (i = 0; i < ehdr->e_phnum; i++) { @@ -144,10 +133,13 @@ int qcom_mdt_load(struct device *dev, const struct firmware *fw, } if (relocate) { - ret = qcom_scm_pas_mem_setup(pas_id, mem_phys, max_addr - min_addr); - if (ret) { - dev_err(dev, "unable to setup relocation\n"); - goto out; + if (pas_init) { + ret = qcom_scm_pas_mem_setup(pas_id, mem_phys, + max_addr - min_addr); + if (ret) { + dev_err(dev, "unable to setup relocation\n"); + goto out; + } } /* @@ -202,7 +194,52 @@ int qcom_mdt_load(struct device *dev, const struct firmware *fw, return ret; } + +/** + * qcom_mdt_load() - load the firmware which header is loaded as fw + * @dev: device handle to associate resources with + * @fw: firmware object for the mdt file + * @firmware: name of the firmware, for construction of segment file names + * @pas_id: PAS identifier + * @mem_region: allocated memory region to load firmware into + * @mem_phys: physical address of allocated memory region + * @mem_size: size of the allocated memory region + * @reloc_base: adjusted physical address after relocation + * + * Returns 0 on success, negative errno otherwise. + */ +int qcom_mdt_load(struct device *dev, const struct firmware *fw, + const char *firmware, int pas_id, void *mem_region, + phys_addr_t mem_phys, size_t mem_size, + phys_addr_t *reloc_base) +{ + return __qcom_mdt_load(dev, fw, firmware, pas_id, mem_region, mem_phys, + mem_size, reloc_base, true); +} EXPORT_SYMBOL_GPL(qcom_mdt_load); +/** + * qcom_mdt_load_no_init() - load the firmware which header is loaded as fw + * @dev: device handle to associate resources with + * @fw: firmware object for the mdt file + * @firmware: name of the firmware, for construction of segment file names + * @pas_id: PAS identifier + * @mem_region: allocated memory region to load firmware into + * @mem_phys: physical address of allocated memory region + * @mem_size: size of the allocated memory region + * @reloc_base: adjusted physical address after relocation + * + * Returns 0 on success, negative errno otherwise. + */ +int qcom_mdt_load_no_init(struct device *dev, const struct firmware *fw, + const char *firmware, int pas_id, + void *mem_region, phys_addr_t mem_phys, + size_t mem_size, phys_addr_t *reloc_base) +{ + return __qcom_mdt_load(dev, fw, firmware, pas_id, mem_region, mem_phys, + mem_size, reloc_base, false); +} +EXPORT_SYMBOL_GPL(qcom_mdt_load_no_init); + MODULE_DESCRIPTION("Firmware parser for Qualcomm MDT format"); MODULE_LICENSE("GPL v2"); diff --git a/include/linux/soc/qcom/mdt_loader.h b/include/linux/soc/qcom/mdt_loader.h index 5b98bbdabc25..944b06aefb0f 100644 --- a/include/linux/soc/qcom/mdt_loader.h +++ b/include/linux/soc/qcom/mdt_loader.h @@ -17,4 +17,8 @@ int qcom_mdt_load(struct device *dev, const struct firmware *fw, phys_addr_t mem_phys, size_t mem_size, phys_addr_t *reloc_base); +int qcom_mdt_load_no_init(struct device *dev, const struct firmware *fw, + const char *fw_name, int pas_id, void *mem_region, + phys_addr_t mem_phys, size_t mem_size, + phys_addr_t *reloc_base); #endif From patchwork Wed May 23 05:20:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 136619 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp450517lji; Tue, 22 May 2018 22:22:14 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrj9AyA4xc9B2ZSAo81IlpshqhfSuoU/EoC0q5dDyl+8r9IBLXS/gto5a5F0NSqxOA0IVkV X-Received: by 2002:a17:902:b488:: with SMTP id y8-v6mr261859plr.183.1527052934144; Tue, 22 May 2018 22:22:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527052934; cv=none; d=google.com; s=arc-20160816; b=wWInQA8qCr5+bJFfty/DxRsLz5hWNm40H0tVIgqOwfjhe49FkoyCZy6vJwxkTdgUf9 4iUF3/jAB3D+trB1R1Ujh98nDlXV9ck9hAZpFdL/lbd+03ZyOuljNiTh9o0TlyWyCe+C JNFdHW9Nrj6EEZbfPTzvEw5WSIOfcSnB/IpLvImNbNr6PZj6XjF36he/wPvIYw6nzGQG DQ69QCo/i/aSYbyxUNtSQr1HwWNO9EdVYaKQ9fSeo70FBo6H9kOFB4dhwoqOhRgeEzYF aPVPDG/LrP7BryQLWTRDhE2U3w7ZSBLrOQPFuFvxHwwteNFaUONynxgo44HyDfNYnyDt 80+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=ZeprXwBIN1WpZGpP/S5ChZKNDekFto/8CiR+g99n/1A=; b=qy+Ya2kK+Ob5MCIY4+JnrvE5l0+KFEGO6nVYauf+xUG4z9Ltcb0gJHmNHf9lI0lOeV 3viN0A9T16Y5RFJrbArrvfKnK/NH+b/3XNIA4Dc0h9Nw/bKXhF7AHgzffxgRUMXzOkyh E7+TFaXoH8RuZrJ83QamfRYTbdmnIjcVFBQx1RwZNns2gu3o8i78ltHRHWr65WRWgoot oBMT0x16htkRjG8abfi2WT6XaL7arbW9Vj/HZmbnOXfzFZtxNsj17DnINyEtWNvfOR26 Q1SJ+VldHxYtUKRK2wNETLS7eAdaYI78x7KmZWmKmFfDekmVc6cGQ85VL9xiMk+vdGho QrSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=J5+GT2ro; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q7-v6si17875323pls.286.2018.05.22.22.22.13; Tue, 22 May 2018 22:22:14 -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=pass header.i=@linaro.org header.s=google header.b=J5+GT2ro; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754126AbeEWFWL (ORCPT + 30 others); Wed, 23 May 2018 01:22:11 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:36704 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754075AbeEWFVB (ORCPT ); Wed, 23 May 2018 01:21:01 -0400 Received: by mail-pl0-f68.google.com with SMTP id v24-v6so12282702plo.3 for ; Tue, 22 May 2018 22:21:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZeprXwBIN1WpZGpP/S5ChZKNDekFto/8CiR+g99n/1A=; b=J5+GT2roFFRq9yoINs1fJ/4VJNc87o4GTJDGgQJ6iBAZGLa3dN3zdWsR5P2cM37Kzs Uxxj2ITxZcpl6dUwRHn26TP1coUhjt63q7GRBWlua7JgHyibJz8P8tvfgykVwXrOILCU ZBKEz/Zrwj3C18HeXockFJK8y326l7tY+7Q7E= 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:in-reply-to :references; bh=ZeprXwBIN1WpZGpP/S5ChZKNDekFto/8CiR+g99n/1A=; b=ii4mXqG5vpfcII/luvWRUoInRJCIe7PWl4ank6+DO7yS6QXlTSfuKP/w80MlljMduw KetZvHdUk8C2Nb1ZoQutRQJ5ebXecp4gAdUub60x4jrt6lXeE+9Koxw+tPr5eFJq+/Si rZZ+8rdbp5iYwy/sL2iLe/L9K+1CXNdW2SsBumUGB5U02PE+0MlBZfxSaiTnqsGvtMVa wG/ttemf/zxyUGvTPw8TdbY4wsS2ACknBb2Xix8IIwDXNu9v7HJxBfUhb1N4TMnfGPVk tsgyI7rEltWf9dLUKkScQJpLM+ThP266MlWcSa+L15+0ImpbkVzh8ep1gzNYvR0RXCWF 7n9Q== X-Gm-Message-State: ALKqPwdTkVm2ajC7hG16k/qKIc55Er9+PcAM5ri8WKH2iZmrgVPAUlgi VtTrPK2YeadGR71hNtZufXqZ4w== X-Received: by 2002:a17:902:2983:: with SMTP id h3-v6mr1468162plb.232.1527052860975; Tue, 22 May 2018 22:21:00 -0700 (PDT) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id r76-v6sm34401146pfl.1.2018.05.22.22.20.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 May 2018 22:21:00 -0700 (PDT) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson , Sricharan R , Sibi Sankar , Rohit kumar Cc: Andy Gross , linux-kernel@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [RFC PATCH 2/5] remoteproc: q6v5: Extract common resource handling Date: Tue, 22 May 2018 22:20:51 -0700 Message-Id: <20180523052054.19025-3-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180523052054.19025-1-bjorn.andersson@linaro.org> References: <20180523052054.19025-1-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Shared between all Hexagon V5 based remoteprocs is the handling of the 5 interrupts and the SMP2P stop request, so break this out into a separate function in order to allow these drivers to be cleaned up. Signed-off-by: Bjorn Andersson --- drivers/remoteproc/Kconfig | 5 + drivers/remoteproc/Makefile | 1 + drivers/remoteproc/qcom_q6v5.c | 243 +++++++++++++++++++++++++++++++++ drivers/remoteproc/qcom_q6v5.h | 46 +++++++ 4 files changed, 295 insertions(+) create mode 100644 drivers/remoteproc/qcom_q6v5.c create mode 100644 drivers/remoteproc/qcom_q6v5.h -- 2.17.0 diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig index cd1c168fd188..63b79ea91a21 100644 --- a/drivers/remoteproc/Kconfig +++ b/drivers/remoteproc/Kconfig @@ -102,6 +102,11 @@ config QCOM_ADSP_PIL config QCOM_RPROC_COMMON tristate +config QCOM_Q6V5_COMMON + tristate + depends on ARCH_QCOM + depends on QCOM_SMEM + config QCOM_Q6V5_PIL tristate "Qualcomm Hexagon V5 Peripherial Image Loader" depends on OF && ARCH_QCOM diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile index 02627ede8d4a..5dd0249cf76a 100644 --- a/drivers/remoteproc/Makefile +++ b/drivers/remoteproc/Makefile @@ -16,6 +16,7 @@ obj-$(CONFIG_DA8XX_REMOTEPROC) += da8xx_remoteproc.o obj-$(CONFIG_KEYSTONE_REMOTEPROC) += keystone_remoteproc.o obj-$(CONFIG_QCOM_ADSP_PIL) += qcom_adsp_pil.o obj-$(CONFIG_QCOM_RPROC_COMMON) += qcom_common.o +obj-$(CONFIG_QCOM_Q6V5_COMMON) += qcom_q6v5.o obj-$(CONFIG_QCOM_Q6V5_PIL) += qcom_q6v5_pil.o obj-$(CONFIG_QCOM_SYSMON) += qcom_sysmon.o obj-$(CONFIG_QCOM_WCNSS_PIL) += qcom_wcnss_pil.o diff --git a/drivers/remoteproc/qcom_q6v5.c b/drivers/remoteproc/qcom_q6v5.c new file mode 100644 index 000000000000..9076537a1671 --- /dev/null +++ b/drivers/remoteproc/qcom_q6v5.c @@ -0,0 +1,243 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Qualcomm Peripheral Image Loader for Q6V5 WCSS + * + * Copyright (C) 2016-2018 Linaro Ltd. + * Copyright (C) 2014 Sony Mobile Communications AB + * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. + */ +#include +#include +#include +#include +#include +#include +#include "qcom_q6v5.h" + +/** + * qcom_q6v5_prepare() - reinitialize the qcom_q6v5 context before start + * @q6v5: reference to qcom_q6v5 context to be reinitialized + * + * Return: 0 on success, negative errno on failure + */ +int qcom_q6v5_prepare(struct qcom_q6v5 *q6v5) +{ + reinit_completion(&q6v5->start_done); + reinit_completion(&q6v5->stop_done); + + q6v5->running = true; + q6v5->handover_issued = false; + + enable_irq(q6v5->handover_irq); + + return 0; +} + +/** + * qcom_q6v5_unprepare() - unprepare the qcom_q6v5 context after stop + * @q6v5: reference to qcom_q6v5 context to be unprepared + * + * Return: 0 on success, 1 if handover hasn't yet been called + */ +int qcom_q6v5_unprepare(struct qcom_q6v5 *q6v5) +{ + disable_irq(q6v5->handover_irq); + + return !q6v5->handover_issued; +} + +static irqreturn_t q6v5_wdog_interrupt(int irq, void *data) +{ + struct qcom_q6v5 *q6v5 = data; + size_t len; + char *msg; + + /* Sometimes the stop triggers a watchdog rather than a stop-ack */ + if (!q6v5->running) { + complete(&q6v5->stop_done); + return IRQ_HANDLED; + } + + msg = qcom_smem_get(QCOM_SMEM_HOST_ANY, q6v5->crash_reason, &len); + if (!IS_ERR(msg) && len > 0 && msg[0]) + dev_err(q6v5->dev, "watchdog received: %s\n", msg); + else + dev_err(q6v5->dev, "watchdog without message\n"); + + rproc_report_crash(q6v5->rproc, RPROC_FATAL_ERROR); + + return IRQ_HANDLED; +} + +static irqreturn_t q6v5_fatal_interrupt(int irq, void *data) +{ + struct qcom_q6v5 *q6v5 = data; + size_t len; + char *msg; + + msg = qcom_smem_get(QCOM_SMEM_HOST_ANY, q6v5->crash_reason, &len); + if (!IS_ERR(msg) && len > 0 && msg[0]) + dev_err(q6v5->dev, "fatal error received: %s\n", msg); + else + dev_err(q6v5->dev, "fatal error without message\n"); + + rproc_report_crash(q6v5->rproc, RPROC_FATAL_ERROR); + + return IRQ_HANDLED; +} + +static irqreturn_t q6v5_ready_interrupt(int irq, void *data) +{ + struct qcom_q6v5 *q6v5 = data; + + complete(&q6v5->start_done); + + return IRQ_HANDLED; +} + +/** + * qcom_q6v5_wait_for_start() - wait for remote processor start signal + * @q6v5: reference to qcom_q6v5 context + * @timeout: timeout to wait for the event, in jiffies + * + * qcom_q6v5_unprepare() should not be called when this function fails. + * + * Return: 0 on success, -ETIMEDOUT on timeout + */ +int qcom_q6v5_wait_for_start(struct qcom_q6v5 *q6v5, int timeout) +{ + int ret; + + ret = wait_for_completion_timeout(&q6v5->start_done, timeout); + if (!ret) + disable_irq(q6v5->handover_irq); + + return !ret ? -ETIMEDOUT : 0; +} + +static irqreturn_t q6v5_handover_interrupt(int irq, void *data) +{ + struct qcom_q6v5 *q6v5 = data; + + if (q6v5->handover) + q6v5->handover(q6v5); + + q6v5->handover_issued = true; + + return IRQ_HANDLED; +} + +static irqreturn_t q6v5_stop_interrupt(int irq, void *data) +{ + struct qcom_q6v5 *q6v5 = data; + + complete(&q6v5->stop_done); + + return IRQ_HANDLED; +} + +/** + * qcom_q6v5_request_stop() - request the remote processor to stop + * @q6v5: reference to qcom_q6v5 context + * + * Return: 0 on success, negative errno on failure + */ +int qcom_q6v5_request_stop(struct qcom_q6v5 *q6v5) +{ + int ret; + + q6v5->running = false; + + qcom_smem_state_update_bits(q6v5->state, + BIT(q6v5->stop_bit), BIT(q6v5->stop_bit)); + + ret = wait_for_completion_timeout(&q6v5->stop_done, 5 * HZ); + + qcom_smem_state_update_bits(q6v5->state, BIT(q6v5->stop_bit), 0); + + return ret == 0 ? -ETIMEDOUT : 0; +} + +/** + * qcom_q6v5_init() - initializer of the q6v5 common struct + * @q6v5: handle to be initialized + * @pdev: platform_device reference for acquiring resources + * @rproc: associated remoteproc instance + * @crash_reason: SMEM id for crash reason string, or 0 if none + * @handover: function to be called when proxy resources should be released + * + * Return: 0 on success, negative errno on failure + */ +int qcom_q6v5_init(struct qcom_q6v5 *q6v5, struct platform_device *pdev, + struct rproc *rproc, int crash_reason, + void (*handover)(struct qcom_q6v5 *q6v5)) +{ + int ret; + + q6v5->rproc = rproc; + q6v5->dev = &pdev->dev; + q6v5->crash_reason = crash_reason; + q6v5->handover = handover; + + init_completion(&q6v5->start_done); + init_completion(&q6v5->stop_done); + + q6v5->wdog_irq = platform_get_irq_byname(pdev, "wdog"); + ret = devm_request_threaded_irq(&pdev->dev, q6v5->wdog_irq, + NULL, q6v5_wdog_interrupt, + IRQF_TRIGGER_RISING | IRQF_ONESHOT, + "q6v5 wdog", q6v5); + if (ret) { + dev_err(&pdev->dev, "failed to acquire wdog IRQ\n"); + return ret; + } + + q6v5->fatal_irq = platform_get_irq_byname(pdev, "fatal"); + ret = devm_request_threaded_irq(&pdev->dev, q6v5->fatal_irq, + NULL, q6v5_fatal_interrupt, + IRQF_TRIGGER_RISING | IRQF_ONESHOT, + "q6v5 fatal", q6v5); + if (ret) { + dev_err(&pdev->dev, "failed to acquire fatal IRQ\n"); + return ret; + } + + q6v5->ready_irq = platform_get_irq_byname(pdev, "ready"); + ret = devm_request_threaded_irq(&pdev->dev, q6v5->ready_irq, + NULL, q6v5_ready_interrupt, + IRQF_TRIGGER_RISING | IRQF_ONESHOT, + "q6v5 ready", q6v5); + if (ret) { + dev_err(&pdev->dev, "failed to acquire ready IRQ\n"); + return ret; + } + + q6v5->handover_irq = platform_get_irq_byname(pdev, "handover"); + ret = devm_request_threaded_irq(&pdev->dev, q6v5->handover_irq, + NULL, q6v5_handover_interrupt, + IRQF_TRIGGER_RISING | IRQF_ONESHOT, + "q6v5 handover", q6v5); + if (ret) { + dev_err(&pdev->dev, "failed to acquire handover IRQ\n"); + return ret; + } + disable_irq(q6v5->handover_irq); + + q6v5->stop_irq = platform_get_irq_byname(pdev, "stop-ack"); + ret = devm_request_threaded_irq(&pdev->dev, q6v5->stop_irq, + NULL, q6v5_stop_interrupt, + IRQF_TRIGGER_RISING | IRQF_ONESHOT, + "q6v5 stop", q6v5); + if (ret) { + dev_err(&pdev->dev, "failed to acquire stop-ack IRQ\n"); + return ret; + } + + q6v5->state = qcom_smem_state_get(&pdev->dev, "stop", &q6v5->stop_bit); + if (IS_ERR(q6v5->state)) { + dev_err(&pdev->dev, "failed to acquire stop state\n"); + return PTR_ERR(q6v5->state); + } + + return 0; +} diff --git a/drivers/remoteproc/qcom_q6v5.h b/drivers/remoteproc/qcom_q6v5.h new file mode 100644 index 000000000000..7ac92c1e0f49 --- /dev/null +++ b/drivers/remoteproc/qcom_q6v5.h @@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef __QCOM_Q6V5_H__ +#define __QCOM_Q6V5_H__ + +#include +#include + +struct rproc; +struct qcom_smem_state; + +struct qcom_q6v5 { + struct device *dev; + struct rproc *rproc; + + struct qcom_smem_state *state; + unsigned stop_bit; + + int wdog_irq; + int fatal_irq; + int ready_irq; + int handover_irq; + int stop_irq; + + bool handover_issued; + + struct completion start_done; + struct completion stop_done; + + int crash_reason; + + bool running; + + void (*handover)(struct qcom_q6v5 *q6v5); +}; + +int qcom_q6v5_init(struct qcom_q6v5 *q6v5, struct platform_device *pdev, + struct rproc *rproc, int crash_reason, + void (*handover)(struct qcom_q6v5 *q6v5)); + +int qcom_q6v5_prepare(struct qcom_q6v5 *q6v5); +int qcom_q6v5_unprepare(struct qcom_q6v5 *q6v5); +int qcom_q6v5_request_stop(struct qcom_q6v5 *q6v5); +int qcom_q6v5_wait_for_start(struct qcom_q6v5 *q6v5, int timeout); + +#endif From patchwork Wed May 23 05:20:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 136617 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp450143lji; Tue, 22 May 2018 22:21:44 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrZ0wAk20V0GGGnVF0yhmNSmZuIKa+pYeBDy9jkawrXvzUanV11XLLayMxhroqc7iSyM7mT X-Received: by 2002:a65:5105:: with SMTP id f5-v6mr1159593pgq.232.1527052903852; Tue, 22 May 2018 22:21:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527052903; cv=none; d=google.com; s=arc-20160816; b=tVhEMZVq2ESUcX3vpNuJhRlosV3oswgVnWtx8as8nKJf7GUbWFKwT0u36b6M45VVii Kh+0dQNgH2Sdfed9NN3mXKqpNpBPjkGGeVf3tQ+srbBSOnT9tYUIHs36EYRpg0Xkituy Qu5yobUPQrJtyyipf5vhkh174epBMaZ0NiJn3QV7S+5LsMeil0TIuZ0TKAhR8L4hyKzG 5Cj7FcZ6M4/mrR21zpM/uZ6PDT8x2xdnYeTgAjx6RsfEfWJrdwWPe8s39i8cRRZK0xS4 kmn50znev0E3UuDRL0zcdw6u7wQnPL7+0iqSWNcOcrUWlAOYrGUs0TJnqWcLtROGFMLV UBjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=aIrSRjBeIcba3DKt2mFCMwisU/AiBaxEBD8qCDxJSSs=; b=ChMEg0dhOyTkqwThr3e4aN7fUP+DaD7o8mEcbbbXITgIxXYP3XKK6YukJV0yTbOd36 Gcz/UxNr4D0upmFQ6oTzIP3Wi6Iw2oN24N7ZbCc7/bbnRUsZoSzfDvTNS4ZaCC5V9kg3 AdKjlNkhUd5BCEq0gMC7l5OBIarjO5CFvd5pa5VTgrbZC8si2qDGV9vKy2uEemBFWEJQ fsyta0ltIC35jbcgQ5Fskw9wH+D2HIBu29aGuOxgW2uacY0gFd4wn73uzpj9WVn6EF8F h8SOEj443FpefdrjsKfNDj/lx3gPWeSYqvSzB1PeBYubTx4W86z6pUL2AVBv+UIRcyD5 oT8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S1uFhr7I; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y5-v6si11141487pgq.276.2018.05.22.22.21.43; Tue, 22 May 2018 22:21:43 -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=pass header.i=@linaro.org header.s=google header.b=S1uFhr7I; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932075AbeEWFVl (ORCPT + 30 others); Wed, 23 May 2018 01:21:41 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:35468 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754087AbeEWFVD (ORCPT ); Wed, 23 May 2018 01:21:03 -0400 Received: by mail-pg0-f65.google.com with SMTP id 11-v6so7239791pge.2 for ; Tue, 22 May 2018 22:21:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=aIrSRjBeIcba3DKt2mFCMwisU/AiBaxEBD8qCDxJSSs=; b=S1uFhr7IbPOnvYLqHOupw/5IukOvsRm1S3J57OvzYiSrWFofaTdjEDYy2YLxdlpQeM DtXW5bycmgblfyl/BxT71cOrUBiQ/9/VZZPMj0HBiG7eKtseLM1QPjOz2ty9ScQe5/xR sjQcrXOJXFoM58hxKZ8oJTY5jcyo05x61B0aY= 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:in-reply-to :references; bh=aIrSRjBeIcba3DKt2mFCMwisU/AiBaxEBD8qCDxJSSs=; b=gU7HK/IyrjRD1GzSxfB/A5BMH/5tYG37qp4XgU+1SVWgqdb8igguUQNutHvCORQM5s 54+v19WJG84HE6etm8id5ZEs60LRzx5Bv9++Z0aHXfu1CY/U6hUYC6QVce8QjwvwaLJa +/n5LAxZNKRnQ7Wb07fPZYEIVVhyFdaGOmn+dg0BW6/znlGv4eng4u/jTYv++hEOvoU1 R8Aw+bcHt9+hn22ZbJEBkNGojuhpDni5ZN9tRckfoP96bZWciEJSR/8X2qJPq0GmPtdT zB42coGQOSl0E/VDw91XS/cUnCfPbSZs6K2LQ5t3bV4eRJ/QYyquTMoZWOEI3EYvvDSA u87w== X-Gm-Message-State: ALKqPwcHGX9c+8iwZo8rq4TOayj1WY/W3OP3F8walKvs7tBtVfokTjF1 PZU1aMCxNlf9JYHRNbgOjEFg+g== X-Received: by 2002:a62:1549:: with SMTP id 70-v6mr1403799pfv.91.1527052863123; Tue, 22 May 2018 22:21:03 -0700 (PDT) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id r76-v6sm34401146pfl.1.2018.05.22.22.21.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 May 2018 22:21:02 -0700 (PDT) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson , Sricharan R , Sibi Sankar , Rohit kumar Cc: Andy Gross , linux-kernel@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [RFC PATCH 4/5] remoteproc: qcom: q6v5-pil: Use common q6v5 helpers Date: Tue, 22 May 2018 22:20:53 -0700 Message-Id: <20180523052054.19025-5-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180523052054.19025-1-bjorn.andersson@linaro.org> References: <20180523052054.19025-1-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Migrate the MSS remoteproc driver to use the newly extracted helper functions. Signed-off-by: Bjorn Andersson --- drivers/remoteproc/Kconfig | 4 + drivers/remoteproc/qcom_q6v5_pil.c | 157 +++-------------------------- 2 files changed, 19 insertions(+), 142 deletions(-) -- 2.17.0 diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig index d51d155cf8bd..2316908e9788 100644 --- a/drivers/remoteproc/Kconfig +++ b/drivers/remoteproc/Kconfig @@ -116,6 +116,10 @@ config QCOM_Q6V5_PIL depends on RPMSG_QCOM_GLINK_SMEM || RPMSG_QCOM_GLINK_SMEM=n depends on QCOM_SYSMON || QCOM_SYSMON=n select MFD_SYSCON + select QCOM_Q6V5_COMMON + select QCOM_RPROC_COMMON + select QCOM_SCM + select QCOM_Q6V5_COMMON select QCOM_RPROC_COMMON select QCOM_SCM help diff --git a/drivers/remoteproc/qcom_q6v5_pil.c b/drivers/remoteproc/qcom_q6v5_pil.c index 2bf8e7c49f2a..e04319573c91 100644 --- a/drivers/remoteproc/qcom_q6v5_pil.c +++ b/drivers/remoteproc/qcom_q6v5_pil.c @@ -30,12 +30,11 @@ #include #include #include -#include -#include #include #include "remoteproc_internal.h" #include "qcom_common.h" +#include "qcom_q6v5.h" #include @@ -151,12 +150,7 @@ struct q6v5 { struct reset_control *mss_restart; - struct qcom_smem_state *state; - unsigned stop_bit; - - int handover_irq; - - bool proxy_unvoted; + struct qcom_q6v5 q6v5; struct clk *active_clks[8]; struct clk *reset_clks[4]; @@ -170,8 +164,6 @@ struct q6v5 { int active_reg_count; int proxy_reg_count; - struct completion start_done; - struct completion stop_done; bool running; phys_addr_t mba_phys; @@ -798,9 +790,7 @@ static int q6v5_start(struct rproc *rproc) int xfermemop_ret; int ret; - qproc->proxy_unvoted = false; - - enable_irq(qproc->handover_irq); + qcom_q6v5_prepare(&qproc->q6v5); ret = q6v5_regulator_enable(qproc, qproc->proxy_regs, qproc->proxy_reg_count); @@ -875,11 +865,9 @@ static int q6v5_start(struct rproc *rproc) if (ret) goto reclaim_mpss; - ret = wait_for_completion_timeout(&qproc->start_done, - msecs_to_jiffies(5000)); - if (ret == 0) { + ret = qcom_q6v5_wait_for_start(&qproc->q6v5, msecs_to_jiffies(5000)); + if (ret == -ETIMEDOUT) { dev_err(qproc->dev, "start timed out\n"); - ret = -ETIMEDOUT; goto reclaim_mpss; } @@ -933,7 +921,7 @@ static int q6v5_start(struct rproc *rproc) qproc->proxy_reg_count); disable_irqs: - disable_irq(qproc->handover_irq); + qcom_q6v5_unprepare(&qproc->q6v5); return ret; } @@ -946,16 +934,10 @@ static int q6v5_stop(struct rproc *rproc) qproc->running = false; - qcom_smem_state_update_bits(qproc->state, - BIT(qproc->stop_bit), BIT(qproc->stop_bit)); - - ret = wait_for_completion_timeout(&qproc->stop_done, - msecs_to_jiffies(5000)); - if (ret == 0) + ret = qcom_q6v5_request_stop(&qproc->q6v5); + if (ret == -ETIMEDOUT) dev_err(qproc->dev, "timed out on wait\n"); - qcom_smem_state_update_bits(qproc->state, BIT(qproc->stop_bit), 0); - q6v5proc_halt_axi_port(qproc, qproc->halt_map, qproc->halt_q6); q6v5proc_halt_axi_port(qproc, qproc->halt_map, qproc->halt_modem); q6v5proc_halt_axi_port(qproc, qproc->halt_map, qproc->halt_nc); @@ -976,9 +958,8 @@ static int q6v5_stop(struct rproc *rproc) q6v5_reset_assert(qproc); - disable_irq(qproc->handover_irq); - - if (!qproc->proxy_unvoted) { + ret = qcom_q6v5_unprepare(&qproc->q6v5); + if (ret) { q6v5_clk_disable(qproc->dev, qproc->proxy_clks, qproc->proxy_clk_count); q6v5_regulator_disable(qproc, qproc->proxy_regs, @@ -1014,74 +995,14 @@ static const struct rproc_ops q6v5_ops = { .load = q6v5_load, }; -static irqreturn_t q6v5_wdog_interrupt(int irq, void *dev) -{ - struct q6v5 *qproc = dev; - size_t len; - char *msg; - - /* Sometimes the stop triggers a watchdog rather than a stop-ack */ - if (!qproc->running) { - complete(&qproc->stop_done); - return IRQ_HANDLED; - } - - msg = qcom_smem_get(QCOM_SMEM_HOST_ANY, MPSS_CRASH_REASON_SMEM, &len); - if (!IS_ERR(msg) && len > 0 && msg[0]) - dev_err(qproc->dev, "watchdog received: %s\n", msg); - else - dev_err(qproc->dev, "watchdog without message\n"); - - rproc_report_crash(qproc->rproc, RPROC_WATCHDOG); - - return IRQ_HANDLED; -} - -static irqreturn_t q6v5_fatal_interrupt(int irq, void *dev) -{ - struct q6v5 *qproc = dev; - size_t len; - char *msg; - - msg = qcom_smem_get(QCOM_SMEM_HOST_ANY, MPSS_CRASH_REASON_SMEM, &len); - if (!IS_ERR(msg) && len > 0 && msg[0]) - dev_err(qproc->dev, "fatal error received: %s\n", msg); - else - dev_err(qproc->dev, "fatal error without message\n"); - - rproc_report_crash(qproc->rproc, RPROC_FATAL_ERROR); - - return IRQ_HANDLED; -} - -static irqreturn_t q6v5_ready_interrupt(int irq, void *dev) -{ - struct q6v5 *qproc = dev; - - complete(&qproc->start_done); - return IRQ_HANDLED; -} - -static irqreturn_t q6v5_handover_interrupt(int irq, void *dev) +static void qcom_msa_handover(struct qcom_q6v5 *q6v5) { - struct q6v5 *qproc = dev; + struct q6v5 *qproc = container_of(q6v5, struct q6v5, q6v5); q6v5_clk_disable(qproc->dev, qproc->proxy_clks, qproc->proxy_clk_count); q6v5_regulator_disable(qproc, qproc->proxy_regs, qproc->proxy_reg_count); - - qproc->proxy_unvoted = true; - - return IRQ_HANDLED; -} - -static irqreturn_t q6v5_stop_ack_interrupt(int irq, void *dev) -{ - struct q6v5 *qproc = dev; - - complete(&qproc->stop_done); - return IRQ_HANDLED; } static int q6v5_init_mem(struct q6v5 *qproc, struct platform_device *pdev) @@ -1154,30 +1075,6 @@ static int q6v5_init_reset(struct q6v5 *qproc) return 0; } -static int q6v5_request_irq(struct q6v5 *qproc, - struct platform_device *pdev, - const char *name, - irq_handler_t thread_fn) -{ - int irq; - int ret; - - irq = platform_get_irq_byname(pdev, name); - if (irq < 0) { - dev_err(&pdev->dev, "no %s IRQ defined\n", name); - return irq; - } - - ret = devm_request_threaded_irq(&pdev->dev, irq, - NULL, thread_fn, - IRQF_TRIGGER_RISING | IRQF_ONESHOT, - "q6v5", qproc); - if (ret) - dev_err(&pdev->dev, "request %s IRQ failed\n", name); - - return ret ? : irq; -} - static int q6v5_alloc_memory_region(struct q6v5 *qproc) { struct device_node *child; @@ -1247,9 +1144,6 @@ static int q6v5_probe(struct platform_device *pdev) qproc->rproc = rproc; platform_set_drvdata(pdev, qproc); - init_completion(&qproc->start_done); - init_completion(&qproc->stop_done); - ret = q6v5_init_mem(qproc, pdev); if (ret) goto free_rproc; @@ -1305,33 +1199,12 @@ static int q6v5_probe(struct platform_device *pdev) qproc->version = desc->version; qproc->has_alt_reset = desc->has_alt_reset; qproc->need_mem_protection = desc->need_mem_protection; - ret = q6v5_request_irq(qproc, pdev, "wdog", q6v5_wdog_interrupt); - if (ret < 0) - goto free_rproc; - ret = q6v5_request_irq(qproc, pdev, "fatal", q6v5_fatal_interrupt); - if (ret < 0) - goto free_rproc; - - ret = q6v5_request_irq(qproc, pdev, "ready", q6v5_ready_interrupt); - if (ret < 0) - goto free_rproc; - - ret = q6v5_request_irq(qproc, pdev, "handover", q6v5_handover_interrupt); - if (ret < 0) - goto free_rproc; - qproc->handover_irq = ret; - disable_irq(qproc->handover_irq); - - ret = q6v5_request_irq(qproc, pdev, "stop-ack", q6v5_stop_ack_interrupt); - if (ret < 0) + ret = qcom_q6v5_init(&qproc->q6v5, pdev, rproc, MPSS_CRASH_REASON_SMEM, + qcom_msa_handover); + if (ret) goto free_rproc; - qproc->state = qcom_smem_state_get(&pdev->dev, "stop", &qproc->stop_bit); - if (IS_ERR(qproc->state)) { - ret = PTR_ERR(qproc->state); - goto free_rproc; - } qproc->mpss_perm = BIT(QCOM_SCM_VMID_HLOS); qproc->mba_perm = BIT(QCOM_SCM_VMID_HLOS); qcom_add_glink_subdev(rproc, &qproc->glink_subdev);