Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2017139pxa; Mon, 24 Aug 2020 02:39:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWKdJoGuqliUcWgVhtv98CIKNoCWiHpgpQJ+2kWQWvwosBHSyiSmnqpVtdjx085gJESwKe X-Received: by 2002:a50:ed02:: with SMTP id j2mr2323435eds.41.1598261986134; Mon, 24 Aug 2020 02:39:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598261986; cv=none; d=google.com; s=arc-20160816; b=krYyInSj37nU68OiKrIv5geOVb8krl+xUlJlNMTIH5n55MHycRwqEoUfHxCuj11IZI irFd1P+Un2ckbArGBAQjMpgGYWk8Yhbumxp9HEdg2DcwZnVAaGa2G2AXgTxMdatRDsn6 tBzFAFJ7LhNLPJ7tXRR97pXmpTmxfaiL+LD/BCdognBUtbgh22UYbAdLrcxBowYZv6ih KIbaa8rrJTlCRnEzgesvg1/Iy5aCeP6fBa+zDFp/GiAwMQVrVMzXJ+H6v+x8yGhLb+v0 qr4Vux0PN5l6BFqINbDm+O+xhbpSKhh3TnhUfM1E571oKqNIGWPrgxVo4VwzHmcXD+J6 uBIQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LUL8dNLEgtWqUXpu5TvFKD0wTuVv4E/uTGLz8M4y4UU=; b=fyfaZKnTVYXshBcyd3/6n/yi5mPVjPDqujdpQbSqZE/XpnszZ5heYouOdfUN1F+Unj R6uqnefLOsRKUo02+eMQuTJXSEjXOH/jWddCAVR/BiFNlq4ATbWQCu0f9L3nvSnTxFPQ 8LBnRLvApzKShhzc+BhHbTrW7+UVR0b/UZuO1VVLVHCgZ8VoycFV7SH4NWQj/xUXLks2 LcK3MmbUYWZvB/uJyT2P9TibyIOMd4RDcKrZOx3rE2crVwPD2i8jmbmr4NylEWX7zf+9 R4ZX3/5sZxwAp1l4iHFP63MU5XnKqReU9PeiND/Xt5hF1QzXalBi8kcUNMMjVOPzcbGw 3UpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0gzmVpTI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v10si6311069eds.470.2020.08.24.02.39.23; Mon, 24 Aug 2020 02:39:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0gzmVpTI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727807AbgHXJh4 (ORCPT + 99 others); Mon, 24 Aug 2020 05:37:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:47318 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727111AbgHXIr3 (ORCPT ); Mon, 24 Aug 2020 04:47:29 -0400 Received: from localhost.localdomain (unknown [122.171.38.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 28FD22072D; Mon, 24 Aug 2020 08:47:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598258848; bh=0ASM38NtqHvLkfihwuFhfZDcSaxHNeAcxdPp58Kpa4o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0gzmVpTI2iar2LvRnsjGkjkzApTW6XVndHLQEY3qt0D8XTS42IHBGP0dgVmubv0aZ FqcCNSMULXxLDNsju8mdgsXxYtQ/rm66bzd0zRfxqenI5czhowATCehVbQeJf5Q2vi WMJX1C7ea6zTVH2tEWBSvjvlt851G0WzmqythizQ= From: Vinod Koul To: dmaengine@vger.kernel.org Cc: Vinod Koul , Rob Herring , Bjorn Andersson , linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 2/3] dmaengine: add peripheral configuration Date: Mon, 24 Aug 2020 14:17:11 +0530 Message-Id: <20200824084712.2526079-3-vkoul@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200824084712.2526079-1-vkoul@kernel.org> References: <20200824084712.2526079-1-vkoul@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some complex dmaengine controllers have capability to program the peripheral device, so pass on the peripheral configuration as part of dma_slave_config Signed-off-by: Vinod Koul --- include/linux/dmaengine.h | 75 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h index 6fbd5c99e30c..264643ca9209 100644 --- a/include/linux/dmaengine.h +++ b/include/linux/dmaengine.h @@ -380,6 +380,73 @@ enum dma_slave_buswidth { DMA_SLAVE_BUSWIDTH_64_BYTES = 64, }; +/** + * enum spi_transfer_cmd - spi transfer commands + */ +enum spi_transfer_cmd { + SPI_TX = 1, + SPI_RX, + SPI_DUPLEX, +}; + +/** + * struct dmaengine_spi_config - spi config for peripheral + * + * @loopback_en: spi loopback enable when set + * @clock_pol: clock polarity + * @data_pol: data polarity + * @pack_en: process tx/rx buffers as packed + * @word_len: spi word length + * @clk_div: source clock divider + * @clk_src: serial clock + * @cmd: spi cmd + * @cs: chip select toggle + * @rx_len: receive length for spi buffer + */ +struct dmaengine_spi_config { + u8 loopback_en; + u8 clock_pol; + u8 data_pol; + u8 pack_en; + u8 word_len; + u32 clk_div; + u32 clk_src; + u8 fragmentation; + enum spi_transfer_cmd cmd; + u8 cs; + u32 rx_len; +}; + +/** + * struct dmaengine_i2c_config - i2c config for peripheral + * + * @pack_enable: process tx/rx buffers as packed + * @cycle_count: clock cycles to be sent + * @high_count: high period of clock + * @low_count: low period of clock + * @clk_div: source clock divider + * @addr: i2c bus address + * @strech: strech the clock at eot + * @op: i2c cmd + */ +struct dmaengine_i2c_config { + u8 pack_enable; + u8 cycle_count; + u8 high_count; + u8 low_count; + u16 clk_div; + u8 addr; + u8 strech; + u8 op; +}; + +enum dmaengine_peripheral { + DMAENGINE_PERIPHERAL_SPI, + DMAENGINE_PERIPHERAL_I2C, + DMAENGINE_PERIPHERAL_UART, + DMAENGINE_PERIPHERAL_LAST = DMAENGINE_PERIPHERAL_UART, +}; + /** * struct dma_slave_config - dma slave channel runtime config * @direction: whether the data shall go in or out on this slave @@ -418,6 +485,10 @@ enum dma_slave_buswidth { * @slave_id: Slave requester id. Only valid for slave channels. The dma * slave peripheral will have unique id as dma requester which need to be * pass as slave config. + * @peripheral: type of peripheral to DMA to/from + * @set_config: set peripheral config + * @spi: peripheral config for spi + * @:i2c peripheral config for i2c * * This struct is passed in as configuration data to a DMA engine * in order to set up a certain channel for DMA transport at runtime. @@ -443,6 +514,10 @@ struct dma_slave_config { u32 dst_port_window_size; bool device_fc; unsigned int slave_id; + enum dmaengine_peripheral peripheral; + u8 set_config; + struct dmaengine_spi_config spi; + struct dmaengine_i2c_config i2c; }; /** -- 2.26.2