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 *