Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5102706ybi; Tue, 4 Jun 2019 01:02:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqxNpnyIu+b3EChpYJakUbXEVdduFytOz5T/Ky6tJa0mB0/bdxZ+nZIT3/GMF7LSc/ykn24f X-Received: by 2002:a17:90a:2946:: with SMTP id x6mr35236117pjf.133.1559635376065; Tue, 04 Jun 2019 01:02:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559635376; cv=none; d=google.com; s=arc-20160816; b=Ko4WiRtzFEWVCjY1mLFXPMPqo+jlhWwbQqxBbokowZB09PLw0noFkHQk3f3govWLlu IxSSQwPymzSsnKSXrx387A0ZvVDaQ6GtqN8M4kCxx5jyRhR2bUWX0go9knFG4m8QBcFN yynvIJZCXGlUM/LptOdjgF5iqPnTNekIG64vtyfKJ5h7iOrRdlJcB4JPHIxj/k7Xsp5x AjYpnMfnxeBUGcxExVZgCGWfBMCaKC7OfaPruy7CY5saQxYkWuFGeby9xMTjZ6tRcbv6 pDWDvn0R1hdrUHo9AvJz/0t4IOa38PAbfe+K9FAmfEQRj3hC7oCMaCzsCToGSWaL+K6v Uaaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=OONcvfHOCIyvGs1/W+0E2C1Jff7fV4ob++BVdGk1FbY=; b=ggI0M0ToGsW++7/Y/8+ydSR4SD3Cwe6C+T66jOq/tV+O059jmS7D0kc6XB25lDdqQE UkL5mct6jM8IyN5vz4sjMwageU1oJ7SBVEy45dz3yorjSUieC5Qg48D/GgnUOvfcdUOd dgr02iqSG5CKrVAYtlKYzo8D4W3CR8gxf5ru6usrNHcAvSASuj8Ybp/26hj3xGeM+pFS H731DgKRK5FhHC87gwkGozyUu5XfEP+7a53X4I++Xzt4HSKmZ5EWInLzg7tIh79Lh4H5 peHCvm+PrlskHJ4UqHsq3C9flHgTlOKTTmeMQm7yh0Hqs8OfkWIrbcVschi9zHLxF8IO H8SQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j187si26491585pfb.132.2019.06.04.01.02.37; Tue, 04 Jun 2019 01:02:56 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727197AbfFDIAz (ORCPT + 99 others); Tue, 4 Jun 2019 04:00:55 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:40426 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727181AbfFDIAz (ORCPT ); Tue, 4 Jun 2019 04:00:55 -0400 Received: from localhost (unknown [IPv6:2a01:e0a:2c:6930:5cf4:84a1:2763:fe0d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: bbrezillon) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 76BB4260E1F; Tue, 4 Jun 2019 09:00:52 +0100 (BST) Date: Tue, 4 Jun 2019 09:58:58 +0200 From: Boris Brezillon To: Qii Wang Cc: , devicetree@vger.kernel.org, srv_heupstream@mediatek.com, leilk.liu@mediatek.com, gregkh@linuxfoundation.org, xinping.qian@mediatek.com, linux-kernel@vger.kernel.org, liguo.zhang@mediatek.com, linux-mediatek@lists.infradead.org, matthias.bgg@gmail.com, linux-i3c@lists.infradead.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 2/2] i3c: master: Add driver for MediaTek IP Message-ID: <20190604095858.38ed9a28@collabora.com> In-Reply-To: <1559533863-10292-3-git-send-email-qii.wang@mediatek.com> References: <1559533863-10292-1-git-send-email-qii.wang@mediatek.com> <1559533863-10292-3-git-send-email-qii.wang@mediatek.com> Organization: Collabora X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 3 Jun 2019 11:51:03 +0800 Qii Wang wrote: > +static int mtk_i3c_master_probe(struct platform_device *pdev) > +{ > + struct device *dev = &pdev->dev; > + struct mtk_i3c_master *master; > + struct resource *res; > + int ret, irqnr; > + > + master = devm_kzalloc(dev, sizeof(*master), GFP_KERNEL); > + if (!master) > + return -ENOMEM; > + > + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "main"); > + master->regs = devm_ioremap_resource(dev, res); > + if (IS_ERR(master->regs)) > + return PTR_ERR(master->regs); > + > + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dma"); > + master->dma_regs = devm_ioremap_resource(dev, res); > + if (IS_ERR(master->dma_regs)) > + return PTR_ERR(master->dma_regs); > + > + irqnr = platform_get_irq(pdev, 0); > + if (irqnr < 0) > + return irqnr; > + > + ret = devm_request_irq(dev, irqnr, mtk_i3c_master_irq, > + IRQF_TRIGGER_NONE, DRV_NAME, master); > + if (ret < 0) { > + dev_err(dev, "Request I3C IRQ %d fail\n", irqnr); > + return ret; > + } > + > + ret = of_property_read_u32(pdev->dev.of_node, "clock-div", > + &master->clk_src_div); You say in one comment that this clock divider is fixed in HW but might change on a per-SoC basis. If that's the case, you should get rid of this clock-div prop and attach the divider to the compatible (using an mtk_i3c_master_variant struct that contains a divider field). > + if (ret < 0) > + return -EINVAL; > + > + spin_lock_init(&master->xferqueue.lock); > + INIT_LIST_HEAD(&master->xferqueue.list); > + > + if (dma_set_mask(dev, DMA_BIT_MASK(33))) { > + dev_err(dev, "dma_set_mask return error.\n"); > + return -EINVAL; > + } > + > + master->clk_main = devm_clk_get(dev, "main"); > + if (IS_ERR(master->clk_main)) { > + dev_err(dev, "cannot get main clock\n"); > + return PTR_ERR(master->clk_main); > + } > + master->clk_dma = devm_clk_get(dev, "dma"); > + if (IS_ERR(master->clk_dma)) { > + dev_err(dev, "cannot get dma clock\n"); > + return PTR_ERR(master->clk_dma); > + } > + > + master->clk_arb = devm_clk_get_optional(dev, "arb"); > + if (IS_ERR(master->clk_arb)) > + return PTR_ERR(master->clk_arb); > + > + ret = mtk_i3c_master_clock_enable(master); > + if (ret) { > + dev_err(dev, "clock enable failed!\n"); > + return ret; > + } > + > + master->dev = dev; > + platform_set_drvdata(pdev, master); > + > + ret = i3c_master_register(&master->mas_ctrler, dev, > + &mtk_i3c_master_ops, false); > + if (ret) { > + dev_err(dev, "Failed to add i3c bus to i3c core\n"); > + mtk_i3c_master_clock_disable(master); > + return ret; > + } > + > + return 0; > +}