From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753509AbbCILDq (ORCPT ); Mon, 9 Mar 2015 07:03:46 -0400 Received: from metis.ext.pengutronix.de ([92.198.50.35]:57098 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752842AbbCILDo (ORCPT ); Mon, 9 Mar 2015 07:03:44 -0400 Date: Mon, 9 Mar 2015 12:03:31 +0100 From: Sascha Hauer To: yong.wu@mediatek.com Cc: Rob Herring , Joerg Roedel , Matthias Brugger , Mark Rutland , devicetree@vger.kernel.org, srv_heupstream@mediatek.com, Catalin Marinas , Will Deacon , linux-kernel@vger.kernel.org, Tomasz Figa , iommu@lists.linux-foundation.org, Daniel Kurtz , Sasha Hauer , linux-mediatek@lists.infradead.org, Robin Murphy , linux-arm-kernel@lists.infradead.org, Lucas Stach Subject: Re: [PATCH 1/5] soc: mediatek: Add SMI driver Message-ID: <20150309110331.GG31289@pengutronix.de> References: <1425638900-24989-1-git-send-email-yong.wu@mediatek.com> <1425638900-24989-2-git-send-email-yong.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1425638900-24989-2-git-send-email-yong.wu@mediatek.com> X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Uptime: 11:53:43 up 47 days, 1:00, 100 users, load average: 22.96, 16.29, 10.37 User-Agent: Mutt/1.5.23 (2014-03-12) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: sha@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 06, 2015 at 06:48:16PM +0800, yong.wu@mediatek.com wrote: > From: Yong Wu > > This patch add SMI(Smart Multimedia Interface) driver. This driver is > responsible to enable/disable iommu and control the clocks of each > local arbiter. > > Signed-off-by: Yong Wu > --- > drivers/soc/mediatek/Kconfig | 7 ++ > drivers/soc/mediatek/Makefile | 1 + > drivers/soc/mediatek/mt8173-smi.c | 143 ++++++++++++++++++++++++++++++++++++++ > include/linux/mtk-smi.h | 40 +++++++++++ I just posted the power domain driver for prividing the domains this driver uses. You should base your code on that. > +#include > + > +#define SMI_LARB_MMU_EN (0xf00) > +#define F_SMI_MMU_EN(port) (1 << (port)) > + > +struct mtk_smi_larb { > + void __iomem *larb_base; > + struct clk *larb_clk[3];/* each larb has 3 clk at most */ > +}; > + > +static const char * const mtk_smi_clk_name[] = { > + "larb_sub0", "larb_sub1", "larb_sub2" > +}; > + > +static const struct of_device_id mtk_smi_of_ids[] = { > + { .compatible = "mediatek,mt8173-smi-larb", > + }, Add a newline after the opening brace. > +int mtk_smi_config_port(struct platform_device *plarbdev, > + unsigned int larbportid) > +{ > + struct mtk_smi_larb *larbpriv = dev_get_drvdata(&plarbdev->dev); > + int ret; > + u32 reg; > + > + ret = mtk_smi_larb_get(plarbdev); > + if (ret) > + return ret; > + > + reg = readl(larbpriv->larb_base + SMI_LARB_MMU_EN); > + reg &= ~F_SMI_MMU_EN(larbportid); > + reg |= F_SMI_MMU_EN(larbportid); This sets the very same bits that are cleared one line above. This is surely not what you want. > + writel(reg, larbpriv->larb_base + SMI_LARB_MMU_EN); > + > + mtk_smi_larb_put(plarbdev); > + > + return 0; > +} > + > +static int mtk_smi_probe(struct platform_device *pdev) > +{ > + struct mtk_smi_larb *larbpriv; > + struct resource *res; > + struct device *dev = &pdev->dev; > + unsigned int i; > + > + larbpriv = devm_kzalloc(dev, sizeof(struct mtk_smi_larb), GFP_KERNEL); sizeof(*larbpriv) > + if (!larbpriv) > + return -ENOMEM; > + > + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > + larbpriv->larb_base = devm_ioremap_resource(dev, res); > + if (IS_ERR(larbpriv->larb_base)) { > + dev_err(dev, "larbbase %p err\n", larbpriv->larb_base); You can print an error number with %ld and PTR_ERR(larbpriv->larb_base). Printing the pointer is not that helpful. > +/* > + * Enable iommu for each port, it is only for iommu. > + * > + * Returns 0 if successfully, others if failed. > + */ > +int mtk_smi_config_port(struct platform_device *pdev, > + unsigned int larbportid); > + > +/* > + * The multimedia module should call the two function below > + * which help open/close the clock of the larb. > + * so the client dtsi should add the larb like "larb = <&larb0>" > + * to get platform_device. > + * > + * mtk_smi_larb_get should be called before the multimedia h/w work. > + * mtk_smi_larb_put should be called after h/w done. > + * > + * Returns 0 if successfully, others if failed. > + */ > +int mtk_smi_larb_get(struct platform_device *plarbdev); > +void mtk_smi_larb_put(struct platform_device *plarbdev); The function documentation usually comes with the definition of a function, not its declaration. Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |