Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp366371ybl; Tue, 7 Jan 2020 21:26:22 -0800 (PST) X-Google-Smtp-Source: APXvYqzG4ZfKm2Z7w1I+Ty4N0kg68O2zzzHhX0WZQkmBdIvwFvNTcM/3p2tTQeOz3eVeiMRW9dk3 X-Received: by 2002:a05:6808:251:: with SMTP id m17mr1737542oie.15.1578461181933; Tue, 07 Jan 2020 21:26:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578461181; cv=none; d=google.com; s=arc-20160816; b=Fxxix2Onj01oiG3RojE93IGkSPzuswMVMsxQ2CEoMLDkf6H01ZMEKrbDYFDubDiBsW rOB+H8jXKaBlBRFos+fEjeN2mVlFWvBsIFvi7ELSKmGHHtrwpxf1mcIQvIliNlihqyT6 N4wvqyIQ3KF1AUriUkmeDimc2kL8hY4dRps7QX/D340QpfMHgJ+3lDnmS/3LKFC7eaXm kGLQMF3SxBmW9XP/iavksCgov8cXzGnee/4N9yjdKbZeserIXVyAyBC+NFIQawgGxLhY chiz/H7XsJVRDM5HXOZUy6OGehYRvXec3MBmAHeEm93FJlEi/AUxyrE56gFqF/2fM7Sv yfoA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=tkOTNhAqYE1x3Eo5rHG4Lthmtqq3DGR51ZA49CKqPEo=; b=dGrGMvE936n/1jgHotj6JiaEQ8Fv1YVW7MR15Uly9+gg0FGr65x65wkXGtQdz6W1XZ o2KJdnyx9S1s1L1s44C+ZHwCVUT5AM+WMdDMAzA6HtL4yGilNsOy7rBwEILkXcheM7/0 gvmacLiBbqKuPmTKRPHBTFOocOMUp31l298NTrkWYaBObrDKg9D0Q0WBKkVR+KNDJQ82 g68sCLn18Wt1tz+ElCbIvQUDSm52/FeSWCg6h2TVHpKZQ9elWyuqbZptOK8jqH9LVyzb K2mym2l6j4CyNN0nRw4u8oettC96m2IanBdt+cFmcQdyknSIBmCiEO1Fj6i+nG/bae5R pNRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=R5KYEY5D; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p20si1579238otr.319.2020.01.07.21.26.10; Tue, 07 Jan 2020 21:26:21 -0800 (PST) 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=@ti.com header.s=ti-com-17Q1 header.b=R5KYEY5D; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726186AbgAHFZ3 (ORCPT + 99 others); Wed, 8 Jan 2020 00:25:29 -0500 Received: from fllv0016.ext.ti.com ([198.47.19.142]:34552 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725773AbgAHFZ2 (ORCPT ); Wed, 8 Jan 2020 00:25:28 -0500 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 0085PM7F053176; Tue, 7 Jan 2020 23:25:22 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1578461122; bh=tkOTNhAqYE1x3Eo5rHG4Lthmtqq3DGR51ZA49CKqPEo=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=R5KYEY5Dwh9gDpKNAwBiJkPf2SDlHH8VPAuEUoomniZOFpwSuM2xtZMROurQNMfwY 8tlTeUgvBbqi1aWR5NNfaBD9Arg1D2hsDUfCVEmyREE8qYe2I/FSZ0qk3EPk/9PCxz M5lEzFh0yKEPozQzY8g6UA3MuuAzPx+y5HR4mA0o= Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 0085PMsu012399 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 7 Jan 2020 23:25:22 -0600 Received: from DFLE105.ent.ti.com (10.64.6.26) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Tue, 7 Jan 2020 23:25:21 -0600 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE105.ent.ti.com (10.64.6.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Tue, 7 Jan 2020 23:25:21 -0600 Received: from [172.24.145.136] (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 0085PIVE114824; Tue, 7 Jan 2020 23:25:19 -0600 Subject: Re: [PATCH v6 2/2] spi: cadence-quadpsi: Add support for the Cadence QSPI controller To: "Ramuthevar,Vadivel MuruganX" , , , CC: , , , References: <20191230074102.50982-1-vadivel.muruganx.ramuthevar@linux.intel.com> <20191230074102.50982-3-vadivel.muruganx.ramuthevar@linux.intel.com> From: Vignesh Raghavendra Message-ID: Date: Wed, 8 Jan 2020 10:55:51 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <20191230074102.50982-3-vadivel.muruganx.ramuthevar@linux.intel.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, [...] On 30/12/19 1:11 pm, Ramuthevar,Vadivel MuruganX wrote: > +static int cqspi_probe(struct platform_device *pdev) > +{ > + struct device *dev = &pdev->dev; > + struct struct_cqspi *cqspi; > + struct spi_master *master; > + struct reset_control *rstc, *rstc_ocp; > + const struct cqspi_driver_platdata *ddata; > + struct cqspi_platform_data *pdata = NULL; > + struct resource *res = NULL; > + int ret; > + > + master = spi_alloc_master(&pdev->dev, sizeof(*cqspi)); > + if (!master) { > + dev_err(&pdev->dev, "spi_alloc_master failed\n"); > + return -ENOMEM; > + } > + master->mode_bits = SPI_RX_QUAD | SPI_TX_DUAL | SPI_RX_DUAL | > + SPI_RX_OCTAL; > + master->setup = cqspi_setup; > + master->mem_ops = &cqspi_mem_ops; > + master->dev.of_node = pdev->dev.of_node; > + cqspi = spi_master_get_devdata(master); > + cqspi->pdev = pdev; > + > + pdata = devm_kmalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); devm_kzalloc()? > + if (!pdata) > + return -ENOMEM; > + > + pdev->dev.platform_data = pdata; > + > + /* Obtain QSPI clock. */ > + cqspi->clk = devm_clk_get(&pdev->dev, "qspi"); clock-name of "qspi" is not mandatory as per DT binding and current DT files don't have clock-names property. This therefore cause probe to fail. This should remain: cqspi->clk = devm_clk_get(&pdev->dev, "NULL"); > + if (IS_ERR(cqspi->clk)) { > + dev_err(&pdev->dev, "cannot get qspi clk\n"); > + return PTR_ERR(cqspi->clk); > + } > + pdata->master_ref_clk_hz = clk_get_rate(cqspi->clk); > + > + ret = clk_prepare_enable(cqspi->clk); > + if (ret < 0) { > + dev_err(&pdev->dev, "failed to enable qspi clock: %d\n", ret); > + return ret; > + } > + > + /* Obtain configuration from OF. */ > + ret = cqspi_of_get_pdata(pdev); > + if (ret) { > + dev_err(&pdev->dev, "Get platform data failed.\n"); > + return -ENODEV; > + } > + > + cqspi->res = res; > + /* Obtain and remap controller address. */ > + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > + cqspi->iobase = devm_ioremap_resource(&pdev->dev, res); > + if (IS_ERR(cqspi->iobase)) { > + dev_err(dev, "Cannot remap controller address.\n"); > + return PTR_ERR(cqspi->iobase); > + } > + > + /* Obtain and remap AHB address. */ > + res = platform_get_resource(pdev, IORESOURCE_MEM, 1); > + cqspi->qspi_ahb_virt = devm_ioremap_resource(dev, res); > + if (IS_ERR(cqspi->qspi_ahb_virt)) { > + dev_err(dev, "Cannot remap AHB address.\n"); > + return PTR_ERR(cqspi->qspi_ahb_virt); > + } > + cqspi->ahbbase = res; > + cqspi->ahb_size = resource_size(res); > + > + /* Obtain QSPI reset control */ > + rstc = devm_reset_control_get_optional_exclusive(dev, "qspi"); > + if (IS_ERR(rstc)) { > + dev_err(dev, "Cannot get QSPI reset.\n"); > + return PTR_ERR(rstc); > + } > + > + rstc_ocp = devm_reset_control_get_optional_exclusive(dev, "qspi-ocp"); > + if (IS_ERR(rstc_ocp)) { > + dev_err(dev, "Cannot get QSPI OCP reset.\n"); > + return PTR_ERR(rstc_ocp); > + } > + > + reset_control_assert(rstc); > + reset_control_deassert(rstc); > + > + reset_control_assert(rstc_ocp); > + reset_control_deassert(rstc_ocp); > + > + ddata = of_device_get_match_data(dev); > + if (ddata && (ddata->quirks & CQSPI_NEEDS_WR_DELAY)) > + cqspi->wr_delay = 5 * DIV_ROUND_UP(NSEC_PER_SEC, > + pdata->master_ref_clk_hz); > + > + if (ddata && (ddata->quirks & CQSPI_DISABLE_DAC_MODE)) > + cqspi->use_dac_mode = false; > + > + init_completion(&cqspi->transfer_complete); > + > + /* Obtain IRQ line. */ > + cqspi->irq = platform_get_irq(pdev, 0); > + if (cqspi->irq < 0) { > + dev_err(dev, "platform_get_irq failed.\n"); > + ret = -ENXIO; > + } > + ret = devm_request_irq(dev, cqspi->irq, cqspi_irq_handler, 0, > + pdev->name, cqspi); > + if (ret) { > + dev_err(dev, "request_irq failed.\n"); > + goto out_clk_disable; > + } > + > + master->bus_num = pdata->bus_num; > + master->num_chipselect = pdata->num_chipselect; Where is pdata->bus_num and pdata->num_chipselect initialized? This causes devm_spi_register_master() to fail randomly as num_chipselect may be 0. > + mutex_init(&cqspi->lock); > + platform_set_drvdata(pdev, master); > + cqspi_controller_init(cqspi); > + cqspi->current_cs = -1; > + > + ret = devm_spi_register_master(dev, master); > + if (ret) { > + dev_err(&pdev->dev, "devm_spi_register_master failed.\n"); > + goto err_of; > + } > + > + return 0; > + > +out_clk_disable: > + clk_disable_unprepare(cqspi->clk); > +err_of: > + spi_master_put(master); > + dev_err(&pdev->dev, "Cadence QSPI controller probe failed\n"); > + return ret; > +} > + -- Regards Vignesh