From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82BE8C433E0 for ; Mon, 8 Jun 2020 21:45:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6C1B82063A for ; Mon, 8 Jun 2020 21:45:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726768AbgFHVpO (ORCPT ); Mon, 8 Jun 2020 17:45:14 -0400 Received: from mga18.intel.com ([134.134.136.126]:58551 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726612AbgFHVpN (ORCPT ); Mon, 8 Jun 2020 17:45:13 -0400 IronPort-SDR: eWnxpI1wy5F3ZgweqQfYMQ4my83r2/Vipi3iSogV4ahgCl9j/ESUc6s4sAmDQeax2qD2Qe1KBd VwPRxpMUuQqw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jun 2020 14:45:12 -0700 IronPort-SDR: HlPk+2iKB1EmEjHx1fiuTRW8JD8I1xoE8JKNt85J7uD2Km3/s3FTpcyY6tQh4WvkwiEAC+ojtp Gz27U2T3mh6A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,489,1583222400"; d="scan'208";a="446893871" Received: from skarmaka-mobl2.amr.corp.intel.com (HELO [10.254.104.56]) ([10.254.104.56]) by orsmga005.jf.intel.com with ESMTP; 08 Jun 2020 14:45:12 -0700 Subject: Re: [PATCH 2/5] soundwire: qcom: add support for mmio soundwire devices To: Jonathan Marek , alsa-devel@alsa-project.org Cc: Andy Gross , Bjorn Andersson , Vinod Koul , Sanyog Kale , "open list:ARM/QUALCOMM SUPPORT" , open list References: <20200608204347.19685-1-jonathan@marek.ca> <20200608204347.19685-3-jonathan@marek.ca> From: Pierre-Louis Bossart Message-ID: <90b08ff9-ab00-051f-1a96-15ee6401fe52@linux.intel.com> Date: Mon, 8 Jun 2020 16:31:51 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <20200608204347.19685-3-jonathan@marek.ca> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org On 6/8/20 3:43 PM, Jonathan Marek wrote: > Adds support for qcom soundwire devices with memory mapped IO registers. 'device' is an ambiguous term for SoundWire. Seems to me this is a SoundWire Master device directly accessed with mmio registers instead of over a SLIMbus link? > > Signed-off-by: Jonathan Marek > --- > drivers/soundwire/qcom.c | 25 +++++++++++++++++++++++-- > 1 file changed, 23 insertions(+), 2 deletions(-) > > diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c > index f38d1fd3679f..628747df1c75 100644 > --- a/drivers/soundwire/qcom.c > +++ b/drivers/soundwire/qcom.c > @@ -90,6 +90,7 @@ struct qcom_swrm_ctrl { > struct sdw_bus bus; > struct device *dev; > struct regmap *regmap; > + void __iomem *mmio; > struct completion *comp; > struct work_struct slave_work; > /* read/write lock */ > @@ -154,6 +155,20 @@ static int qcom_swrm_ahb_reg_write(struct qcom_swrm_ctrl *ctrl, > return SDW_CMD_OK; > } > > +static int qcom_swrm_cpu_reg_read(struct qcom_swrm_ctrl *ctrl, int reg, > + u32 *val) > +{ > + *val = readl(ctrl->mmio + reg); > + return SDW_CMD_OK; > +} > + > +static int qcom_swrm_cpu_reg_write(struct qcom_swrm_ctrl *ctrl, int reg, > + int val) > +{ > + writel(val, ctrl->mmio + reg); > + return SDW_CMD_OK; > +} > + > static int qcom_swrm_cmd_fifo_wr_cmd(struct qcom_swrm_ctrl *ctrl, u8 cmd_data, > u8 dev_addr, u16 reg_addr) > { > @@ -746,6 +761,7 @@ static int qcom_swrm_probe(struct platform_device *pdev) > struct sdw_master_prop *prop; > struct sdw_bus_params *params; > struct qcom_swrm_ctrl *ctrl; > + struct resource *res; > int ret; > u32 val; > > @@ -760,8 +776,13 @@ static int qcom_swrm_probe(struct platform_device *pdev) > if (!ctrl->regmap) > return -EINVAL; > } else { > - /* Only WCD based SoundWire controller is supported */ > - return -ENOTSUPP; I would move patch4 before this one, and add the functionality *after* removing the SLIMbus dependency. > + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > + > + ctrl->reg_read = qcom_swrm_cpu_reg_read; > + ctrl->reg_write = qcom_swrm_cpu_reg_write; > + ctrl->mmio = devm_ioremap_resource(dev, res); > + if (IS_ERR(ctrl->mmio)) > + return PTR_ERR(ctrl->mmio); maybe deal with the resource checks before setting callbacks? There are quite a few drivers who do things this way: clk/qcom/common.c- res = platform_get_resource(pdev, IORESOURCE_MEM, 0); clk/qcom/common.c: base = devm_ioremap_resource(dev, res); -- > } > > ctrl->irq = of_irq_get(dev->of_node, 0); >