From patchwork Wed Nov 15 14:10:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 118962 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp4367615qgn; Wed, 15 Nov 2017 06:15:44 -0800 (PST) X-Google-Smtp-Source: AGs4zMa3SyYDdRKq/NoBJSI+OjxsdutUUjmOmfsae0JClq1cLewJVJOUVCC6QZrRfJrttWd3Lc9Y X-Received: by 10.28.58.145 with SMTP id h139mr10830129wma.56.1510755344672; Wed, 15 Nov 2017 06:15:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510755344; cv=none; d=google.com; s=arc-20160816; b=lGzDSSGdosZ+D3FfiUU29ek66Sf+2CdGbPgQUCTcXRsUF7qej600BKRCAycfUTF38m lZvJoqJB2s6a0bt71JLv/iuY/T+s865ZMHRPal370FZJ0tqGBBoXcdMiF46WfQYiU3pr /HIXGi1wKEyAxXA6VtpIZJunDI/QHpcUliOgGjPxrFZ5nssQxeaM101L7fWhIxEmyziF /8pTLUdBGgf1/ep2nYdGqpmZrjrG9eMnfFUYgJ8op74ZP7Hk2TToynjFqmPu6fEWDkgN JxqFNkq6OvQKp8f6BHKetA4DF/nyabq9D5oltBdic1Dwr8+Y8Z01IN48DzVKGoq+8OyO jseg== 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=Lwa9CR950Vh04cnZunS5jfiAn2LHEh0hUoVYJholG28=; b=IPhxvumjbe+N0RrI9yC80f5Myg4CgjQK3q/AtkL18Y8NOywtlqRt6qf4wvyuJJcpaJ 6AHDRzR5AUYCD9m3n8WupkB/A3Ub2VPOowXWQWJVuesxOAH7ory8ByUU/G3bQIFwZuCI RfPaztSDXfJcJiFTFVa7fc1+YKp3x2IB3ctV+rvaBAxElVD4gyiyjYnuI0Z+NGWAK/DJ 5sZ8i8Y1xTipB7od+fdhP3uz23yPtbBbsak29sWjBb9/EKnPOrchcQgJ0i6217vNiDKl 4FaGeViUsWCVJbt67qksjkzUPOofeGeBN6/GSHpf2E26/qZAzBkq51rfhtKXNEwI4Bau oJyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=T66W0183; 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 f7si9242302wmd.196.2017.11.15.06.15.44; Wed, 15 Nov 2017 06:15:44 -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=T66W0183; 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 DAC112675E6; Wed, 15 Nov 2017 15:13:48 +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 10A632675E6; Wed, 15 Nov 2017 15:13:46 +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=-2.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, RCVD_IN_SORBS_SPAM, 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 B29C52675E6 for ; Wed, 15 Nov 2017 15:13:38 +0100 (CET) Received: by mail-wr0-f194.google.com with SMTP id q66so20557202wrb.13 for ; Wed, 15 Nov 2017 06:13:38 -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=qSwu6AF92F7tsGluDHJjT0DP4kZKL7WsXE6VwbmHKh0=; b=T66W0183BWesHiYSN9Aa3YorNce51JsITjbYepVaEmQgAlHvXF4SD963Gq8mmZ/mFO jqzhzArhVOHwtnK2RSGtO5ouVSVHIjL95RBENiF/ME7sFw7gxRv2gcZvZpPvrR790Bsl aw3/KSGf/1oKWbWbQ7+0oKtAdFGiUj9t+wb4M= 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=qSwu6AF92F7tsGluDHJjT0DP4kZKL7WsXE6VwbmHKh0=; b=buqq6YUxYySt8W7jYoR0aaK76ux/rp66qi91KAlpWUd5Pptp+y9k7UcmizwOms29bZ d20at6uE0P/GDOll0G0FKhrH1+ZW3w365Emk9V+pGrQ9kMAqytSXG2W+qsIy3A1rfyut 47x+0P9KByxsqdRiDiJxvcgdHuCc+5hO0SJEdokx74MT4V+eQYLRjofdCGFsX5E8hSbO Y47uOeLtPQXILqp+nE9OtuXfur5F/UwCw8z1ZIzMxJ3VPW8bTyG0cMqQhJ7fDrRD8ero dMHpqrzV0lWE43jrr4Bp6B9sC5vysD1m38r8RHoTZxxXYqe05LrOq6skr41A8b5OarcC eQoA== X-Gm-Message-State: AJaThX69nggvjB27HeBtZDGvKjfpqa7pOW6YtsqwAqpqyTmsIOY9pZ02 NlwiDBrIywiTSkpicF8/UkyuFA== X-Received: by 10.223.189.13 with SMTP id j13mr13828958wrh.94.1510755217943; Wed, 15 Nov 2017 06:13:37 -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 m11sm56707wrf.56.2017.11.15.06.13.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 15 Nov 2017 06:13:36 -0800 (PST) From: srinivas.kandagatla@linaro.org To: gregkh@linuxfoundation.org, broonie@kernel.org, alsa-devel@alsa-project.org Date: Wed, 15 Nov 2017 14:10:38 +0000 Message-Id: <20171115141043.29202-9-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171115141043.29202-1-srinivas.kandagatla@linaro.org> References: <20171115141043.29202-1-srinivas.kandagatla@linaro.org> Cc: mark.rutland@arm.com, michael.opdenacker@free-electrons.com, poeschel@lemonage.de, Srinivas Kandagatla , andreas.noever@gmail.com, arnd@arndb.de, vinod.koul@intel.com, bp@suse.de, devicetree@vger.kernel.org, james.hogan@imgtec.com, pawel.moll@arm.com, linux-arm-msm@vger.kernel.org, sharon.dvir1@mail.huji.ac.il, robh+dt@kernel.org, sdharia@codeaurora.org, alan@linux.intel.com, treding@nvidia.com, mathieu.poirier@linaro.org, jkosina@suse.cz, linux-kernel@vger.kernel.org, daniel@ffwll.ch, joe@perches.com, davem@davemloft.net Subject: [alsa-devel] [PATCH v7 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 | 95 ++++++++++++++++++++++++++++++++++++ include/linux/regmap.h | 18 +++++++ 4 files changed, 118 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 0368fd7b3a41..344440768205 100644 --- a/drivers/base/regmap/Kconfig +++ b/drivers/base/regmap/Kconfig @@ -20,6 +20,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..bbccad3f8b3a --- /dev/null +++ b/drivers/base/regmap/regmap-slimbus.c @@ -0,0 +1,95 @@ +/* + * Register map access API - slimbus support + * + * Copyright 2017 Linaro Inc + * + * Author: Srinivas Kandagatla + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#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; + + if (!sdev) + return 0; + + 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; + + if (!sdev) + return 0; + + 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 978abfbac617..49c8db1dd0ce 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; @@ -449,6 +450,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, @@ -565,6 +570,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 *