From patchwork Mon Aug 24 08:47:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinod Koul X-Patchwork-Id: 248172 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:522:0:0:0:0 with SMTP id h2csp2392799ils; Mon, 24 Aug 2020 02:37:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy2Gk1O56ovdSzrFiHJIQ0ZkaOhWOeHVkjXgz8iHFpVKL7PAW4ZzwxHzqyNUu3L3WyrbLCL X-Received: by 2002:a17:907:41dc:: with SMTP id og20mr4852363ejb.183.1598261876846; Mon, 24 Aug 2020 02:37:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598261876; cv=none; d=google.com; s=arc-20160816; b=eLxVV7EwoGDoVwBwRvlSUKvA2TFKiNGiRsmnVfsaOrFmhwNYjC+g//LcrZrSLI66Rn r/70jBxHmBLlwjFUODSm/lgMR/oZclUG4ymNyxUS57Dt037w9sQlQLhe2kwR1qih1jVj MG/h8fzPpvR7QpRxnzFNS3B5AwqbbV+rPe0mG453m+/8W73gdZhKuXG9BXpIq/R1NCm1 LiAzMC+l8N/kfoiUM4/sVZvmTKOKBIJ3ShbpNtPGZJIw28Fmzn2+fi9RYR0/KsfM4OfH mKS6kAc+TMDVFQsR+cvmjsdJxQFn5d1rmfzK+hnDAGm3K4McRi8Z5NBVK2V0IWnWTzAg 70qg== 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=N7NDsuDYpPU08mN01QyntctyjiOVPZ7DeofeNOm69z1M5qs76T9MDDMXofV8ouoPmR boLO2jvdPREdCniJbE44uWoHFUQdaLfuw1YqdiDLM8rZ27YJEJvnWoH/vVsnlFAzMB43 0fpnrRuDdYPRXaPzxTR0Vpgzr8aCzWpnUe4CIZ6qSov7JohA01RuYBQvVZ1IoyPSHrve bs7sWPbcusyICirUcu0QWVtALLLnoMsF/E91d//VvuwH1epVzAbpxdYuxM8e0ZEaMa0+ KzdLQkET9FFe4h4BlvSCTc2pogq11L+7Y86GINTOAMFFa1OJYRkXlVWkR1iLMSnxVQ2e MSZw== 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 devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-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 v7si2586804edf.94.2020.08.24.02.37.56; Mon, 24 Aug 2020 02:37:56 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-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 devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-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 S1728434AbgHXJhy (ORCPT + 6 others); Mon, 24 Aug 2020 05:37:54 -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 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@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(+) -- 2.26.2 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; }; /**