Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4188840pxu; Mon, 30 Nov 2020 21:07:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJxKA4lTR4eI9AZNYJyFvXs4hPHKHHgPdokgGvlCSMux02tnFF09xPeAG/lrJeytPgBwm/1E X-Received: by 2002:a17:906:3883:: with SMTP id q3mr1370866ejd.160.1606799250882; Mon, 30 Nov 2020 21:07:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606799250; cv=none; d=google.com; s=arc-20160816; b=dthd7lxb2JLURK4UU45rmJHo4DKJCP9kos6rHXSAWzy8Ijd3UakGj8GBkrizSUq9d4 4YuE3LhCNfq+6h1CLgM3N7EomIpN4g53AFlFHSmalFZ4Mtn18Y/RGiMCfxoX6EpFOBhI HKAKLw91BTLzXMkRtjnxRN/UXKdPkisVq4TMOVjcVEzOPTGjm8aU33qGb0JBEIutRqYp efj+4hknrSTW94UI9TD/83TdUVFouY02O5SbywRVlBgzQVMTOh2dQnAnShoN9rPPZujL Xv3rDtV2uU379megLx5oMzsvOlFCday2/ZBmShLIFBn/VWgdzbiWfleGHzsb1T+nR08f FtXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:ironport-sdr:ironport-sdr; bh=j6pBexD7/hxtDRVu/cNgK45J7Pwder1i+u+SjWjKyJw=; b=tXswKFIILa7Q6kyHQ0iIhm7d+bfcRHf8s6tUtnmNDHO06PRUcxjtrYC1BbVTksA0/W /fyfa8kuwhC2w9+0jujZtzNBst3wx5joyvroG9uiGdpt+d94/uSCM2ViGk+bFYYYY5L/ bm+cOPVJknTRyi4TzYNyNEpm8VEJIlxq0CLEXve5ctTdk3LA1KipS4zXJ7AL9DMELPXX ms4InOwh4HZ3MOTWVyfnUdHYs3m9qpPs6QDQjOj4JnIunrozOi63y15sgszs0/1YXWBH l86ccBkbhCvGbRVnTeqSwWoJJdAS7110sTRu6SHsCOw/iej6alg+g/Ybeqv7w+Lq+0QU Jdrg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z22si250199ejo.390.2020.11.30.21.07.08; Mon, 30 Nov 2020 21:07:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727860AbgLACej (ORCPT + 99 others); Mon, 30 Nov 2020 21:34:39 -0500 Received: from mga11.intel.com ([192.55.52.93]:26603 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727832AbgLACei (ORCPT ); Mon, 30 Nov 2020 21:34:38 -0500 IronPort-SDR: 8IvrEE2LtQhLeIJPq4Y8K0JaGjOAHyCjqzlopnSD6YYzA4wDI+85N0AaUxHl+g+2L4drP1ecBL X3+h5S+dPynw== X-IronPort-AV: E=McAfee;i="6000,8403,9821"; a="169250292" X-IronPort-AV: E=Sophos;i="5.78,382,1599548400"; d="scan'208";a="169250292" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2020 18:32:58 -0800 IronPort-SDR: j0B1RUSAEBkCbip2cFPb8qNg6VS4l2ulleh195CRS73FaOPfpWTiNj4eGMJoQkBPmR9aDe52Hn BBidhJNssYVw== X-IronPort-AV: E=Sophos;i="5.78,382,1599548400"; d="scan'208";a="549360086" Received: from bard-ubuntu.sh.intel.com ([10.239.13.33]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2020 18:32:54 -0800 From: Bard Liao To: alsa-devel@alsa-project.org, vkoul@kernel.org Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, tiwai@suse.de, broonie@kernel.org, gregkh@linuxfoundation.org, jank@cadence.com, srinivas.kandagatla@linaro.org, rander.wang@linux.intel.com, ranjani.sridharan@linux.intel.com, hui.wang@canonical.com, pierre-louis.bossart@linux.intel.com, sanyog.r.kale@intel.com, bard.liao@intel.com Subject: [PATCH v2 1/5] soundwire: SDCA: add helper macro to access controls Date: Mon, 30 Nov 2020 22:40:16 +0800 Message-Id: <20201130144020.19757-2-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201130144020.19757-1-yung-chuan.liao@linux.intel.com> References: <20201130144020.19757-1-yung-chuan.liao@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pierre-Louis Bossart The upcoming SDCA (SoundWire Device Class Audio) specification defines a hierarchical encoding to interface with Class-defined capabilities. The specification is not yet accessible to the general public but this information is released with explicit permission from the MIPI Board to avoid delays with SDCA support on Linux platforms. A block of 64 MBytes of register addresses are allocated to SDCA controls, starting at address 0x40000000. The 26 LSBs which identify individual controls are set based on the following variables: - Function Number. An SCDA device can be split in up to 8 independent Functions. Each of these Functions is described in the SDCA specification, e.g. Smart Amplifier, Smart Microphone, Simple Microphone, Jack codec, HID, etc. - Entity Number. Within each Function, an Entity is an identifiable block. Up to 127 Entities are connected in a pre-defined graph (similar to USB), with Entity0 reserved for Function-level configurations. In contrast to USB, the SDCA spec pre-defines Function Types, topologies, and allowed options, i.e. the degree of freedom is not unlimited to limit the possibility of errors in descriptors leading to software quirks. - Control Selector. Within each Entity, the SDCA specification defines 48 controls such as Mute, Gain, AGC, etc, and 16 implementation defined ones. Some Control Selectors might be used for low-level platform setup, and other exposed to applications and users. Note that the same Control Selector capability, e.g. Latency control, might be located at different offsets in different entities, the Control Selector mapping is Entity-specific. - Control Number. Some Control Selectors allow channel-specific values to be set, with up to 64 channels allowed. This is mostly used for volume control. - Current/Next values. Some Control Selectors are 'Dual-Ranked'. Software may either update the Current value directly for immediate effect. Alternatively, software may write into the 'Next' values and update the SoundWire 1.2 'Commit Groups' register to copy 'Next' values into 'Current' ones in a synchronized manner. This is different from bank switching which is typically used to change the bus configuration only. - MBQ. the Multi-Byte Quantity bit is used to provide atomic updates when accessing more that one byte, for example a 16-bit volume control would be updated consistently, the intermediate values mixing old MSB with new LSB are not applied. These 6 parameters are used to build a 32-bit address to access the desired Controls. Because of address range, paging is required, but the most often used parameter values are placed in the lower 16 bits of the address. This helps to keep the paging registers constant while updating Controls for a specific Device/Function. Reviewed-by: Rander Wang Reviewed-by: Guennadi Liakhovetski Reviewed-by: Kai Vehmanen Signed-off-by: Pierre-Louis Bossart Signed-off-by: Bard Liao --- include/linux/soundwire/sdw_registers.h | 32 +++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/include/linux/soundwire/sdw_registers.h b/include/linux/soundwire/sdw_registers.h index 0cb1a22685b8..138bec908c40 100644 --- a/include/linux/soundwire/sdw_registers.h +++ b/include/linux/soundwire/sdw_registers.h @@ -309,4 +309,36 @@ #define SDW_CASC_PORT_MASK_INTSTAT3 1 #define SDW_CASC_PORT_REG_OFFSET_INTSTAT3 2 +/* + * v1.2 device - SDCA address mapping + * + * Spec definition + * Bits Contents + * 31 0 (required by addressing range) + * 30:26 0b10000 (Control Prefix) + * 25 0 (Reserved) + * 24:22 Function Number [2:0] + * 21 Entity[6] + * 20:19 Control Selector[5:4] + * 18 0 (Reserved) + * 17:15 Control Number[5:3] + * 14 Next + * 13 MBQ + * 12:7 Entity[5:0] + * 6:3 Control Selector[3:0] + * 2:0 Control Number[2:0] + */ + +#define SDW_SDCA_CTL(fun, ent, ctl, ch) (BIT(30) | \ + (((fun) & 0x7) << 22) | \ + (((ent) & 0x40) << 15) | \ + (((ent) & 0x3f) << 7) | \ + (((ctl) & 0x30) << 15) | \ + (((ctl) & 0x0f) << 3) | \ + (((ch) & 0x38) << 12) | \ + ((ch) & 0x07)) + +#define SDW_SDCA_MBQ_CTL(reg) ((reg) | BIT(13)) +#define SDW_SDCA_NEXT_CTL(reg) ((reg) | BIT(14)) + #endif /* __SDW_REGISTERS_H */ -- 2.17.1