Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp592260imu; Thu, 13 Dec 2018 00:41:03 -0800 (PST) X-Google-Smtp-Source: AFSGD/UDSIkU5gB9fj03J2QtzOUzFY3hZuD6U8TjDeG+avxXvUsvk6FYsuqP2zOhz4W/+qK4sHSV X-Received: by 2002:a63:e001:: with SMTP id e1mr21261237pgh.39.1544690463060; Thu, 13 Dec 2018 00:41:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544690463; cv=none; d=google.com; s=arc-20160816; b=x1VJawNY8hZ/1Ah4aMUOAn8q3fglE2DE7rDi6APSH9Ou+zVR+QxovL4v1nOwgVgclr OnrD83k4pYV5BDUA6CUSXOZBTUfPt1mw3nHiXZikJb4OIG3cKIZjfx8bHqYppK08faKy O1AfHb9GKP/dHXdn2gApaa1euIq4RLP039+1uB0yfeMJ41CPmunqEKAYp8b+1lcK2KJk hXtJ+lHDLb7nqvdBOugGkaeiRn2ztxICgBLV2TvS4gBSyZpxWpC0kvCjmrAF5/U5CyBk TsOIJxINo0i77CG6yOGe1Mi7mhksXNpaXbn8+6GXMpfnHf4RfiMqjlAyHeK1VqLdPGX7 vbxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=bDE1Tz1GCAnvboalsfoxxulYxVj8OPdW7HCkxq5XUEE=; b=QHf06S/1HbRHYKoa+HFLn87EFWPddXbwFWYrrczAvpzSt2TcvLfAHE0nEw8i/75YWS dELZhr8jT6VjbdxVo31XyExFw7s3Ky15Vhv7dvgz7SOKfpJb5WPrt+eydgZlHp3Sh8rw bjBkX1Nr9KI0/KQSV6Dieh3dxSwTM7Qwvx0Z5dK6bebQeAy9kylddNKdCsXNm//afiCj r8KMZyuiwrQ0V3Fd/JGozYdSzrWVh2osnxrvFheWsRQXcY4CecXetR1kNs6J/d/BqmSJ BBuHx2DsKk2+nGhUVVXWnK81b9rvjzP5y5Z2nYavDrxcgdklQMcu5lFNy6Z1l610Eh4t 1/Mg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s8si1028260plq.345.2018.12.13.00.40.48; Thu, 13 Dec 2018 00:41:03 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727635AbeLMIjh (ORCPT + 99 others); Thu, 13 Dec 2018 03:39:37 -0500 Received: from mail-sz2.amlogic.com ([211.162.65.114]:52845 "EHLO mail-sz2.amlogic.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727604AbeLMIjf (ORCPT ); Thu, 13 Dec 2018 03:39:35 -0500 Received: from localhost.localdomain (10.28.8.16) by mail-sz2.amlogic.com (10.28.11.6) with Microsoft SMTP Server id 15.0.1320.4; Thu, 13 Dec 2018 16:39:57 +0800 From: Sunny Luo To: Mark Brown CC: Sunny Luo , Yixun Lan , Neil Armstrong , Jerome Brunet , Kevin Hilman , Carlo Caione , Jianxin Pan , Xingyu Chen , , , , Subject: [PATCH v2 1/3] spi: meson-axg: support MAX 80M clock Date: Thu, 13 Dec 2018 16:39:12 +0800 Message-ID: <1544690354-16409-2-git-send-email-sunny.luo@amlogic.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1544690354-16409-1-git-send-email-sunny.luo@amlogic.com> References: <1544690354-16409-1-git-send-email-sunny.luo@amlogic.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.28.8.16] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The SPICC controller in Meson-AXG is capable of running at 80M clock. The ASIC IP is improved and the clock is actually running higher than previous old SoCs. Signed-off-by: Sunny Luo Signed-off-by: Yixun Lan --- drivers/spi/spi-meson-spicc.c | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/drivers/spi/spi-meson-spicc.c b/drivers/spi/spi-meson-spicc.c index 7fe4488..b56249d 100644 --- a/drivers/spi/spi-meson-spicc.c +++ b/drivers/spi/spi-meson-spicc.c @@ -9,11 +9,13 @@ #include #include +#include #include #include #include #include #include +#include #include #include #include @@ -34,7 +36,6 @@ * to have a CS go down over the full transfer */ -#define SPICC_MAX_FREQ 30000000 #define SPICC_MAX_BURST 128 /* Register Map */ @@ -120,6 +121,10 @@ #define SPICC_BURST_MAX 16 #define SPICC_FIFO_HALF 10 +struct meson_spicc_data { + unsigned int max_speed_hz; +}; + struct meson_spicc_device { struct spi_master *master; struct platform_device *pdev; @@ -127,6 +132,7 @@ struct meson_spicc_device { struct clk *core; struct spi_message *message; struct spi_transfer *xfer; + const struct meson_spicc_data *data; u8 *tx_buf; u8 *rx_buf; unsigned int bytes_per_word; @@ -517,6 +523,9 @@ static int meson_spicc_probe(struct platform_device *pdev) spicc->pdev = pdev; platform_set_drvdata(pdev, spicc); + spicc->data = (const struct meson_spicc_data *) + of_device_get_match_data(&pdev->dev); + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); spicc->base = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(spicc->base)) { @@ -567,11 +576,9 @@ static int meson_spicc_probe(struct platform_device *pdev) master->unprepare_transfer_hardware = meson_spicc_unprepare_transfer; master->transfer_one = meson_spicc_transfer_one; - /* Setup max rate according to the Meson GX datasheet */ - if ((rate >> 2) > SPICC_MAX_FREQ) - master->max_speed_hz = SPICC_MAX_FREQ; - else - master->max_speed_hz = rate >> 2; + /* Setup max rate according to the Meson datasheet */ + master->max_speed_hz = min_t(unsigned int, rate >> 1, + spicc->data->max_speed_hz); ret = devm_spi_register_master(&pdev->dev, master); if (ret) { @@ -602,9 +609,23 @@ static int meson_spicc_remove(struct platform_device *pdev) return 0; } +static const struct meson_spicc_data meson_spicc_gx_data = { + .max_speed_hz = 30000000, +}; + +static const struct meson_spicc_data meson_spicc_axg_data = { + .max_speed_hz = 80000000, +}; + static const struct of_device_id meson_spicc_of_match[] = { - { .compatible = "amlogic,meson-gx-spicc", }, - { .compatible = "amlogic,meson-axg-spicc", }, + { + .compatible = "amlogic,meson-gx-spicc", + .data = &meson_spicc_gx_data, + }, + { + .compatible = "amlogic,meson-axg-spicc", + .data = &meson_spicc_axg_data, + }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, meson_spicc_of_match); -- 2.7.4