Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752234AbbBRPkn (ORCPT ); Wed, 18 Feb 2015 10:40:43 -0500 Received: from eso.teric.us ([69.164.192.171]:45701 "EHLO eso.teric.us" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751712AbbBRPkl (ORCPT ); Wed, 18 Feb 2015 10:40:41 -0500 X-Greylist: delayed 392 seconds by postgrey-1.27 at vger.kernel.org; Wed, 18 Feb 2015 10:40:41 EST Date: Wed, 18 Feb 2015 09:34:46 -0600 From: Josh Cartwright To: Gilad Avidov Cc: sdharia@codeaurora.org, mlocke@codeaurora.org, linux-arm-msm@vger.kernel.org, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, iivanov@mm-sol.com, galak@codeaurora.org, agross@codeaurora.org Subject: Re: [PATCH V3 2/2] spmi: pmic_arb: add support for hw version 2 Message-ID: <20150218153446.GA3485@kryptos> References: <1423522272-24472-1-git-send-email-gavidov@codeaurora.org> <1423522272-24472-3-git-send-email-gavidov@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1423522272-24472-3-git-send-email-gavidov@codeaurora.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2652 Lines: 83 Hey Gilad- On Mon, Feb 09, 2015 at 03:51:12PM -0700, Gilad Avidov wrote: > Qualcomm PMIC Arbiter version-2 changes from version-1 are: > > - Some different register offsets. > - New channel register space, one per PMIC peripheral (ppid). > All tx traffic uses these channels. > - New observer register space. All rx trafic uses this space. > - Different command format for spmi command registers. > > Acked-by: Sagar Dharia > Signed-off-by: Gilad Avidov [..] > +++ b/drivers/spmi/spmi-pmic-arb.c [..] > @@ -645,12 +795,65 @@ static int spmi_pmic_arb_probe(struct platform_device *pdev) > pa->spmic = ctrl; > > res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "core"); > - pa->base = devm_ioremap_resource(&ctrl->dev, res); > - if (IS_ERR(pa->base)) { > - err = PTR_ERR(pa->base); > + pa->rd_base = devm_ioremap_resource(&ctrl->dev, res); This seems like an awkward way to do this, especially if you end up remapping it... > + if (IS_ERR(pa->rd_base)) { > + err = PTR_ERR(pa->rd_base); > goto err_put_ctrl; > } > > + hw_ver = readl_relaxed(pa->rd_base + PMIC_ARB_VERSION); > + is_v1 = (hw_ver < PMIC_ARB_VERSION_V2_MIN); > + > + dev_info(&ctrl->dev, "PMIC Arb Version-%d (0x%x)\n", (is_v1 ? 1 : 2), > + hw_ver); > + > + if (is_v1) { > + pa->ver_ops = &pmic_arb_v1; > + pa->wr_base = pa->rd_base; > + } else { > + u8 chan; > + u16 ppid; > + u32 regval; > + > + pa->ver_ops = &pmic_arb_v2; > + > + pa->ppid_to_chan = devm_kzalloc(&ctrl->dev, > + PPID_TO_CHAN_TABLE_SZ, GFP_KERNEL); > + if (!pa->ppid_to_chan) { > + err = -ENOMEM; > + goto err_put_ctrl; > + } > + /* > + * PMIC_ARB_REG_CHNL is a table in HW mapping channel to ppid. > + * ppid_to_chan is an in-memory invert of that table. > + */ > + for (chan = 0; chan < PMIC_ARB_MAX_CHNL; ++chan) { > + regval = readl_relaxed(pa->rd_base + > + PMIC_ARB_REG_CHNL(chan)); > + if (!regval) > + continue; > + > + ppid = (regval >> 8) & 0xFFF; > + pa->ppid_to_chan[ppid] = chan; > + } > + > + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, > + "obsrvr"); > + pa->rd_base = devm_ioremap_resource(&ctrl->dev, res); ...here. Especially because now you have some loose mapping hanging around for the lifetime of the device. I'd suggest splitting the v1 and v2 probe routines out into their own functions. Josh -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/