From patchwork Tue Jul 26 05:22:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamlakant Patel X-Patchwork-Id: 9247641 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1AA87607D8 for ; Tue, 26 Jul 2016 05:43:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A53926223 for ; Tue, 26 Jul 2016 05:43:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EFF2D26538; Tue, 26 Jul 2016 05:43:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 507EF26223 for ; Tue, 26 Jul 2016 05:43:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752818AbcGZFnK (ORCPT ); Tue, 26 Jul 2016 01:43:10 -0400 Received: from mail-gw1-out.broadcom.com ([216.31.210.62]:11918 "EHLO mail-gw1-out.broadcom.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752634AbcGZFnK (ORCPT ); Tue, 26 Jul 2016 01:43:10 -0400 X-Greylist: delayed 577 seconds by postgrey-1.27 at vger.kernel.org; Tue, 26 Jul 2016 01:43:10 EDT X-IronPort-AV: E=Sophos;i="5.28,423,1464678000"; d="scan'208";a="100286543" Received: from mail-irv-18.broadcom.com ([10.15.198.37]) by mail-gw1-out.broadcom.com with ESMTP; 26 Jul 2016 00:06:49 -0700 Received: from mail-irva-12.broadcom.com (mail-irva-12.broadcom.com [10.11.16.101]) by mail-irv-18.broadcom.com (Postfix) with ESMTP id 465198203D; Mon, 25 Jul 2016 22:33:32 -0700 (PDT) Received: from linaro.ban.broadcom.com (unknown [10.131.60.135]) by mail-irva-12.broadcom.com (Postfix) with ESMTP id 6841FA6282; Mon, 25 Jul 2016 22:33:29 -0700 (PDT) From: kamlakant.patel@broadcom.com To: Mark Brown Cc: Kamlakant Patel , linux-spi@vger.kernel.org, Jayachandran C Subject: [PATCH] spi: vulcan: Add ACPI support for SPI driver Date: Tue, 26 Jul 2016 10:52:06 +0530 Message-Id: <1469510526-7593-1-git-send-email-kamlakant.patel@broadcom.com> X-Mailer: git-send-email 1.9.1 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Kamlakant Patel Add ACPI support for SPI controller driver on Broadcom Vulcan ARM64 plateform. Signed-off-by: Kamlakant Patel --- drivers/spi/spi-xlp.c | 33 ++++++++++++++++++++++++++++----- 1 files changed, 28 insertions(+), 5 deletions(-) diff --git a/drivers/spi/spi-xlp.c b/drivers/spi/spi-xlp.c index 8f04fec..7494254 100644 --- a/drivers/spi/spi-xlp.c +++ b/drivers/spi/spi-xlp.c @@ -11,6 +11,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ +#include #include #include #include @@ -85,7 +86,7 @@ #define XLP_SPI_TXRXTH 0x80 #define XLP_SPI_FIFO_SIZE 8 #define XLP_SPI_MAX_CS 4 -#define XLP_SPI_DEFAULT_FREQ 133333333 +#define VULCAN_SPI_DEFAULT_FREQ 133000000 #define XLP_SPI_FDIV_MIN 4 #define XLP_SPI_FDIV_MAX 65535 /* @@ -403,11 +404,24 @@ static int xlp_spi_probe(struct platform_device *pdev) } clk = devm_clk_get(&pdev->dev, NULL); - if (IS_ERR(clk)) { - dev_err(&pdev->dev, "could not get spi clock\n"); - return -ENODEV; + if (!IS_ERR(clk)) { + xspi->spi_clk = clk_get_rate(clk); + } else { + u32 freq; + + err = device_property_read_u32(&pdev->dev, + "clock-frequency", &freq); + if (err) { + /* + * Use default SPI frequency for Vulcan unless + * changed by firmaware. + */ + dev_err(&pdev->dev, "Can't get clock-frequency, + using default\n"); + freq = VULCAN_SPI_DEFAULT_FREQ; + } + xspi->spi_clk = freq; } - xspi->spi_clk = clk_get_rate(clk); master = spi_alloc_master(&pdev->dev, 0); if (!master) { @@ -437,6 +451,14 @@ static int xlp_spi_probe(struct platform_device *pdev) return 0; } +#ifdef CONFIG_ACPI +static const struct acpi_device_id xlp_spi_acpi_match[] = { + { "BRCM900D", 0 }, + { }, +}; +MODULE_DEVICE_TABLE(acpi, xlp_spi_acpi_match); +#endif + static const struct of_device_id xlp_spi_dt_id[] = { { .compatible = "netlogic,xlp832-spi" }, { }, @@ -447,6 +469,7 @@ static struct platform_driver xlp_spi_driver = { .driver = { .name = "xlp-spi", .of_match_table = xlp_spi_dt_id, + .acpi_match_table = ACPI_PTR(xlp_spi_acpi_match), }, }; module_platform_driver(xlp_spi_driver);