From patchwork Mon Dec 11 23:42:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 121475 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3430709qgn; Mon, 11 Dec 2017 15:45:22 -0800 (PST) X-Google-Smtp-Source: ACJfBougEOmecaed3JIh81idUp53fsMsXNY7Goc2qqN3xzI5eCq7oehTv4wbJnuQKAf38e8J+ApU X-Received: by 10.28.9.195 with SMTP id 186mr25280wmj.122.1513035922328; Mon, 11 Dec 2017 15:45:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513035922; cv=none; d=google.com; s=arc-20160816; b=iKNqh/9SPfweIVZdYCfyb8edtT4Zll6/CE9K8ZyjhH7z+pnHpqzoW4mQkUaIU4ARqz fyff5Xo2P3K1GqdPXml8m02Q2gsYDW+jWjY1LJ400bJ8fYfZKjfQg4BQIP68jx5zGcx2 Y6WirrO8SW2H6a7cgztCuc2W4kqLXh6Fbq12BsHLKj3JoB3oVp8Bm191TW9PONoh+cKu Euoe/qMqOl391YEyIwaCw37rGA70w711EdRz55iVzc5bcsZnVk6woOGEVs59XuxM7N1e NIzc409T4wT9DMXs/OLgpWdJay8hDCYFyXRaa0ElOo0857jhEtPkgB6SFEw2IABHA0Id 7mQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to:arc-authentication-results; bh=lUvi2L7V1dhqGjM8H1ByxT+ro7/Wnr+xBwSMFKrds2U=; b=nOnrnO2QAvh1iTH+VS17YGVvykHb59aSKMux8/MrKnjWdN+2wimzQ9GDqYsagWixRo ZW4B0Q5OHG8mJDSSIyzJbhDrREvveOlPPnwEt3+Ot1dHp6YbId/AApHtzAFlun2vhf2p tZoZddG8YkjxXszhAiIkXlawI04pTDxQl3v+46ZL5HLfDwsx1FZZueYyKtPnwJxoIMQJ VSTYD+Ouo/usxD58AfAwFXbQehRlMpmoglTcdNBoTUjLMf0Zm5D5yJEm1XP72YIA3spg +pgV+SvSkF5e46CVAJKDfW/x1Yr+j2Zcp0nvx4g6ypVO/ftsC1yf7ItmDpaPqvol5vv/ FTww== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Y8l/mmzC; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id z5si11556883wrg.500.2017.12.11.15.45.22; Mon, 11 Dec 2017 15:45:22 -0800 (PST) Received-SPF: pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) client-ip=77.48.224.243; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Y8l/mmzC; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 977972676AA; Tue, 12 Dec 2017 00:45:20 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 82A4B2676B2; Tue, 12 Dec 2017 00:45:19 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS autolearn=disabled version=3.4.0 Received: from mail-wm0-f44.google.com (mail-wm0-f44.google.com [74.125.82.44]) by alsa0.perex.cz (Postfix) with ESMTP id 7F0702676AA for ; Tue, 12 Dec 2017 00:45:16 +0100 (CET) Received: by mail-wm0-f44.google.com with SMTP id 64so17186767wme.3 for ; Mon, 11 Dec 2017 15:45:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VtzlVv/nVHlPYSuMLYy7IE/ubwbbXCy2eCS6Ah+iEB0=; b=Y8l/mmzC/QT1NbCL9apVcNI6j70sF/2JYi2toczNNGZ6wZ/HlDcMqJ70IjnzVhfwu9 kprG+k5leys2/xhndT5jBP2OgC5W4YpmxCduLcRMOHvpI3q6YTppOs0db5hyQjAw7gyj 6MJ5ZFfXL53lCU+Vw62mRRd+ZdvWG4iYa1Ri8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VtzlVv/nVHlPYSuMLYy7IE/ubwbbXCy2eCS6Ah+iEB0=; b=kQoq+Sf+bsdIYq+7ZDY6Zu0sn7yB4Zq7OMmEZGytoUbWmgGbsqUsexMJu8sN8eAyW1 CXwdgtIxdUoXLjxkceDjF6eDpmP5MmOaq4JXAFCZo3lVQxz06Off67Ee0+gZWXC/yvEn TKqVyRsi7EJDLXIL/1a3rYdbIOoa1jI83d//+/8HepyJXYQ7HbnR2iYkf0nx6MlNDlB2 /8exoeY8x5sGWvqVNBvN4KIDDd/VAzH3bnUKPhlC7CG4CJ4sKUuOCD4+8pPqAx+wzBka VUP/jp5tOrrfnBVYzD/zDuWhaTdppBPtiC4RnQzYdnfkr8ywOJC2nhFHN0zfmSWXhOf/ naRg== X-Gm-Message-State: AKGB3mJMo1Q9CUx8F3VbHWfF9Vprv7V9vSFaFJf0eiq/+gqYz+QauM/W FB5SxsH/NtIaMdcmCpn6LaIQgA== X-Received: by 10.28.132.209 with SMTP id g200mr16586wmd.91.1513035915557; Mon, 11 Dec 2017 15:45:15 -0800 (PST) Received: from localhost.localdomain (cpc90716-aztw32-2-0-cust92.18-1.cable.virginm.net. [86.26.100.93]) by smtp.gmail.com with ESMTPSA id k69sm10673615wmg.8.2017.12.11.15.45.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 11 Dec 2017 15:45:15 -0800 (PST) From: srinivas.kandagatla@linaro.org To: Mark Brown , Greg Kroah-Hartman , alsa-devel@alsa-project.org Date: Mon, 11 Dec 2017 23:42:55 +0000 Message-Id: <20171211234307.14465-2-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171211234307.14465-1-srinivas.kandagatla@linaro.org> References: <20171211234307.14465-1-srinivas.kandagatla@linaro.org> Cc: Mark Rutland , devicetree@vger.kernel.org, Jonathan Corbet , linux-arm-msm@vger.kernel.org, linux-doc@vger.kernel.org, j.neuschaefer@gmx.net, linux-kernel@vger.kernel.org, Rob Herring , Srinivas Kandagatla , pombredanne@nexb.com, sdharia@codeaurora.org Subject: [alsa-devel] [PATCH v10 01/13] Documentation: Add SLIMbus summary X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org From: Sagar Dharia SLIMbus (Serial Low Power Interchip Media Bus) is a specification developed by MIPI (Mobile Industry Processor Interface) alliance. SLIMbus is a 2-wire implementation, which is used to communicate with peripheral components like audio-codec. The summary of SLIMbus and API is documented in the 'summary' file. Signed-off-by: Sagar Dharia Signed-off-by: Srinivas Kandagatla --- Documentation/driver-api/index.rst | 1 + Documentation/driver-api/slimbus.rst | 127 +++++++++++++++++++++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 Documentation/driver-api/slimbus.rst -- 2.15.0 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/Documentation/driver-api/index.rst b/Documentation/driver-api/index.rst index d17a9876b473..ef7c9e0b179c 100644 --- a/Documentation/driver-api/index.rst +++ b/Documentation/driver-api/index.rst @@ -47,6 +47,7 @@ available subsections can be seen below. gpio misc_devices dmaengine/index + slimbus .. only:: subproject and html diff --git a/Documentation/driver-api/slimbus.rst b/Documentation/driver-api/slimbus.rst new file mode 100644 index 000000000000..7555ecd538de --- /dev/null +++ b/Documentation/driver-api/slimbus.rst @@ -0,0 +1,127 @@ +============================ +Linux kernel SLIMbus support +============================ + +Overview +======== + +What is SLIMbus? +---------------- +SLIMbus (Serial Low Power Interchip Media Bus) is a specification developed by +MIPI (Mobile Industry Processor Interface) alliance. The bus uses master/slave +configuration, and is a 2-wire multi-drop implementation (clock, and data). + +Currently, SLIMbus is used to interface between application processors of SoCs +(System-on-Chip) and peripheral components (typically codec). SLIMbus uses +Time-Division-Multiplexing to accommodate multiple data channels, and +a control channel. + +The control channel is used for various control functions such as bus +management, configuration and status updates. These messages can be unicast (e.g. +reading/writing device specific values), or multicast (e.g. data channel +reconfiguration sequence is a broadcast message announced to all devices) + +A data channel is used for data-transfer between 2 SLIMbus devices. Data +channel uses dedicated ports on the device. + +Hardware description: +--------------------- +SLIMbus specification has different types of device classifications based on +their capabilities. +A manager device is responsible for enumeration, configuration, and dynamic +channel allocation. Every bus has 1 active manager. + +A generic device is a device providing application functionality (e.g. codec). + +Framer device is responsible for clocking the bus, and transmitting frame-sync +and framing information on the bus. + +Each SLIMbus component has an interface device for monitoring physical layer. + +Typically each SoC contains SLIMbus component having 1 manager, 1 framer device, +1 generic device (for data channel support), and 1 interface device. +External peripheral SLIMbus component usually has 1 generic device (for +functionality/data channel support), and an associated interface device. +The generic device's registers are mapped as 'value elements' so that they can +be written/read using SLIMbus control channel exchanging control/status type of +information. +In case there are multiple framer devices on the same bus, manager device is +responsible to select the active-framer for clocking the bus. + +Per specification, SLIMbus uses "clock gears" to do power management based on +current frequency and bandwidth requirements. There are 10 clock gears and each +gear changes the SLIMbus frequency to be twice its previous gear. + +Each device has a 6-byte enumeration-address and the manager assigns every +device with a 1-byte logical address after the devices report presence on the +bus. + +Software description: +--------------------- +There are 2 types of SLIMbus drivers: + +slim_controller represents a 'controller' for SLIMbus. This driver should +implement duties needed by the SoC (manager device, associated +interface device for monitoring the layers and reporting errors, default +framer device). + +slim_device represents the 'generic device/component' for SLIMbus, and a +slim_driver should implement driver for that slim_device. + +Device notifications to the driver: +----------------------------------- +Since SLIMbus devices have mechanisms for reporting their presence, the +framework allows drivers to bind when corresponding devices report their +presence on the bus. +However, it is possible that the driver needs to be probed +first so that it can enable corresponding SLIMbus device (e.g. power it up and/or +take it out of reset). To support that behavior, the framework allows drivers +to probe first as well (e.g. using standard DeviceTree compatibility field). +This creates the necessity for the driver to know when the device is functional +(i.e. reported present). device_up callback is used for that reason when the +device reports present and is assigned a logical address by the controller. + +Similarly, SLIMbus devices 'report absent' when they go down. A 'device_down' +callback notifies the driver when the device reports absent and its logical +address assignment is invalidated by the controller. + +Another notification "boot_device" is used to notify the slim_driver when +controller resets the bus. This notification allows the driver to take necessary +steps to boot the device so that it's functional after the bus has been reset. + +Driver and Controller APIs: +-------------------------- +.. kernel-doc:: include/linux/slimbus.h + :internal: + +.. kernel-doc:: drivers/slimbus/slimbus.h + :internal: + +.. kernel-doc:: drivers/slimbus/core.c + :export: + +Clock-pause: +------------ +SLIMbus mandates that a reconfiguration sequence (known as clock-pause) be +broadcast to all active devices on the bus before the bus can enter low-power +mode. Controller uses this sequence when it decides to enter low-power mode so +that corresponding clocks and/or power-rails can be turned off to save power. +Clock-pause is exited by waking up framer device (if controller driver initiates +exiting low power mode), or by toggling the data line (if a slave device wants +to initiate it). + +Clock-pause APIs: +~~~~~~~~~~~~~~~~~ +.. kernel-doc:: drivers/slimbus/sched.c + :export: + +Messaging: +---------- +The framework supports regmap and read/write apis to exchange control-information +with a SLIMbus device. APIs can be synchronous or asynchronous. +The header file has more documentation about messaging APIs. + +Messaging APIs: +~~~~~~~~~~~~~~~ +.. kernel-doc:: drivers/slimbus/messaging.c + :export: From patchwork Mon Dec 11 23:42:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 121480 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3431602qgn; Mon, 11 Dec 2017 15:46:35 -0800 (PST) X-Google-Smtp-Source: ACJfBosPg9xgk5uciGjx8HDMoqlA/gvrsHkgp+CBBvjoN9PS46ttgwyACbU3kZlA90FtwyR/sf7s X-Received: by 10.28.6.21 with SMTP id 21mr19542wmg.73.1513035995104; Mon, 11 Dec 2017 15:46:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513035995; cv=none; d=google.com; s=arc-20160816; b=gwlPzOki/uE7OsA9LnDVip1mqcwky6uw205i5BK8Udr4Eb4rd8J/kseids7hU/LVdW IMSNCOg8phjaG5ymAbJk9/FB91w0lAlNq3Hst+97m3G+PB2U5+Fiss3b6zZRrNndhokW QgOS82bM/0ue59Ea9k+RetuL9hR4DeX9+xoX+v6LosEd+bthIYXnYN/bAMTjfYgVcFk5 1m825WuvScBxvpwzH/KBzel41mrhITeQD6ePgdZmgAw7hruosl4VhSajQDgfeXKUloBX Ip6hQy0ZxqmM0tvkcDNu+AWLkJCvC9vHznJBT0P1ZxmgB9VxgY86vjlTdhjcxRZ1veyo rrqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to:arc-authentication-results; bh=XjTh8ZBINCCum29OYBy1iZWmG6h0dWlks29zWwJJqZ0=; b=n44dUkSXWVqTevB6X8BJFbTMcLpKso4lowguNCJYjCVlQaIG+goCx1hwW3jccHTWDO krdL70agNEaeCMMWsReL8x2QbJPoNNHFWiILRcC+IYl5qj6xgVvEdHJU6NdTYS4B4gBD pzvwlp3l22TgulGU7/lFLqAc4/BjxtQtz6b/R9b+q8uBa4+/XwgvdtXjJ7owh5a0P1eF QjNbozLy/cNloiHtoP3F9rZciBIroJmHOL+Gqz/+xV5A6N5HRJo4tFqLl5KJjGFnMADz o02zexvYQ9Nbao4+6+Dc9RlOJeDeei9I+VpEMnx4XwdmlHX+6hHFE67mjMZSpp8iwqo1 VPoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=K+IbNl4e; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id i39si11354185wrf.525.2017.12.11.15.46.34; Mon, 11 Dec 2017 15:46:35 -0800 (PST) Received-SPF: pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) client-ip=77.48.224.243; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=K+IbNl4e; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 6B3172676E0; Tue, 12 Dec 2017 00:45:28 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id D008C2676C4; Tue, 12 Dec 2017 00:45:22 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS autolearn=disabled version=3.4.0 Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by alsa0.perex.cz (Postfix) with ESMTP id 1CD442676BA for ; Tue, 12 Dec 2017 00:45:20 +0100 (CET) Received: by mail-wm0-f65.google.com with SMTP id n138so17566175wmg.2 for ; Mon, 11 Dec 2017 15:45:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=uusZXetr52IXQdNFOPhM9nTXZOoziAuIWidBdYknQ5M=; b=K+IbNl4ew3RePZph4q+WhYeq9xdhj+bGtOp0ywgmD0krZ4FQNBMBYJYZXCzvraxg5l fKpCFeh/ET6SfTQBrtAzAZwpDtd+iomqp2GofRyabahWKr8a/Y+5uugqrIr2l1xXoSIx OoVqUaH4d1YERz4Z5HB5fLJLKs9nZqrFz8uMM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=uusZXetr52IXQdNFOPhM9nTXZOoziAuIWidBdYknQ5M=; b=Ju5Nl1tEA8YWwZnjbMoUjwgma1MKb15N6tZY7dFGqwy0qNmBFjvwiGdoR7iJ/pqrYM 3i013X+ncfXymsmbbcxaMrx8U8mcvzXQtMfnlcfUn0800Ron5ZxyhKfUqgpLV74ahTo4 rArjnI9NBzYeo0BijH0LnWjyaa5yOWrGbcanMDiV8ToqAfn9Auqe3lF+W7wLAzgFr6/l pNeD2Mdc7BBqw/08zitJ/yhioN8GS+iwfnCz2h8PDMndpONB5mXSGyBDuyij5stUC66+ 6d19frovnTYKTN9P6U2nwqYqbs8nb3qUxVoBzDuClwihueToy2tWDWG+XcSzgCpsfvG9 kZqg== X-Gm-Message-State: AKGB3mJNn+r+hAs/UbttOByDU+TumTGqMWM5AxgIhjziHWEGOeVyu7dq G4c1uz59CzQgOraTS3aDmASUhg== X-Received: by 10.28.55.72 with SMTP id e69mr24346wma.154.1513035920574; Mon, 11 Dec 2017 15:45:20 -0800 (PST) Received: from localhost.localdomain (cpc90716-aztw32-2-0-cust92.18-1.cable.virginm.net. [86.26.100.93]) by smtp.gmail.com with ESMTPSA id k69sm10673615wmg.8.2017.12.11.15.45.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 11 Dec 2017 15:45:19 -0800 (PST) From: srinivas.kandagatla@linaro.org To: Mark Brown , Greg Kroah-Hartman , alsa-devel@alsa-project.org Date: Mon, 11 Dec 2017 23:42:59 +0000 Message-Id: <20171211234307.14465-6-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171211234307.14465-1-srinivas.kandagatla@linaro.org> References: <20171211234307.14465-1-srinivas.kandagatla@linaro.org> Cc: Mark Rutland , devicetree@vger.kernel.org, Jonathan Corbet , linux-arm-msm@vger.kernel.org, linux-doc@vger.kernel.org, j.neuschaefer@gmx.net, linux-kernel@vger.kernel.org, Rob Herring , Srinivas Kandagatla , pombredanne@nexb.com, sdharia@codeaurora.org Subject: [alsa-devel] [PATCH v10 05/13] slimbus: core: add support to device tree helper X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org From: Srinivas Kandagatla This patch adds support to parse slim devices from device tree. Signed-off-by: Srinivas Kandagatla --- drivers/slimbus/core.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) -- 2.15.0 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/drivers/slimbus/core.c b/drivers/slimbus/core.c index ed53ae6bd1cc..1accb20ed5cd 100644 --- a/drivers/slimbus/core.c +++ b/drivers/slimbus/core.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include "slimbus.h" @@ -113,6 +114,9 @@ static int slim_add_device(struct slim_controller *ctrl, sbdev->dev.driver = NULL; sbdev->ctrl = ctrl; + if (node) + sbdev->dev.of_node = of_node_get(node); + dev_set_name(&sbdev->dev, "%x:%x:%x:%x", sbdev->e_addr.manf_id, sbdev->e_addr.prod_code, @@ -143,6 +147,50 @@ static struct slim_device *slim_alloc_device(struct slim_controller *ctrl, return sbdev; } +static void of_register_slim_devices(struct slim_controller *ctrl) +{ + struct device *dev = ctrl->dev; + struct device_node *node; + + if (!ctrl->dev->of_node) + return; + + for_each_child_of_node(ctrl->dev->of_node, node) { + struct slim_device *sbdev; + struct slim_eaddr e_addr; + const char *compat = NULL; + int reg[2], ret; + int manf_id, prod_code; + + compat = of_get_property(node, "compatible", NULL); + if (!compat) + continue; + + ret = sscanf(compat, "slim%x,%x", &manf_id, &prod_code); + if (ret != 2) { + dev_err(dev, "Manf ID & Product code not found %s\n", + compat); + continue; + } + + ret = of_property_read_u32_array(node, "reg", reg, 2); + if (ret) { + dev_err(dev, "Device and Instance id not found:%d\n", + ret); + continue; + } + + e_addr.dev_index = reg[0]; + e_addr.instance = reg[1]; + e_addr.manf_id = manf_id; + e_addr.prod_code = prod_code; + + sbdev = slim_alloc_device(ctrl, &e_addr, node); + if (!sbdev) + continue; + } +} + /* * slim_register_controller() - Controller bring-up and registration. * @@ -174,6 +222,8 @@ int slim_register_controller(struct slim_controller *ctrl) dev_dbg(ctrl->dev, "Bus [%s] registered:dev:%p\n", ctrl->name, ctrl->dev); + of_register_slim_devices(ctrl); + return 0; } EXPORT_SYMBOL_GPL(slim_register_controller); From patchwork Mon Dec 11 23:43:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 121481 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3431787qgn; Mon, 11 Dec 2017 15:46:51 -0800 (PST) X-Google-Smtp-Source: ACJfBouT1H008QNKbI/ldhjn0iN2M3fg2OxFtPe0l9m7Kx+AmG4HHvZ+Ih8KLnXtb83p/in/W8YC X-Received: by 10.28.194.11 with SMTP id s11mr13618wmf.143.1513036011184; Mon, 11 Dec 2017 15:46:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513036011; cv=none; d=google.com; s=arc-20160816; b=OhY6nk6vsyjMKBZMf0PsmULsPYtjf2NdBq4KeSjNjkvrZcMntJX6hZrnQlPB/K4cnj MOffGGNsKdtyeAGMqwjVH7m/QdM5qjdMsUG0ul4XrfqIqtIULOKvVLAPkh8rENbSLVb1 5VZwAdBUGfXPXZZkCFOulGmj1gALT0+9PELKIPGkdqiwljq3u7SjdIl/9Cwit8liv2Tr MhgXlNPerkpjKBO/OrMAZDoipANR86I/X5Xrr9Hq3bO/tw8iMDfIU/4cMj4/ZOU9Q4s9 g7YfxYV76WO0AIyDuSTxsmWYsbEmTLLdtAToLVKwrenF+Brp8i4sy5PWrlc2pp1wln6L PvOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to:arc-authentication-results; bh=qg64e9TY83hHIdhG7K3dQrILnGST2GfK6L9LuMFvd2E=; b=0u8/fU8DEOxZ8Y8rEWnHk31S4jL+dYGlH0szVWQeGWy+8Os97eUuUetIvEdhwB0Yq/ Ay9yIUTfoxocgO8GCpUqwCGIXx4UGIA0j3xpobsQ7Pb5S+6O2Ftuz9/uOoZQwXyjFu0P b66slj0bxACYbPiOLEV2gJNIWHnBkUfMawsdfYSEdCXerYoV7ndUnVRnwIfDwCKW3S25 /Tjg2H9Eg24gNzt1L30ux7IJEQmR79FwA052VUiUB37xIE8tiEr4eIh05AumV1DgUzeh z5s4txR/tYQNG7JcrSF8xp7Gq4MexGMzu8xscyNpe9iilGDoFKJe7s1BecM3hpUQvYHh tZ0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=V8O5SRJ6; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id 15si1149406wmu.274.2017.12.11.15.46.50; Mon, 11 Dec 2017 15:46:51 -0800 (PST) Received-SPF: pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) client-ip=77.48.224.243; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=V8O5SRJ6; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 3672B2676ED; Tue, 12 Dec 2017 00:45:29 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id DAF9D2676C9; Tue, 12 Dec 2017 00:45:25 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS autolearn=disabled version=3.4.0 Received: from mail-wm0-f47.google.com (mail-wm0-f47.google.com [74.125.82.47]) by alsa0.perex.cz (Postfix) with ESMTP id CD5582676C4 for ; Tue, 12 Dec 2017 00:45:22 +0100 (CET) Received: by mail-wm0-f47.google.com with SMTP id g130so15251143wme.0 for ; Mon, 11 Dec 2017 15:45:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=knVHKosbS3nbpd+2B5jJKtW5Ojd9ov/PAXCe/VuYA0s=; b=V8O5SRJ6AmInC6XiPwMXNK42Xc6cf34TvaCalPl40eqzSuOkj2YiS3xam74T80I+E3 lmm4ukdOLc+aIIiblMY4vFnPv33NvUu50fboHOSlFhezlsCgrM0izvJtaQbxx0XK5DMf PgTcnu7iwzZSptf7E/0t6cjgBXwNbKoZdlV1E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=knVHKosbS3nbpd+2B5jJKtW5Ojd9ov/PAXCe/VuYA0s=; b=ZHbRQt/MI3tdvYEO6cAk+SyBTBPO6MQdWYz8iSd+yWICmGAuGTtakvtyXpGgAwfoeq gjWOoh3gaoxfM8RoSKs1PC82Kg7d5aLHU5bi6J+Xp8ZpdBMV01RDjxvucIGmwZWRsBDk EweciaST5bkKGm2U/WEsbdOmrc4j75bXCAeejDDuEacPZ8KJLhC8f0FEYHZcX2KyMcQs YBsGD4yb7EJafpZPVuG566hXfJd4ZGvY/lctV4GY8aIdnCuW+G/GHm5fCi9T7u4WP17j z6NeNWc3hAuc+pwTQj36HO6LCa+lgSLH8O3uFDmnEI8UK23RFP41V4kGYrS08IoIGRuk jGlA== X-Gm-Message-State: AKGB3mLYmdQ0c3I+pwdaWzNMLRO4yOBl1QFMad42BY4nUITiBdqKHdeA Zu202y0+gx/oKuuOZ9FYmC4Wog== X-Received: by 10.28.178.135 with SMTP id b129mr15242wmf.103.1513035921917; Mon, 11 Dec 2017 15:45:21 -0800 (PST) Received: from localhost.localdomain (cpc90716-aztw32-2-0-cust92.18-1.cable.virginm.net. [86.26.100.93]) by smtp.gmail.com with ESMTPSA id k69sm10673615wmg.8.2017.12.11.15.45.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 11 Dec 2017 15:45:21 -0800 (PST) From: srinivas.kandagatla@linaro.org To: Mark Brown , Greg Kroah-Hartman , alsa-devel@alsa-project.org Date: Mon, 11 Dec 2017 23:43:00 +0000 Message-Id: <20171211234307.14465-7-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171211234307.14465-1-srinivas.kandagatla@linaro.org> References: <20171211234307.14465-1-srinivas.kandagatla@linaro.org> Cc: Mark Rutland , devicetree@vger.kernel.org, Jonathan Corbet , linux-arm-msm@vger.kernel.org, linux-doc@vger.kernel.org, j.neuschaefer@gmx.net, linux-kernel@vger.kernel.org, Rob Herring , Srinivas Kandagatla , pombredanne@nexb.com, sdharia@codeaurora.org Subject: [alsa-devel] [PATCH v10 06/13] slimbus: Add messaging APIs to slimbus framework X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org From: Sagar Dharia SLIMbus devices use value-element, and information elements to control device parameters (e.g. value element is used to represent gain for codec, information element is used to represent interrupt status for codec when codec interrupt fires). Messaging APIs are used to set/get these value and information elements. SLIMbus specification uses 8-bit "transaction IDs" for messages where a read-value is anticipated. Framework uses a table of pointers to store those TIDs and responds back to the caller in O(1). Caller can do synchronous and asynchronous reads/writes. Signed-off-by: Srinivas Kandagatla --- drivers/slimbus/Makefile | 2 +- drivers/slimbus/messaging.c | 297 ++++++++++++++++++++++++++++++++++++++++++++ drivers/slimbus/slimbus.h | 67 ++++++++++ include/linux/slimbus.h | 40 ++++++ 4 files changed, 405 insertions(+), 1 deletion(-) create mode 100644 drivers/slimbus/messaging.c -- 2.15.0 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/drivers/slimbus/Makefile b/drivers/slimbus/Makefile index 506ff17d6346..568a14c7be78 100644 --- a/drivers/slimbus/Makefile +++ b/drivers/slimbus/Makefile @@ -3,4 +3,4 @@ # Makefile for kernel SLIMbus framework. # obj-$(CONFIG_SLIMBUS) += slimbus.o -slimbus-y := core.o +slimbus-y := core.o messaging.o diff --git a/drivers/slimbus/messaging.c b/drivers/slimbus/messaging.c new file mode 100644 index 000000000000..031e67648d7c --- /dev/null +++ b/drivers/slimbus/messaging.c @@ -0,0 +1,297 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2011-2017, The Linux Foundation + */ + +#include +#include "slimbus.h" + +/** + * slim_msg_response() - Deliver Message response received from a device to the + * framework. + * + * @ctrl: Controller handle + * @reply: Reply received from the device + * @len: Length of the reply + * @tid: Transaction ID received with which framework can associate reply. + * + * Called by controller to inform framework about the response received. + * This helps in making the API asynchronous, and controller-driver doesn't need + * to manage 1 more table other than the one managed by framework mapping TID + * with buffers + */ +void slim_msg_response(struct slim_controller *ctrl, u8 *reply, u8 tid, u8 len) +{ + struct slim_msg_txn *txn; + struct slim_val_inf *msg; + unsigned long flags; + + spin_lock_irqsave(&ctrl->txn_lock, flags); + txn = idr_find(&ctrl->tid_idr, tid); + if (txn == NULL) { + spin_unlock_irqrestore(&ctrl->txn_lock, flags); + return; + } + + msg = txn->msg; + if (msg == NULL || msg->rbuf == NULL) { + dev_err(ctrl->dev, "Got response to invalid TID:%d, len:%d\n", + tid, len); + return; + } + + idr_remove(&ctrl->tid_idr, tid); + spin_unlock_irqrestore(&ctrl->txn_lock, flags); + + memcpy(msg->rbuf, reply, len); + if (txn->comp) + complete(txn->comp); +} +EXPORT_SYMBOL_GPL(slim_msg_response); + +/** + * slim_do_transfer() - Process a SLIMbus-messaging transaction + * + * @ctrl: Controller handle + * @txn: Transaction to be sent over SLIMbus + * + * Called by controller to transmit messaging transactions not dealing with + * Interface/Value elements. (e.g. transmittting a message to assign logical + * address to a slave device + * + * Return: -ETIMEDOUT: If transmission of this message timed out + * (e.g. due to bus lines not being clocked or driven by controller) + */ +int slim_do_transfer(struct slim_controller *ctrl, struct slim_msg_txn *txn) +{ + DECLARE_COMPLETION_ONSTACK(done); + bool need_tid; + unsigned long flags; + int ret, tid, timeout; + + need_tid = slim_tid_txn(txn->mt, txn->mc); + + if (need_tid) { + spin_lock_irqsave(&ctrl->txn_lock, flags); + tid = idr_alloc(&ctrl->tid_idr, txn, 0, + SLIM_MAX_TIDS, GFP_KERNEL); + txn->tid = tid; + + if (!txn->msg->comp) + txn->comp = &done; + else + txn->comp = txn->comp; + + spin_unlock_irqrestore(&ctrl->txn_lock, flags); + + if (tid < 0) + return tid; + } + + ret = ctrl->xfer_msg(ctrl, txn); + + if (ret && need_tid && !txn->msg->comp) { + unsigned long ms = txn->rl + HZ; + + timeout = wait_for_completion_timeout(txn->comp, + msecs_to_jiffies(ms)); + if (!timeout) { + ret = -ETIMEDOUT; + spin_lock_irqsave(&ctrl->txn_lock, flags); + idr_remove(&ctrl->tid_idr, tid); + spin_unlock_irqrestore(&ctrl->txn_lock, flags); + } + } + + if (ret) + dev_err(ctrl->dev, "Tx:MT:0x%x, MC:0x%x, LA:0x%x failed:%d\n", + txn->mt, txn->mc, txn->la, ret); + + return ret; +} +EXPORT_SYMBOL_GPL(slim_do_transfer); + +static int slim_val_inf_sanity(struct slim_controller *ctrl, + struct slim_val_inf *msg, u8 mc) +{ + if (!msg || msg->num_bytes > 16 || + (msg->start_offset + msg->num_bytes) > 0xC00) + goto reterr; + switch (mc) { + case SLIM_MSG_MC_REQUEST_VALUE: + case SLIM_MSG_MC_REQUEST_INFORMATION: + if (msg->rbuf != NULL) + return 0; + break; + + case SLIM_MSG_MC_CHANGE_VALUE: + case SLIM_MSG_MC_CLEAR_INFORMATION: + if (msg->wbuf != NULL) + return 0; + break; + + case SLIM_MSG_MC_REQUEST_CHANGE_VALUE: + case SLIM_MSG_MC_REQUEST_CLEAR_INFORMATION: + if (msg->rbuf != NULL && msg->wbuf != NULL) + return 0; + break; + } +reterr: + dev_err(ctrl->dev, "Sanity check failed:msg:offset:0x%x, mc:%d\n", + msg->start_offset, mc); + return -EINVAL; +} + +static u16 slim_slicesize(int code) +{ + static const u8 sizetocode[16] = { + 0, 1, 2, 3, 3, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7 + }; + + clamp(code, 1, (int)ARRAY_SIZE(sizetocode)); + + return sizetocode[code - 1]; +} + +/** + * slim_xfer_msg() - Transfer a value info message on slim device + * + * @sbdev: slim device to which this msg has to be transfered + * @msg: value info message pointer + * @mc: message code of the message + * + * Called by drivers which want to transfer a vlaue or info elements. + * + * Return: -ETIMEDOUT: If transmission of this message timed out + */ +int slim_xfer_msg(struct slim_device *sbdev, struct slim_val_inf *msg, + u8 mc) +{ + DEFINE_SLIM_LDEST_TXN(txn_stack, mc, 6, sbdev->laddr, msg); + struct slim_msg_txn *txn = &txn_stack; + struct slim_controller *ctrl = sbdev->ctrl; + int ret; + u16 sl; + + if (!ctrl) + return -EINVAL; + + ret = slim_val_inf_sanity(ctrl, msg, mc); + if (ret) + return ret; + + sl = slim_slicesize(msg->num_bytes); + + dev_dbg(ctrl->dev, "SB xfer msg:os:%x, len:%d, MC:%x, sl:%x\n", + msg->start_offset, msg->num_bytes, mc, sl); + + txn->ec = ((sl | (1 << 3)) | ((msg->start_offset & 0xFFF) << 4)); + + switch (mc) { + case SLIM_MSG_MC_REQUEST_CHANGE_VALUE: + case SLIM_MSG_MC_CHANGE_VALUE: + case SLIM_MSG_MC_REQUEST_CLEAR_INFORMATION: + case SLIM_MSG_MC_CLEAR_INFORMATION: + txn->rl += msg->num_bytes; + default: + break; + } + + if (slim_tid_txn(txn->mt, txn->mc)) + txn->rl++; + + return slim_do_transfer(ctrl, txn); +} +EXPORT_SYMBOL_GPL(slim_xfer_msg); + +static void slim_fill_msg(struct slim_val_inf *msg, u32 addr, + size_t count, u8 *rbuf, u8 *wbuf) +{ + msg->start_offset = addr; + msg->num_bytes = count; + msg->rbuf = rbuf; + msg->wbuf = wbuf; +} + +/** + * slim_read() - Read SLIMbus value element + * + * @sdev: client handle. + * @addr: address of value element to read. + * @count: number of bytes to read. Maximum bytes allowed are 16. + * @val: will return what the value element value was + * + * Return: -EINVAL for Invalid parameters, -ETIMEDOUT If transmission of + * this message timed out (e.g. due to bus lines not being clocked + * or driven by controller) + */ +int slim_read(struct slim_device *sdev, u32 addr, size_t count, u8 *val) +{ + struct slim_val_inf msg; + + slim_fill_msg(&msg, addr, count, val, NULL); + + return slim_xfer_msg(sdev, &msg, SLIM_MSG_MC_REQUEST_VALUE); +} +EXPORT_SYMBOL_GPL(slim_read); + +/** + * slim_readb() - Read byte from SLIMbus value element + * + * @sdev: client handle. + * @addr: address in the value element to read. + * + * Return: byte value of value element. + */ +int slim_readb(struct slim_device *sdev, u32 addr) +{ + int ret; + u8 buf; + + ret = slim_read(sdev, addr, 1, &buf); + if (ret < 0) + return ret; + else + return buf; +} +EXPORT_SYMBOL_GPL(slim_readb); + +/** + * slim_write() - Write SLIMbus value element + * + * @sdev: client handle. + * @addr: address in the value element to write. + * @count: number of bytes to write. Maximum bytes allowed are 16. + * @val: value to write to value element + * + * Return: -EINVAL for Invalid parameters, -ETIMEDOUT If transmission of + * this message timed out (e.g. due to bus lines not being clocked + * or driven by controller) + */ +int slim_write(struct slim_device *sdev, u32 addr, size_t count, u8 *val) +{ + struct slim_val_inf msg; + + slim_fill_msg(&msg, addr, count, val, NULL); + + return slim_xfer_msg(sdev, &msg, SLIM_MSG_MC_CHANGE_VALUE); +} +EXPORT_SYMBOL_GPL(slim_write); + +/** + * slim_writeb() - Write byte to SLIMbus value element + * + * @sdev: client handle. + * @addr: address of value element to write. + * @value: value to write to value element + * + * Return: -EINVAL for Invalid parameters, -ETIMEDOUT If transmission of + * this message timed out (e.g. due to bus lines not being clocked + * or driven by controller) + * + */ +int slim_writeb(struct slim_device *sdev, u32 addr, u8 value) +{ + return slim_write(sdev, addr, 1, &value); +} +EXPORT_SYMBOL_GPL(slim_writeb); diff --git a/drivers/slimbus/slimbus.h b/drivers/slimbus/slimbus.h index 66657722f50f..0d40c2578c28 100644 --- a/drivers/slimbus/slimbus.h +++ b/drivers/slimbus/slimbus.h @@ -8,8 +8,17 @@ #include #include #include +#include #include +/* SLIMbus message types. Related to interpretation of message code. */ +#define SLIM_MSG_MT_CORE 0x0 + +/* Destination type Values */ +#define SLIM_MSG_DEST_LOGICALADDR 0 +#define SLIM_MSG_DEST_ENUMADDR 1 +#define SLIM_MSG_DEST_BROADCAST 3 + /* Standard values per SLIMbus spec needed by controllers and devices */ #define SLIM_MAX_CLK_GEAR 10 #define SLIM_MIN_CLK_GEAR 1 @@ -17,6 +26,7 @@ /* Manager's logical address is set to 0xFF per spec */ #define SLIM_LA_MANAGER 0xFF +#define SLIM_MAX_TIDS 256 /** * struct slim_framer - Represents SLIMbus framer. * Every controller may have multiple framers. There is 1 active framer device @@ -37,6 +47,39 @@ struct slim_framer { #define to_slim_framer(d) container_of(d, struct slim_framer, dev) +/** + * struct slim_msg_txn - Message to be sent by the controller. + * This structure has packet header, + * payload and buffer to be filled (if any) + * @rl: Header field. remaining length. + * @mt: Header field. Message type. + * @mc: Header field. LSB is message code for type mt. + * @dt: Header field. Destination type. + * @ec: Element code. Used for elemental access APIs. + * @tid: Transaction ID. Used for messages expecting response. + * (relevant for message-codes involving read operation) + * @la: Logical address of the device this message is going to. + * (Not used when destination type is broadcast.) + * @msg: Elemental access message to be read/written + * @comp: completion if read/write is synchronous, used internally + * for tid based transactions. + */ +struct slim_msg_txn { + u8 rl; + u8 mt; + u8 mc; + u8 dt; + u16 ec; + u8 tid; + u8 la; + struct slim_val_inf *msg; + struct completion *comp; +}; + +/* Frequently used message transaction structures */ +#define DEFINE_SLIM_LDEST_TXN(name, mc, rl, la, msg) \ + struct slim_msg_txn name = { rl, 0, mc, SLIM_MSG_DEST_LOGICALADDR, 0,\ + 0, la, msg, } /** * struct slim_controller - Controls every instance of SLIMbus * (similar to 'master' on SPI) @@ -52,6 +95,9 @@ struct slim_framer { * @devices: Slim device list * @tid_idr: tid id allocator * @txn_lock: Lock to protect table of transactions + * @xfer_msg: Transfer a message on this controller (this can be a broadcast + * control/status message like data channel setup, or a unicast message + * like value element read/write. * @set_laddr: Setup logical address at laddr for the slave with elemental * address e_addr. Drivers implementing controller will be expected to * send unicast message to this device with its logical address. @@ -93,6 +139,8 @@ struct slim_controller { struct list_head devices; struct idr tid_idr; spinlock_t txn_lock; + int (*xfer_msg)(struct slim_controller *ctrl, + struct slim_msg_txn *tx); int (*set_laddr)(struct slim_controller *ctrl, struct slim_eaddr *ea, u8 laddr); int (*get_laddr)(struct slim_controller *ctrl, @@ -104,5 +152,24 @@ int slim_device_report_present(struct slim_controller *ctrl, void slim_report_absent(struct slim_device *sbdev); int slim_register_controller(struct slim_controller *ctrl); int slim_unregister_controller(struct slim_controller *ctrl); +void slim_msg_response(struct slim_controller *ctrl, u8 *reply, u8 tid, u8 l); +int slim_do_transfer(struct slim_controller *ctrl, struct slim_msg_txn *txn); + +static inline bool slim_tid_txn(u8 mt, u8 mc) +{ + return (mt == SLIM_MSG_MT_CORE && + (mc == SLIM_MSG_MC_REQUEST_INFORMATION || + mc == SLIM_MSG_MC_REQUEST_CLEAR_INFORMATION || + mc == SLIM_MSG_MC_REQUEST_VALUE || + mc == SLIM_MSG_MC_REQUEST_CLEAR_INFORMATION)); +} +static inline bool slim_ec_txn(u8 mt, u8 mc) +{ + return (mt == SLIM_MSG_MT_CORE && + ((mc >= SLIM_MSG_MC_REQUEST_INFORMATION && + mc <= SLIM_MSG_MC_REPORT_INFORMATION) || + (mc >= SLIM_MSG_MC_REQUEST_VALUE && + mc <= SLIM_MSG_MC_CHANGE_VALUE))); +} #endif /* _LINUX_SLIMBUS_H */ diff --git a/include/linux/slimbus.h b/include/linux/slimbus.h index aeed98a683be..c36cf121d2cd 100644 --- a/include/linux/slimbus.h +++ b/include/linux/slimbus.h @@ -7,6 +7,7 @@ #define _LINUX_SLIMBUS_H #include #include +#include #include extern struct bus_type slimbus_bus; @@ -88,6 +89,25 @@ struct slim_driver { }; #define to_slim_driver(d) container_of(d, struct slim_driver, driver) +/** + * struct slim_val_inf - Slimbus value or information element + * @start_offset: Specifies starting offset in information/value element map + * @rbuf: buffer to read the values + * @wbuf: buffer to write + * @num_bytes: upto 16. This ensures that the message will fit the slicesize + * per SLIMbus spec + * @comp: completion for asynchronous operations, valid only if TID is + * required for transaction, like REQUEST operations. + * Rest of the transactions are synchronous anyway. + */ +struct slim_val_inf { + u16 start_offset; + u8 num_bytes; + u8 *rbuf; + const u8 *wbuf; + struct completion *comp; +}; + /* * use a macro to avoid include chaining to get THIS_MODULE */ @@ -121,4 +141,24 @@ static inline void slim_set_devicedata(struct slim_device *dev, void *data) struct slim_device *slim_get_device(struct slim_controller *ctrl, struct slim_eaddr *e_addr); int slim_get_logical_addr(struct slim_device *sbdev); + +/* Information Element management messages */ +#define SLIM_MSG_MC_REQUEST_INFORMATION 0x20 +#define SLIM_MSG_MC_REQUEST_CLEAR_INFORMATION 0x21 +#define SLIM_MSG_MC_REPLY_INFORMATION 0x24 +#define SLIM_MSG_MC_CLEAR_INFORMATION 0x28 +#define SLIM_MSG_MC_REPORT_INFORMATION 0x29 + +/* Value Element management messages */ +#define SLIM_MSG_MC_REQUEST_VALUE 0x60 +#define SLIM_MSG_MC_REQUEST_CHANGE_VALUE 0x61 +#define SLIM_MSG_MC_REPLY_VALUE 0x64 +#define SLIM_MSG_MC_CHANGE_VALUE 0x68 + +int slim_xfer_msg(struct slim_device *sbdev, struct slim_val_inf *msg, + u8 mc); +int slim_readb(struct slim_device *sdev, u32 addr); +int slim_writeb(struct slim_device *sdev, u32 addr, u8 value); +int slim_read(struct slim_device *sdev, u32 addr, size_t count, u8 *val); +int slim_write(struct slim_device *sdev, u32 addr, size_t count, u8 *val); #endif /* _LINUX_SLIMBUS_H */ From patchwork Mon Dec 11 23:43:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 121485 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3432242qgn; Mon, 11 Dec 2017 15:47:28 -0800 (PST) X-Google-Smtp-Source: ACJfBosV0mSfJslwTutQPMDQqsQVq2lZiOwE2WufmzceYaTX/afhPvitvzMChwynfasci/G4eE57 X-Received: by 10.28.105.14 with SMTP id e14mr32800wmc.74.1513036048112; Mon, 11 Dec 2017 15:47:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513036048; cv=none; d=google.com; s=arc-20160816; b=r5UNjSavnDYfIoMz2imKHP1JgSWFDAcSOzsfiiy+K7b7nnqsj2hyqkDi7xX/binNih OK7l1hBifJuHhJzO9KcfF7DJCQ3PnNL5yrPJ0HLjBZNqRBOcfXJ37WAADbeavm0tJkCD mXSWszZl0/0NE74/SNHUm8660YGbsM0JdfDogCy37DqnjMf/NIftuKhKZK++Y+K7WPkJ DshrJIQBFFv87ua2xo/n+NFNt9GExBRK9wQ4LbrEj03jp8e0xcXTiRAIL/n2FTvxNMtT t7zYNXC+AgKIsM1nKoV6J81fkAWUa9z13JAMF+q/lfkx+H096z9KBvNNILDuiSBWeuWP kiCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to:arc-authentication-results; bh=wnVSEgG3v9a8vUHN9dqAVK0Xo2x4cNY8n6/4QycRnwg=; b=GqG37QbuBw5cweJuE9I6Vlqmq/flW/VquWDn5B/OJZvJ5KdxBc8iAC3SYtViMaWi8U c35skEp5XpmaCsl/zAuzmVEr9JKzViprg3G5KPNm3lWbsvpETFZLwzRuYYDtmmB7PH/R Bub6R0wHNLl4vniM3G2Qj1IWl7i80LbreOOHemIRI6Ak1Q+79A0WNFATKPXU9SpP4ECQ XiDpjGgCbGL/Fv/Z+exm+x3pU8+KrUCSequq5GwIf79PbiNta+w9GWScC23k1mCgHkXU Nz8FqOtGWW+SYxLiQzOV/TLaIkveuXbpzJLe/WTnEBTP2Tv5tpwyUYRa3nmov9vqLYpM c0sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ipsNTK/z; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id i184si6045890wmf.57.2017.12.11.15.47.27; Mon, 11 Dec 2017 15:47:28 -0800 (PST) Received-SPF: pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) client-ip=77.48.224.243; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ipsNTK/z; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id E4FCB26770C; Tue, 12 Dec 2017 00:45:32 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 7A82526770C; Tue, 12 Dec 2017 00:45:31 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_PASS autolearn=disabled version=3.4.0 Received: from mail-wr0-f196.google.com (mail-wr0-f196.google.com [209.85.128.196]) by alsa0.perex.cz (Postfix) with ESMTP id C96D72676D1 for ; Tue, 12 Dec 2017 00:45:23 +0100 (CET) Received: by mail-wr0-f196.google.com with SMTP id q9so19324492wre.7 for ; Mon, 11 Dec 2017 15:45:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=79+SUDUWYx6bMeBmO61v7nXbYjeYEhjtDBfnnMLT3uQ=; b=ipsNTK/zDkGZ+rTYhkj5hgfj/+XTgsWCOSr4ZXQif/BuyDu3ulTFghtDc0Mu+1belo BbvCnMLRLneGijKGCltPcmf2w5lZ5yRBbx5D10WyblIfpFk9JyZ+YeIaI72h64ip3PdI 3sDY0WL8MFwIfL5jkBnZWNP6287GtYKJXWYpU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=79+SUDUWYx6bMeBmO61v7nXbYjeYEhjtDBfnnMLT3uQ=; b=a4ATf2AB0vkt1I3NHDIP4Zf9RvSuFGCanUiyywu9SlV+huWSMhks7l9305ediUBN2N BkFNAIQ7B1QVmnpBrywg+glqqzCQFqZiqgYsX7WhRNTsQRmuGnEqM6SURPn9jPpAETuM 7i73b/KZNxxV2bb3hLoxzvrw1jH+V96u6p9zF8xQ7E3bWVb4EiL/88ZHT/nRpsGxBSXJ dKUWCYaJBXXiU+7QnY3LILe/fETK+do2EDnpjzXTwx0+Zc6NuUEZaLyCIWVv+mDlz4yF r2GNxQpbPRYo7qRgETuhpmxZKQmbIw1qOiE3sRk3sMr5PEwUiIIFz30ydZckfAKNcGa0 u5cw== X-Gm-Message-State: AKGB3mJSXvos5Dp4N1JfAIjDQuUdTMmN+oug1qMkoQFWfd12zXLa0E5Z m1vlyrAol7pNQX8MDwSLgGslMg== X-Received: by 10.223.197.10 with SMTP id q10mr1784571wrf.237.1513035922990; Mon, 11 Dec 2017 15:45:22 -0800 (PST) Received: from localhost.localdomain (cpc90716-aztw32-2-0-cust92.18-1.cable.virginm.net. [86.26.100.93]) by smtp.gmail.com with ESMTPSA id k69sm10673615wmg.8.2017.12.11.15.45.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 11 Dec 2017 15:45:22 -0800 (PST) From: srinivas.kandagatla@linaro.org To: Mark Brown , Greg Kroah-Hartman , alsa-devel@alsa-project.org Date: Mon, 11 Dec 2017 23:43:01 +0000 Message-Id: <20171211234307.14465-8-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171211234307.14465-1-srinivas.kandagatla@linaro.org> References: <20171211234307.14465-1-srinivas.kandagatla@linaro.org> Cc: Mark Rutland , devicetree@vger.kernel.org, Jonathan Corbet , linux-arm-msm@vger.kernel.org, linux-doc@vger.kernel.org, j.neuschaefer@gmx.net, linux-kernel@vger.kernel.org, Rob Herring , Srinivas Kandagatla , pombredanne@nexb.com, sdharia@codeaurora.org Subject: [alsa-devel] [PATCH v10 07/13] slimbus: Add support for 'clock-pause' feature X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org From: Sagar Dharia Per SLIMbus specification, a reconfiguration sequence known as 'clock pause' needs to be broadcast over the bus while entering low- power mode. Clock-pause is initiated by the controller driver. To exit clock-pause, controller typically wakes up the framer device. Since wakeup precedure is controller-specific, framework calls it via controller's function pointer to invoke it. Signed-off-by: Sagar Dharia Signed-off-by: Srinivas Kandagatla --- drivers/slimbus/Makefile | 2 +- drivers/slimbus/core.c | 16 ++++++ drivers/slimbus/messaging.c | 35 ++++++++++++- drivers/slimbus/sched.c | 121 ++++++++++++++++++++++++++++++++++++++++++++ drivers/slimbus/slimbus.h | 53 +++++++++++++++++++ 5 files changed, 225 insertions(+), 2 deletions(-) create mode 100644 drivers/slimbus/sched.c -- 2.15.0 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/drivers/slimbus/Makefile b/drivers/slimbus/Makefile index 568a14c7be78..cd6833ed521a 100644 --- a/drivers/slimbus/Makefile +++ b/drivers/slimbus/Makefile @@ -3,4 +3,4 @@ # Makefile for kernel SLIMbus framework. # obj-$(CONFIG_SLIMBUS) += slimbus.o -slimbus-y := core.o messaging.o +slimbus-y := core.o messaging.o sched.o diff --git a/drivers/slimbus/core.c b/drivers/slimbus/core.c index 1accb20ed5cd..4988a8f4d905 100644 --- a/drivers/slimbus/core.c +++ b/drivers/slimbus/core.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include "slimbus.h" @@ -218,6 +219,8 @@ int slim_register_controller(struct slim_controller *ctrl) ida_init(&ctrl->laddr_ida); idr_init(&ctrl->tid_idr); mutex_init(&ctrl->lock); + mutex_init(&ctrl->sched.m_reconf); + init_completion(&ctrl->sched.pause_comp); dev_dbg(ctrl->dev, "Bus [%s] registered:dev:%p\n", ctrl->name, ctrl->dev); @@ -249,6 +252,8 @@ int slim_unregister_controller(struct slim_controller *ctrl) { /* Remove all clients */ device_for_each_child(ctrl->dev, NULL, slim_ctrl_remove_device); + /* Enter Clock Pause */ + slim_ctrl_clk_pause(ctrl, false, 0); ida_simple_remove(&ctrl_ida, ctrl->id); return 0; @@ -416,6 +421,14 @@ int slim_device_report_present(struct slim_controller *ctrl, struct slim_device *sbdev; int ret; + ret = pm_runtime_get_sync(ctrl->dev); + + if (ctrl->sched.clk_state != SLIM_CLK_ACTIVE) { + dev_err(ctrl->dev, "slim ctrl not active,state:%d, ret:%d\n", + ctrl->sched.clk_state, ret); + goto slimbus_not_active; + } + sbdev = slim_get_device(ctrl, e_addr); if (IS_ERR(sbdev)) return -ENODEV; @@ -427,6 +440,9 @@ int slim_device_report_present(struct slim_controller *ctrl, ret = slim_device_alloc_laddr(sbdev, true); +slimbus_not_active: + pm_runtime_mark_last_busy(ctrl->dev); + pm_runtime_put_autosuspend(ctrl->dev); return ret; } EXPORT_SYMBOL_GPL(slim_device_report_present); diff --git a/drivers/slimbus/messaging.c b/drivers/slimbus/messaging.c index 031e67648d7c..755462a4c75e 100644 --- a/drivers/slimbus/messaging.c +++ b/drivers/slimbus/messaging.c @@ -4,6 +4,7 @@ */ #include +#include #include "slimbus.h" /** @@ -46,6 +47,10 @@ void slim_msg_response(struct slim_controller *ctrl, u8 *reply, u8 tid, u8 len) memcpy(msg->rbuf, reply, len); if (txn->comp) complete(txn->comp); + + /* Remove runtime-pm vote now that response was received for TID txn */ + pm_runtime_mark_last_busy(ctrl->dev); + pm_runtime_put_autosuspend(ctrl->dev); } EXPORT_SYMBOL_GPL(slim_msg_response); @@ -65,10 +70,29 @@ EXPORT_SYMBOL_GPL(slim_msg_response); int slim_do_transfer(struct slim_controller *ctrl, struct slim_msg_txn *txn) { DECLARE_COMPLETION_ONSTACK(done); - bool need_tid; + bool need_tid = false, clk_pause_msg = false; unsigned long flags; int ret, tid, timeout; + /* + * do not vote for runtime-PM if the transactions are part of clock + * pause sequence + */ + if (ctrl->sched.clk_state == SLIM_CLK_ENTERING_PAUSE && + (txn->mt == SLIM_MSG_MT_CORE && + txn->mc >= SLIM_MSG_MC_BEGIN_RECONFIGURATION && + txn->mc <= SLIM_MSG_MC_RECONFIGURE_NOW)) + clk_pause_msg = true; + + if (!clk_pause_msg) { + ret = pm_runtime_get_sync(ctrl->dev); + if (ctrl->sched.clk_state != SLIM_CLK_ACTIVE) { + dev_err(ctrl->dev, "ctrl wrong state:%d, ret:%d\n", + ctrl->sched.clk_state, ret); + goto slim_xfer_err; + } + } + need_tid = slim_tid_txn(txn->mt, txn->mc); if (need_tid) { @@ -107,6 +131,15 @@ int slim_do_transfer(struct slim_controller *ctrl, struct slim_msg_txn *txn) dev_err(ctrl->dev, "Tx:MT:0x%x, MC:0x%x, LA:0x%x failed:%d\n", txn->mt, txn->mc, txn->la, ret); +slim_xfer_err: + if (!clk_pause_msg && (!need_tid || ret == -ETIMEDOUT)) { + /* + * remove runtime-pm vote if this was TX only, or + * if there was error during this transaction + */ + pm_runtime_mark_last_busy(ctrl->dev); + pm_runtime_mark_last_busy(ctrl->dev); + } return ret; } EXPORT_SYMBOL_GPL(slim_do_transfer); diff --git a/drivers/slimbus/sched.c b/drivers/slimbus/sched.c new file mode 100644 index 000000000000..af84997d2742 --- /dev/null +++ b/drivers/slimbus/sched.c @@ -0,0 +1,121 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2011-2017, The Linux Foundation + */ + +#include +#include "slimbus.h" + +/** + * slim_ctrl_clk_pause() - Called by slimbus controller to enter/exit + * 'clock pause' + * @ctrl: controller requesting bus to be paused or woken up + * @wakeup: Wakeup this controller from clock pause. + * @restart: Restart time value per spec used for clock pause. This value + * isn't used when controller is to be woken up. + * + * Slimbus specification needs this sequence to turn-off clocks for the bus. + * The sequence involves sending 3 broadcast messages (reconfiguration + * sequence) to inform all devices on the bus. + * To exit clock-pause, controller typically wakes up active framer device. + * This API executes clock pause reconfiguration sequence if wakeup is false. + * If wakeup is true, controller's wakeup is called. + * For entering clock-pause, -EBUSY is returned if a message txn in pending. + */ +int slim_ctrl_clk_pause(struct slim_controller *ctrl, bool wakeup, u8 restart) +{ + int i, ret = 0; + unsigned long flags; + struct slim_sched *sched = &ctrl->sched; + struct slim_val_inf msg = {0, 0, NULL, NULL}; + + DEFINE_SLIM_BCAST_TXN(txn, SLIM_MSG_MC_BEGIN_RECONFIGURATION, + 3, SLIM_LA_MANAGER, &msg); + + if (wakeup == false && restart > SLIM_CLK_UNSPECIFIED) + return -EINVAL; + + mutex_lock(&sched->m_reconf); + if (wakeup) { + if (sched->clk_state == SLIM_CLK_ACTIVE) { + mutex_unlock(&sched->m_reconf); + return 0; + } + + /* + * Fine-tune calculation based on clock gear, + * message-bandwidth after bandwidth management + */ + ret = wait_for_completion_timeout(&sched->pause_comp, + msecs_to_jiffies(100)); + if (!ret) { + mutex_unlock(&sched->m_reconf); + pr_err("Previous clock pause did not finish"); + return -ETIMEDOUT; + } + ret = 0; + + /* + * Slimbus framework will call controller wakeup + * Controller should make sure that it sets active framer + * out of clock pause + */ + if (sched->clk_state == SLIM_CLK_PAUSED && ctrl->wakeup) + ret = ctrl->wakeup(ctrl); + if (!ret) + sched->clk_state = SLIM_CLK_ACTIVE; + mutex_unlock(&sched->m_reconf); + + return ret; + } + + /* already paused */ + if (ctrl->sched.clk_state == SLIM_CLK_PAUSED) { + mutex_unlock(&sched->m_reconf); + return 0; + } + + spin_lock_irqsave(&ctrl->txn_lock, flags); + for (i = 0; i < SLIM_MAX_TIDS; i++) { + /* Pending response for a message */ + if (idr_find(&ctrl->tid_idr, i)) { + spin_unlock_irqrestore(&ctrl->txn_lock, flags); + mutex_unlock(&sched->m_reconf); + return -EBUSY; + } + } + spin_unlock_irqrestore(&ctrl->txn_lock, flags); + + sched->clk_state = SLIM_CLK_ENTERING_PAUSE; + + /* clock pause sequence */ + ret = slim_do_transfer(ctrl, &txn); + if (ret) + goto clk_pause_ret; + + txn.mc = SLIM_MSG_MC_NEXT_PAUSE_CLOCK; + txn.rl = 4; + msg.num_bytes = 1; + msg.wbuf = &restart; + ret = slim_do_transfer(ctrl, &txn); + if (ret) + goto clk_pause_ret; + + txn.mc = SLIM_MSG_MC_RECONFIGURE_NOW; + txn.rl = 3; + msg.num_bytes = 1; + msg.wbuf = NULL; + ret = slim_do_transfer(ctrl, &txn); + +clk_pause_ret: + if (ret) { + sched->clk_state = SLIM_CLK_ACTIVE; + } else { + sched->clk_state = SLIM_CLK_PAUSED; + complete(&sched->pause_comp); + } + mutex_unlock(&sched->m_reconf); + + return ret; +} +EXPORT_SYMBOL_GPL(slim_ctrl_clk_pause); diff --git a/drivers/slimbus/slimbus.h b/drivers/slimbus/slimbus.h index 0d40c2578c28..db089134f673 100644 --- a/drivers/slimbus/slimbus.h +++ b/drivers/slimbus/slimbus.h @@ -14,6 +14,16 @@ /* SLIMbus message types. Related to interpretation of message code. */ #define SLIM_MSG_MT_CORE 0x0 +/* Clock pause Reconfiguration messages */ +#define SLIM_MSG_MC_BEGIN_RECONFIGURATION 0x40 +#define SLIM_MSG_MC_NEXT_PAUSE_CLOCK 0x4A +#define SLIM_MSG_MC_RECONFIGURE_NOW 0x5F + +/* Clock pause values per SLIMbus spec */ +#define SLIM_CLK_FAST 0 +#define SLIM_CLK_CONST_PHASE 1 +#define SLIM_CLK_UNSPECIFIED 2 + /* Destination type Values */ #define SLIM_MSG_DEST_LOGICALADDR 0 #define SLIM_MSG_DEST_ENUMADDR 1 @@ -80,6 +90,42 @@ struct slim_msg_txn { #define DEFINE_SLIM_LDEST_TXN(name, mc, rl, la, msg) \ struct slim_msg_txn name = { rl, 0, mc, SLIM_MSG_DEST_LOGICALADDR, 0,\ 0, la, msg, } + +#define DEFINE_SLIM_BCAST_TXN(name, mc, rl, la, msg) \ + struct slim_msg_txn name = { rl, 0, mc, SLIM_MSG_DEST_BROADCAST, 0,\ + 0, la, msg, } +/** + * enum slim_clk_state: SLIMbus controller's clock state used internally for + * maintaining current clock state. + * @SLIM_CLK_ACTIVE: SLIMbus clock is active + * @SLIM_CLK_ENTERING_PAUSE: SLIMbus clock pause sequence is being sent on the + * bus. If this succeeds, state changes to SLIM_CLK_PAUSED. If the + * transition fails, state changes back to SLIM_CLK_ACTIVE + * @SLIM_CLK_PAUSED: SLIMbus controller clock has paused. + */ +enum slim_clk_state { + SLIM_CLK_ACTIVE, + SLIM_CLK_ENTERING_PAUSE, + SLIM_CLK_PAUSED, +}; + +/** + * struct slim_sched: Framework uses this structure internally for scheduling. + * @clk_state: Controller's clock state from enum slim_clk_state + * @pause_comp: Signals completion of clock pause sequence. This is useful when + * client tries to call SLIMbus transaction when controller is entering + * clock pause. + * @m_reconf: This mutex is held until current reconfiguration (data channel + * scheduling, message bandwidth reservation) is done. Message APIs can + * use the bus concurrently when this mutex is held since elemental access + * messages can be sent on the bus when reconfiguration is in progress. + */ +struct slim_sched { + enum slim_clk_state clk_state; + struct completion pause_comp; + struct mutex m_reconf; +}; + /** * struct slim_controller - Controls every instance of SLIMbus * (similar to 'master' on SPI) @@ -95,6 +141,7 @@ struct slim_msg_txn { * @devices: Slim device list * @tid_idr: tid id allocator * @txn_lock: Lock to protect table of transactions + * @sched: scheduler structure used by the controller * @xfer_msg: Transfer a message on this controller (this can be a broadcast * control/status message like data channel setup, or a unicast message * like value element read/write. @@ -105,6 +152,9 @@ struct slim_msg_txn { * address table and get_laddr can be used in that case so that controller * can do this assignment. Use case is when the master is on the remote * processor side, who is resposible for allocating laddr. + * @wakeup: This function pointer implements controller-specific procedure + * to wake it up from clock-pause. Framework will call this to bring + * the controller out of clock pause. * * 'Manager device' is responsible for device management, bandwidth * allocation, channel setup, and port associations per channel. @@ -139,12 +189,14 @@ struct slim_controller { struct list_head devices; struct idr tid_idr; spinlock_t txn_lock; + struct slim_sched sched; int (*xfer_msg)(struct slim_controller *ctrl, struct slim_msg_txn *tx); int (*set_laddr)(struct slim_controller *ctrl, struct slim_eaddr *ea, u8 laddr); int (*get_laddr)(struct slim_controller *ctrl, struct slim_eaddr *ea, u8 *laddr); + int (*wakeup)(struct slim_controller *ctrl); }; int slim_device_report_present(struct slim_controller *ctrl, @@ -154,6 +206,7 @@ int slim_register_controller(struct slim_controller *ctrl); int slim_unregister_controller(struct slim_controller *ctrl); void slim_msg_response(struct slim_controller *ctrl, u8 *reply, u8 tid, u8 l); int slim_do_transfer(struct slim_controller *ctrl, struct slim_msg_txn *txn); +int slim_ctrl_clk_pause(struct slim_controller *ctrl, bool wakeup, u8 restart); static inline bool slim_tid_txn(u8 mt, u8 mc) { From patchwork Mon Dec 11 23:43:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 121482 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3431938qgn; Mon, 11 Dec 2017 15:47:03 -0800 (PST) X-Google-Smtp-Source: ACJfBot+qn2xpCEJw9LosOsj3ugvg8o4RWr4gKTJTKxon/BlIJ6LEzqY+3XwoAYVbu3eE3wx7VAd X-Received: by 10.28.16.144 with SMTP id 138mr13249wmq.155.1513036023505; Mon, 11 Dec 2017 15:47:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513036023; cv=none; d=google.com; s=arc-20160816; b=ZEBxBxY9WBGL3ptfNs7Svg/MR1pDyK6xGS47BxGLUsGkrECpBM1J+Fs021UXeQXQAT bImEy0i5f5oyydFWhyzd/O56WEzVu4n5TebTO1Sc+pwHewTR17dnZm+9M5zNh7SAM9rk V4TxBL3gnp2yLkDEt0AufePOQZsJd1cnSCdG3VEiM6RPBYoI0QRQ6rcMIv+/wXn7A+7c 5jTViMreMLjaR3bHuxOvQJnEGh5IM+lkRa/K8LeuTNBg9FnfQVvi0fQw/+hSWlT4xJLe xkgflKtoJfkYY5+xR5dkdYST/g6Gn5mwGGoc0FSjGkQ06xX5ydrPQLUFP+fwDWMRjBmi lWwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to:arc-authentication-results; bh=KgAijYjyX+XAi+wtSuXVA+ub5irflMDcHCPe+g5RyQ0=; b=DdqZl+i3y32FfeGLwuVCwguD/PvVms7oipw7tYHy77KRx1DWKG9QhW+T8uo6LJZSdd 7/jw3x93p/OxWK7y7u2EZKyWausPg5KKRvKPcbkMEVIAaLyszsgPJpKrckOobDpoZ0ET HAr39rxpg7WfeHiNuB1ujng2cOMC3YErblU6HDNPVXrfODxzJ5UzUb7KxdnRP8vGjq1B Mpt4wO9G5nYieNu1YUI7d/3IOuTrStzl02EPPWYfXq3l8HzJhJQuSLLaS4lSvGi1oJ99 MmRjbgV4Gu0nCoXZwx329XkDbHnfljmjluwv7ygM3cjkeWWMzNUsy7CuuxEj1f3o7RkY H06g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ZgGkH5H1; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id n25si11576770wra.549.2017.12.11.15.47.03; Mon, 11 Dec 2017 15:47:03 -0800 (PST) Received-SPF: pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) client-ip=77.48.224.243; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ZgGkH5H1; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 398062676FD; Tue, 12 Dec 2017 00:45:30 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 319A72676D7; Tue, 12 Dec 2017 00:45:27 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_PASS autolearn=disabled version=3.4.0 Received: from mail-wr0-f194.google.com (mail-wr0-f194.google.com [209.85.128.194]) by alsa0.perex.cz (Postfix) with ESMTP id 2B9372676CB for ; Tue, 12 Dec 2017 00:45:24 +0100 (CET) Received: by mail-wr0-f194.google.com with SMTP id k61so19308067wrc.4 for ; Mon, 11 Dec 2017 15:45:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SZXq628LwAI/zssq5oA1vcFcJ1pJBiBd9MS5mT7xUDU=; b=ZgGkH5H1TaPEyttX9Hp+KZZPPZnVI8KF+P4QR87zNP6Y3oMM3amYioFltIDVme5WUs 3cAAPhFVgWhI1XCTjzs7FhiAw7ba934oV0lFk6hd03d/iEU3kF08SCCk2LcPSIlmvoyN 6ksBIdPaMIhpX4SxJ/THUY1w6zgqawhePGL9c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SZXq628LwAI/zssq5oA1vcFcJ1pJBiBd9MS5mT7xUDU=; b=K1kPapDT9RF6LmsGd7um7U62GNBasZlDrr0ORUIQ+AtbCfiqipy/hEhNNbUtHD8Pmp /cNY+V8YzEYL88M/1Lr7pQZRjhp9r8fMs+tD6NteJ9Pr4zZevxYTjbp4wVsOJ+BP39+N dlnX8XfMMk53kgK4MmRdrOzBH0KA8NDabLxjN73KGIa7XObOGWY+e3QxV8hAEkC4kUaj HH/qhw6ZPaA8YYWVCR0bv2Z+vkZuF7sgsXOdez1+7ZAXDCTgDwxcQ8C23sFlcoZyk1bD 9bNTKIYm4oOEXgroAQP9VRS/f09aE3/7hZzJwOMaB7oWTUSQXcdBHj5CgUvs4dMpv+5V 2OYQ== X-Gm-Message-State: AKGB3mJXKRkxfyDyjNv+OvIGbK5e2jXeU2jPIZ8Xp0+QTXcTXtqakVAD Z06iPbF9unvu5BagkmXI/hioCw== X-Received: by 10.223.186.67 with SMTP id t3mr1753859wrg.276.1513035924290; Mon, 11 Dec 2017 15:45:24 -0800 (PST) Received: from localhost.localdomain (cpc90716-aztw32-2-0-cust92.18-1.cable.virginm.net. [86.26.100.93]) by smtp.gmail.com with ESMTPSA id k69sm10673615wmg.8.2017.12.11.15.45.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 11 Dec 2017 15:45:23 -0800 (PST) From: srinivas.kandagatla@linaro.org To: Mark Brown , Greg Kroah-Hartman , alsa-devel@alsa-project.org Date: Mon, 11 Dec 2017 23:43:02 +0000 Message-Id: <20171211234307.14465-9-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171211234307.14465-1-srinivas.kandagatla@linaro.org> References: <20171211234307.14465-1-srinivas.kandagatla@linaro.org> Cc: Mark Rutland , devicetree@vger.kernel.org, Jonathan Corbet , linux-arm-msm@vger.kernel.org, linux-doc@vger.kernel.org, j.neuschaefer@gmx.net, linux-kernel@vger.kernel.org, Rob Herring , Srinivas Kandagatla , pombredanne@nexb.com, sdharia@codeaurora.org Subject: [alsa-devel] [PATCH v10 08/13] regmap: add SLIMbus support X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org From: Srinivas Kandagatla This patch adds support to read/write SLIMbus value elements. Currently it only supports byte read/write. Adding this support in regmap would give codec drivers more flexibility when there are more than 2 control interfaces like SLIMbus, i2c. Without this patch each codec driver has to directly call SLIMbus value element apis, and this could would get messy once we want to add i2c interface to it. Signed-off-by: Srinivas Kandagatla --- drivers/base/regmap/Kconfig | 4 ++ drivers/base/regmap/Makefile | 1 + drivers/base/regmap/regmap-slimbus.c | 80 ++++++++++++++++++++++++++++++++++++ include/linux/regmap.h | 18 ++++++++ 4 files changed, 103 insertions(+) create mode 100644 drivers/base/regmap/regmap-slimbus.c -- 2.15.0 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/drivers/base/regmap/Kconfig b/drivers/base/regmap/Kconfig index 3a1535d812d8..cc162b48c6d7 100644 --- a/drivers/base/regmap/Kconfig +++ b/drivers/base/regmap/Kconfig @@ -21,6 +21,10 @@ config REGMAP_I2C tristate depends on I2C +config REGMAP_SLIMBUS + tristate + depends on SLIMBUS + config REGMAP_SPI tristate depends on SPI diff --git a/drivers/base/regmap/Makefile b/drivers/base/regmap/Makefile index 0d298c446108..63dec9222892 100644 --- a/drivers/base/regmap/Makefile +++ b/drivers/base/regmap/Makefile @@ -8,6 +8,7 @@ obj-$(CONFIG_REGCACHE_COMPRESSED) += regcache-lzo.o obj-$(CONFIG_DEBUG_FS) += regmap-debugfs.o obj-$(CONFIG_REGMAP_AC97) += regmap-ac97.o obj-$(CONFIG_REGMAP_I2C) += regmap-i2c.o +obj-$(CONFIG_REGMAP_SLIMBUS) += regmap-slimbus.o obj-$(CONFIG_REGMAP_SPI) += regmap-spi.o obj-$(CONFIG_REGMAP_SPMI) += regmap-spmi.o obj-$(CONFIG_REGMAP_MMIO) += regmap-mmio.o diff --git a/drivers/base/regmap/regmap-slimbus.c b/drivers/base/regmap/regmap-slimbus.c new file mode 100644 index 000000000000..c90bee81d954 --- /dev/null +++ b/drivers/base/regmap/regmap-slimbus.c @@ -0,0 +1,80 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) 2017, Linaro Ltd. + +#include +#include +#include + +#include "internal.h" + +static int regmap_slimbus_byte_reg_read(void *context, unsigned int reg, + unsigned int *val) +{ + struct slim_device *sdev = context; + int v; + + v = slim_readb(sdev, reg); + + if (v < 0) + return v; + + *val = v; + + return 0; +} + +static int regmap_slimbus_byte_reg_write(void *context, unsigned int reg, + unsigned int val) +{ + struct slim_device *sdev = context; + + return slim_writeb(sdev, reg, val); +} + +static struct regmap_bus regmap_slimbus_bus = { + .reg_write = regmap_slimbus_byte_reg_write, + .reg_read = regmap_slimbus_byte_reg_read, + .reg_format_endian_default = REGMAP_ENDIAN_LITTLE, + .val_format_endian_default = REGMAP_ENDIAN_LITTLE, +}; + +static const struct regmap_bus *regmap_get_slimbus(struct slim_device *slim, + const struct regmap_config *config) +{ + if (config->val_bits == 8 && config->reg_bits == 8) + return ®map_slimbus_bus; + + return ERR_PTR(-ENOTSUPP); +} + +struct regmap *__regmap_init_slimbus(struct slim_device *slimbus, + const struct regmap_config *config, + struct lock_class_key *lock_key, + const char *lock_name) +{ + const struct regmap_bus *bus = regmap_get_slimbus(slimbus, config); + + if (IS_ERR(bus)) + return ERR_CAST(bus); + + return __regmap_init(&slimbus->dev, bus, &slimbus->dev, config, + lock_key, lock_name); +} +EXPORT_SYMBOL_GPL(__regmap_init_slimbus); + +struct regmap *__devm_regmap_init_slimbus(struct slim_device *slimbus, + const struct regmap_config *config, + struct lock_class_key *lock_key, + const char *lock_name) +{ + const struct regmap_bus *bus = regmap_get_slimbus(slimbus, config); + + if (IS_ERR(bus)) + return ERR_CAST(bus); + + return __devm_regmap_init(&slimbus->dev, bus, &slimbus, config, + lock_key, lock_name); +} +EXPORT_SYMBOL_GPL(__devm_regmap_init_slimbus); + +MODULE_LICENSE("GPL v2"); diff --git a/include/linux/regmap.h b/include/linux/regmap.h index 15eddc1353ba..b2207737a159 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h @@ -24,6 +24,7 @@ struct module; struct device; struct i2c_client; struct irq_domain; +struct slim_device; struct spi_device; struct spmi_device; struct regmap; @@ -499,6 +500,10 @@ struct regmap *__regmap_init_i2c(struct i2c_client *i2c, const struct regmap_config *config, struct lock_class_key *lock_key, const char *lock_name); +struct regmap *__regmap_init_slimbus(struct slim_device *slimbus, + const struct regmap_config *config, + struct lock_class_key *lock_key, + const char *lock_name); struct regmap *__regmap_init_spi(struct spi_device *dev, const struct regmap_config *config, struct lock_class_key *lock_key, @@ -615,6 +620,19 @@ int regmap_attach_dev(struct device *dev, struct regmap *map, __regmap_lockdep_wrapper(__regmap_init_i2c, #config, \ i2c, config) +/** + * regmap_init_slimbus() - Initialise register map + * + * @slimbus: Device that will be interacted with + * @config: Configuration for register map + * + * The return value will be an ERR_PTR() on error or a valid pointer to + * a struct regmap. + */ +#define regmap_init_slimbus(slimbus, config) \ + __regmap_lockdep_wrapper(__regmap_init_slimbus, #config, \ + slimbus, config) + /** * regmap_init_spi() - Initialise register map * From patchwork Mon Dec 11 23:43:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 121484 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3432077qgn; Mon, 11 Dec 2017 15:47:15 -0800 (PST) X-Google-Smtp-Source: ACJfBotKnKLIrKAM7W0e2vPtb9r7V42s+hmBk4HJRho49iR7p4dyYKFVIj9LCtHA+kE2B2aQAiR/ X-Received: by 10.28.118.4 with SMTP id r4mr23092wmc.71.1513036034967; Mon, 11 Dec 2017 15:47:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513036034; cv=none; d=google.com; s=arc-20160816; b=iiKBnP9e34FnxYw5BxTxnpSG1O+9bekq5mhaInyHO/zAyr55qzm3+UCn4nYu8Q9HNQ 0RmHIed7LupekgmHpg8X+7GeUed5FK8XKQdC6e63UBPrZ6GwgoLyqjPcBhWqYNBf4MQM PvqHnIqmEwbE4xi3e6NIIxHVEXzUHEhkAkd+1TY4ILzo+un+kABbhCxVkVp22XkI2ylh Lpp2453zn2Hq4YXzTrSJPAdWnCcqMFH72NZBluiQ0nQiaRxkxOgEqvMFZ/2kPNqn1v11 aYRl/8bXm6C4DmF60lry6juFKrx6TNvG1PPa7IXupsQE0xzgiEtpP9zQEOxJ4gu5iLHm 0p7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to:arc-authentication-results; bh=bobwrR0TOnGI7aNGeH7XFbHwwjfFQ4lnVCWo4HG7fDs=; b=dLGhSMaxv12NnlfXE3wF2AfJ2zsWdZiVi9BNGZxiVYqDBUBVuL9Wyin15idd4eKjPK Rhr4y0d/eb+eaBB8JBJB1evHSBDxbL5Wx2oOlXSzA9PQc5GNjJvOnOj005ZhQzBuScsg VhDIRTc/TixKFIt8lWT110E+9MXHuuRldO0pTHT0jhNDJFfhWqrn98OjVMlXJuZbFOij 4F7Xv6V7M/DyRC171KgpVs9BMB0Lc9xoZQs7JVtqg+AsCPC5TK3W39uZYHmZli281Drv pfZQdD+9nJzHYSJl7QrZSWPJFQIu6zAMzEDHnPWW6JaavI+lURV4LH6ozDEJifykrqXw R7nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=h+VgyRH4; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id x83si6072199wmg.13.2017.12.11.15.47.14; Mon, 11 Dec 2017 15:47:14 -0800 (PST) Received-SPF: pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) client-ip=77.48.224.243; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=h+VgyRH4; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id E3056267702; Tue, 12 Dec 2017 00:45:30 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 9FE632676D5; Tue, 12 Dec 2017 00:45:29 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_PASS autolearn=disabled version=3.4.0 Received: from mail-wr0-f193.google.com (mail-wr0-f193.google.com [209.85.128.193]) by alsa0.perex.cz (Postfix) with ESMTP id 273D52676D5 for ; Tue, 12 Dec 2017 00:45:25 +0100 (CET) Received: by mail-wr0-f193.google.com with SMTP id h1so19289895wre.12 for ; Mon, 11 Dec 2017 15:45:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=m5fuV9rRvWZc/You+YmM0UYXnMGafyyzentCXPDdM2Y=; b=h+VgyRH4v6Yw1HxlY/H0rFC+ixzLud5mu/21SojItN/1xL2jsD2hLqDEHa/LSN75Lc U1tDPvF50XKJnfaHBY+UBraJCvEdBdjZ/bzP8NrTsFqF1y5hkg4miukcVdSHJkCAkcb9 UYCjXBwSK3xuLTe4GRbSNGai0hXyYWDC8QrEU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=m5fuV9rRvWZc/You+YmM0UYXnMGafyyzentCXPDdM2Y=; b=sGIfTC+aoSDW2GOmbK2/mywDBRdKV2ZWPjCkv81gpKzSp4LRuGUrj6CvmBWySSlfJD nkYTfGAXMdzOyUY28XXTy/pCSKBSTkB5rUgasuCiA7VKASTR03BC+rZI8JPsqRE2lkXA 2pTncUN+tz0FHblnsCiMaaWHT1+hpQe1RK0xrPbV9JtS/7u4SKOIcPsMmIr58ROAMnns ApOIGAzorcl/HiWT9qYrDDdPojCatmdO9dYbaNnTOaYiYvVxHbAJyH19tA58QJHKkLCx aR2yN93pnUI/5NITLZIC1kMOvis3XUmcKuFa/uSEYAnDce+6aZoH2wUmk8wbL9Do7YnQ 9HAQ== X-Gm-Message-State: AKGB3mJz2A+GCux6yTG2uL7sWjKqeAfOsnohi8toUJaA984sK0+78CE4 tx/gxb9mGMyHmeN6WI/Uw6mBFA== X-Received: by 10.223.174.147 with SMTP id y19mr1794964wrc.97.1513035925575; Mon, 11 Dec 2017 15:45:25 -0800 (PST) Received: from localhost.localdomain (cpc90716-aztw32-2-0-cust92.18-1.cable.virginm.net. [86.26.100.93]) by smtp.gmail.com with ESMTPSA id k69sm10673615wmg.8.2017.12.11.15.45.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 11 Dec 2017 15:45:24 -0800 (PST) From: srinivas.kandagatla@linaro.org To: Mark Brown , Greg Kroah-Hartman , alsa-devel@alsa-project.org Date: Mon, 11 Dec 2017 23:43:03 +0000 Message-Id: <20171211234307.14465-10-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171211234307.14465-1-srinivas.kandagatla@linaro.org> References: <20171211234307.14465-1-srinivas.kandagatla@linaro.org> Cc: Mark Rutland , devicetree@vger.kernel.org, Jonathan Corbet , linux-arm-msm@vger.kernel.org, linux-doc@vger.kernel.org, j.neuschaefer@gmx.net, linux-kernel@vger.kernel.org, Rob Herring , Srinivas Kandagatla , pombredanne@nexb.com, sdharia@codeaurora.org Subject: [alsa-devel] [PATCH v10 09/13] slimbus: core: add common defines required for controllers X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org From: Srinivas Kandagatla This patch adds some common constant defines which are required for qcom slim controller driver. Signed-off-by: Srinivas Kandagatla --- drivers/slimbus/slimbus.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) -- 2.15.0 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/drivers/slimbus/slimbus.h b/drivers/slimbus/slimbus.h index db089134f673..79f8e05d92dd 100644 --- a/drivers/slimbus/slimbus.h +++ b/drivers/slimbus/slimbus.h @@ -11,9 +11,38 @@ #include #include +/* Standard values per SLIMbus spec needed by controllers and devices */ +#define SLIM_CL_PER_SUPERFRAME 6144 +#define SLIM_CL_PER_SUPERFRAME_DIV8 (SLIM_CL_PER_SUPERFRAME >> 3) + /* SLIMbus message types. Related to interpretation of message code. */ #define SLIM_MSG_MT_CORE 0x0 +/* + * SLIM Broadcast header format + * BYTE 0: MT[7:5] RL[4:0] + * BYTE 1: RSVD[7] MC[6:0] + * BYTE 2: RSVD[7:6] DT[5:4] PI[3:0] + */ +#define SLIM_MSG_MT_MASK GENMASK(2, 0) +#define SLIM_MSG_MT_SHIFT 5 +#define SLIM_MSG_RL_MASK GENMASK(4, 0) +#define SLIM_MSG_RL_SHIFT 0 +#define SLIM_MSG_MC_MASK GENMASK(6, 0) +#define SLIM_MSG_MC_SHIFT 0 +#define SLIM_MSG_DT_MASK GENMASK(1, 0) +#define SLIM_MSG_DT_SHIFT 4 + +#define SLIM_HEADER_GET_MT(b) ((b >> SLIM_MSG_MT_SHIFT) & SLIM_MSG_MT_MASK) +#define SLIM_HEADER_GET_RL(b) ((b >> SLIM_MSG_RL_SHIFT) & SLIM_MSG_RL_MASK) +#define SLIM_HEADER_GET_MC(b) ((b >> SLIM_MSG_MC_SHIFT) & SLIM_MSG_MC_MASK) +#define SLIM_HEADER_GET_DT(b) ((b >> SLIM_MSG_DT_SHIFT) & SLIM_MSG_DT_MASK) + +/* Device management messages used by this framework */ +#define SLIM_MSG_MC_REPORT_PRESENT 0x1 +#define SLIM_MSG_MC_ASSIGN_LOGICAL_ADDRESS 0x2 +#define SLIM_MSG_MC_REPORT_ABSENT 0xF + /* Clock pause Reconfiguration messages */ #define SLIM_MSG_MC_BEGIN_RECONFIGURATION 0x40 #define SLIM_MSG_MC_NEXT_PAUSE_CLOCK 0x4A @@ -94,6 +123,10 @@ struct slim_msg_txn { #define DEFINE_SLIM_BCAST_TXN(name, mc, rl, la, msg) \ struct slim_msg_txn name = { rl, 0, mc, SLIM_MSG_DEST_BROADCAST, 0,\ 0, la, msg, } + +#define DEFINE_SLIM_EDEST_TXN(name, mc, rl, la, msg) \ + struct slim_msg_txn name = { rl, 0, mc, SLIM_MSG_DEST_ENUMADDR, 0,\ + 0, la, msg, } /** * enum slim_clk_state: SLIMbus controller's clock state used internally for * maintaining current clock state. From patchwork Mon Dec 11 23:43:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 121486 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3432366qgn; Mon, 11 Dec 2017 15:47:40 -0800 (PST) X-Google-Smtp-Source: ACJfBoufshWGiOK7HHByHp/xJUcsEj/wazm9TiCBPrsQiWn7hc7OWcz882y8uWFPMRSoDBRp/wDA X-Received: by 10.28.28.11 with SMTP id c11mr14366wmc.161.1513036060163; Mon, 11 Dec 2017 15:47:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513036060; cv=none; d=google.com; s=arc-20160816; b=Wa1/u32KQn4tx7D5CYhzJjCm68+4CrGxinwtyxko77WybTiE8bm5a6xwVNnh7n2bKq Pb2xoEQ8PAbsWCUvm/Sw/wYlRv74X46ZqTuU0cSAH4BKAdnZaouuOGx5xZ8n5RN5yewH ttcX7oWp6aKapQj3HSiLodRM4SYhZrPudG0bhncnvTeeU3CNIuNcOWo743+uSzWMMZpt whRbRaJT01YPfJYn28QwQ7zGsNjCXKS+jke9cMLvEqRAF0T3NOuugTb7zwd7VifcAwtC 5IUx2b1+JY3t11fWBh0Wk+joUxUZ0Uh+NDuCyX0a6+xs5CZgAbqdrsskCzbUKIo+hzc9 xH1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to:arc-authentication-results; bh=JmzJ9GjR1SUASEx4tIy8YetHCutHPc7Fw5PzZPWjHjo=; b=PKCDl9IaGCsCoIEM8l7MFhQv0WejdY4AT9Ubj6Uo1SBFU0mOWGr5L13RfBpaSw3rEr PRGEyaT/i6KeNEI4zie6fz7ye2YRPi3d5idGQEoIeuQMS7boJ7VL6CxKQ0Ft1LRYdrih 7MxUBw1FwnViDE/oqK14r0G2cmuV6C95Msb5Zt7rtEOoGc5ZSqgsmvbj0Khq3adfXhO5 YLE/hY+1DZszLWHevORvdGwHS0T1dXfcUx/3MWl5b67U9rJfhi02gqdDSDCNakxrjZm1 7azQ8VAiyWsIwXY/FmMlD1PzgSCeMIaMNc5DS20LE2gZrNevgYJNjE1d7gAGYwNMO2D8 ZNxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=NDkXfyeF; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id g131si6091936wma.17.2017.12.11.15.47.39; Mon, 11 Dec 2017 15:47:40 -0800 (PST) Received-SPF: pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) client-ip=77.48.224.243; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=NDkXfyeF; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 74918267716; Tue, 12 Dec 2017 00:45:33 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id A4296267712; Tue, 12 Dec 2017 00:45:31 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_PASS autolearn=disabled version=3.4.0 Received: from mail-wr0-f195.google.com (mail-wr0-f195.google.com [209.85.128.195]) by alsa0.perex.cz (Postfix) with ESMTP id 429AD2676DA for ; Tue, 12 Dec 2017 00:45:27 +0100 (CET) Received: by mail-wr0-f195.google.com with SMTP id k61so19308123wrc.4 for ; Mon, 11 Dec 2017 15:45:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=npBrS6d/TflCw66s5D1yhUtJ4b2+IPoeeI+n2lsOOtw=; b=NDkXfyeF39l/SZYMrL97GQ77/kOIPiSAhXgqxMWwY11P72Z93P6z5yIdY37c5VUw8q 7KsBD/I6Q7osFFGnfWBsHhUaJwsWpHD8M498+5jSw6jDUL9j4CIAMsfqWMuc0N3GjTwv RvcrePuo7QnYD+2zPih3MywKGT+TG2BXzXgxY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=npBrS6d/TflCw66s5D1yhUtJ4b2+IPoeeI+n2lsOOtw=; b=ojvOxLo3Ae9yFQ5zRNGaMpqvP5a/3YU4HLYdIgS8d8hhFq7QJt9cJ7oKGcVvcPnC3W 9Uhz6M0ZX86o6OxsWUIbEUZ9kN4bPwnABTQ7LxxDI1qmi1J0qPBegpNVNOOvA3TcCVQo 5u/YEf4s/YprmG3allQm3zGFqFQXhAGxsC9eUAQQqdhxwmTTCTJWHca2/a4266YqT2w4 lLee4eszWSTeO7NtxWjkh2XbGJmExiWJUzyNsUHDK4BeChoTtnntIptcD3qk8+cpzRwl Y1XnIz5J7saxOjjTGaQRyZKY9Y/LdIzyI78FdkP15/YMj+/ncLxSwxadCpijzONGyvgK L7og== X-Gm-Message-State: AKGB3mIacS9ZBts+Y9+gPXsKsuyYtvPcfk14FNB1oFP3MJVhQUPc8pED Mn7u5F2jNGD2KbUP/EgmzJcHtA== X-Received: by 10.223.200.65 with SMTP id e1mr1759258wrh.133.1513035926658; Mon, 11 Dec 2017 15:45:26 -0800 (PST) Received: from localhost.localdomain (cpc90716-aztw32-2-0-cust92.18-1.cable.virginm.net. [86.26.100.93]) by smtp.gmail.com with ESMTPSA id k69sm10673615wmg.8.2017.12.11.15.45.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 11 Dec 2017 15:45:26 -0800 (PST) From: srinivas.kandagatla@linaro.org To: Mark Brown , Greg Kroah-Hartman , alsa-devel@alsa-project.org Date: Mon, 11 Dec 2017 23:43:04 +0000 Message-Id: <20171211234307.14465-11-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171211234307.14465-1-srinivas.kandagatla@linaro.org> References: <20171211234307.14465-1-srinivas.kandagatla@linaro.org> Cc: Mark Rutland , devicetree@vger.kernel.org, Jonathan Corbet , linux-arm-msm@vger.kernel.org, linux-doc@vger.kernel.org, j.neuschaefer@gmx.net, linux-kernel@vger.kernel.org, Rob Herring , Srinivas Kandagatla , pombredanne@nexb.com, sdharia@codeaurora.org Subject: [alsa-devel] [PATCH v10 10/13] dt-bindings: Add qcom slimbus controller bindings X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org From: Sagar Dharia This patch add device tree bindings for Qualcomm slimbus controller. Signed-off-by: Sagar Dharia Signed-off-by: Srinivas Kandagatla Reviewed-by: Rob Herring --- .../devicetree/bindings/slimbus/slim-qcom-ctrl.txt | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Documentation/devicetree/bindings/slimbus/slim-qcom-ctrl.txt -- 2.15.0 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/Documentation/devicetree/bindings/slimbus/slim-qcom-ctrl.txt b/Documentation/devicetree/bindings/slimbus/slim-qcom-ctrl.txt new file mode 100644 index 000000000000..922dcb8ff24a --- /dev/null +++ b/Documentation/devicetree/bindings/slimbus/slim-qcom-ctrl.txt @@ -0,0 +1,39 @@ +Qualcomm SLIMbus controller +This controller is used if applications processor driver controls SLIMbus +master component. + +Required properties: + + - #address-cells - refer to Documentation/devicetree/bindings/slimbus/bus.txt + - #size-cells - refer to Documentation/devicetree/bindings/slimbus/bus.txt + + - reg : Offset and length of the register region(s) for the device + - reg-names : Register region name(s) referenced in reg above + Required register resource entries are: + "ctrl": Physical address of controller register blocks + "slew": required for "qcom,apq8064-slim" SOC. + - compatible : should be "qcom,-slim" for SOC specific compatible + followed by "qcom,slim" for fallback. + - interrupts : Interrupt number used by this controller + - clocks : Interface and core clocks used by this SLIMbus controller + - clock-names : Required clock-name entries are: + "iface" : Interface clock for this controller + "core" : Interrupt for controller core's BAM + +Example: + + slim@28080000 { + compatible = "qcom,apq8064-slim", "qcom,slim"; + reg = <0x28080000 0x2000>, <0x80207C 4>; + reg-names = "ctrl", "slew"; + interrupts = <0 33 0>; + clocks = <&lcc SLIMBUS_SRC>, <&lcc AUDIO_SLIMBUS_CLK>; + clock-names = "iface", "core"; + #address-cells = <2>; + #size-cell = <0>; + + wcd9310: audio-codec@1,0{ + compatible = "slim217,60"; + reg = <1 0>; + }; + };