From patchwork Fri Oct 6 15:51:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 115080 Delivered-To: patch@linaro.org Received: by 10.80.163.170 with SMTP id s39csp1520754edb; Fri, 6 Oct 2017 08:53:17 -0700 (PDT) X-Received: by 10.98.139.76 with SMTP id j73mr2684162pfe.265.1507305197388; Fri, 06 Oct 2017 08:53:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507305197; cv=none; d=google.com; s=arc-20160816; b=KPqwbO38wiaMEBnjvXDSQSC/HOtBcDsn7MBxPLQK7yTP7hzSgVKnEE6+PM1C8OAaDC D4mW4ySIFkOBQER9FVpZ7o7ZPCPx6KbsvOMbQpBIsMxV/oVlR36u2vBMkmVDFVEpK8e4 lxQrNztczXcTzhWA56roVR/ZMk53lFr8bw9FRevsZTMEm5hXznzVQeaogqewkyCOMXMI Zq2tv5NibG9+ScOuvj/R4rZ/GD9xwQB1Pk1nd/QkX7Whm40IKTMRmboNLrBRXGjsSTsP 7ILp/JKCCf0wdZcTPvD2XUIyuXPGB+vNTH/tLESL0bMsh3Aw8dz8VHCOQwEe1DLYli2e WteQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=K2opC3HzCRA/nqrPh9khK157iBJ5GKb7yluBigMkfxs=; b=CFyjFw6+7AETCOKfCMyv9n1tnLv2X+URnYxLj639E6ypMRJOYz/O4NBaEPDj7Pa2Kr cYd36K0HPyiU5bQHU1iqdwwyKikP4lOAYxmuEAFGVoTeiFPJSD5m/SgCBpi+7Jky8WJx +FTMCdtMB4y8EVAG+I9a8aXOp42rr1wn6RjOd6Ld6IH+K47qucTfZxfC6wbWYmUztDnL TfbMHCBLKRYw81wIxLfvew9oRJcK5zvBJcdt86AuHkc576fhY7zNNX55WE+r32pqDIW+ kJ5qIBOFuPRLK7QLNWXkswJlQQD9B6TTMWW5o4xO+fOuXMcMemdKE7ojpOzIee9+NuNN AMeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=NDVlMZul; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u65si1465971pfd.623.2017.10.06.08.53.17; Fri, 06 Oct 2017 08:53:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=NDVlMZul; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752614AbdJFPxA (ORCPT + 11 others); Fri, 6 Oct 2017 11:53:00 -0400 Received: from mail-wr0-f179.google.com ([209.85.128.179]:55434 "EHLO mail-wr0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752880AbdJFPwC (ORCPT ); Fri, 6 Oct 2017 11:52:02 -0400 Received: by mail-wr0-f179.google.com with SMTP id 22so2139575wrb.12 for ; Fri, 06 Oct 2017 08:52:01 -0700 (PDT) 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=wPgSWez1b1gQ2n+EaiZxJNwk0q8/YC0u3vic+IYGWEI=; b=NDVlMZuldgTzGzmc3Z95ze0QNTJHR+ejWOjsbpUn66kV1cvz2G5oGi5PcJ7bYmSSHt ha4VytiKAZjB2FC//RVCIP53q2+xFN/Ht6BvHpc63jl3cA6UFYKjGCsmx7uJHqIAcRna vG1r9dT9dx5X8raD/kfbSpn3r2/xPoRUb8DvQ= 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=wPgSWez1b1gQ2n+EaiZxJNwk0q8/YC0u3vic+IYGWEI=; b=GwQYGC6PN9tK2d9wc4gj2ruk7b5DKGZBbB5wyGht40CQtc9jo4Rbc9VQhhTYortYCi y0NwRrliTfiRZ5ZY3Iw/YI+H+8VrtJJ14ikg+1VIb5Nv6dBWmvXG95Sa7rp/zHsswSTT NxxjclQgJZPeIUN04NyXHsVeUv80k9tiHk/asy4Rcfi1Am/157Hd/8oJM9EBzN2Lowp+ e75kRoziRIXiM0Jv2OC8dlM93l6Ncx/b0a5Tq9lDurKuzQJvri8H0YD71O9Aw8pqjyZ8 b545cy0khT/aerABm4t56C72rmrmGrrhNarvzmFaekXrcWXwkmNVxp+rtYF4Uablc9eb e2pA== X-Gm-Message-State: AMCzsaWSHvZUiC7paVgGFBOd2QWQI7TjgowpyGgW5aCHGPkDMyqP2G+U ncAGADM8PsgM/e548wSQjPW1lg== X-Google-Smtp-Source: AOwi7QAxoVOrttBCFsHS3vxO2nxvBQrCDkS/mgbLJUtvJTCul8anDNYvd7KlR7Wxtw0k4vGZG+AJQQ== X-Received: by 10.223.163.151 with SMTP id l23mr2476076wrb.73.1507305120571; Fri, 06 Oct 2017 08:52:00 -0700 (PDT) Received: from localhost.localdomain (static.8.26.4.46.clients.your-server.de. [46.4.26.8]) by smtp.gmail.com with ESMTPSA id r21sm1510327wmd.26.2017.10.06.08.51.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 06 Oct 2017 08:52:00 -0700 (PDT) From: srinivas.kandagatla@linaro.org To: gregkh@linuxfoundation.org, broonie@kernel.org, alsa-devel@alsa-project.org Cc: sdharia@codeaurora.org, bp@suse.de, poeschel@lemonage.de, treding@nvidia.com, gong.chen@linux.intel.com, andreas.noever@gmail.com, alan@linux.intel.com, mathieu.poirier@linaro.org, daniel@ffwll.ch, jkosina@suse.cz, sharon.dvir1@mail.huji.ac.il, joe@perches.com, davem@davemloft.net, james.hogan@imgtec.com, michael.opdenacker@free-electrons.com, robh+dt@kernel.org, pawel.moll@arm.com, mark.rutland@arm.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, kheitke@audience.com, linux-arm-msm@vger.kernel.org, arnd@arndb.de, Srinivas Kandagatla Subject: [Patch v6 6/7] regmap: add SLIMBUS support Date: Fri, 6 Oct 2017 17:51:35 +0200 Message-Id: <20171006155136.4682-7-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171006155136.4682-1-srinivas.kandagatla@linaro.org> References: <20171006155136.4682-1-srinivas.kandagatla@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.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 | 89 ++++++++++++++++++++++++++++++++++++ include/linux/regmap.h | 18 ++++++++ 4 files changed, 112 insertions(+) create mode 100644 drivers/base/regmap/regmap-slimbus.c -- 2.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/base/regmap/Kconfig b/drivers/base/regmap/Kconfig index 073c0b7..b79de7c 100644 --- a/drivers/base/regmap/Kconfig +++ b/drivers/base/regmap/Kconfig @@ -19,6 +19,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 0cf4abc..b16d367 100644 --- a/drivers/base/regmap/Makefile +++ b/drivers/base/regmap/Makefile @@ -7,6 +7,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 0000000..5ae24ab --- /dev/null +++ b/drivers/base/regmap/regmap-slimbus.c @@ -0,0 +1,89 @@ +/* + * 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 *slim = context; + struct slim_val_inf msg = {0,}; + + msg.start_offset = reg; + msg.num_bytes = 1; + msg.rbuf = (void *)val; + + return slim_request_val_element(slim, &msg); +} + +static int regmap_slimbus_byte_reg_write(void *context, unsigned int reg, + unsigned int val) +{ + struct slim_device *slim = context; + struct slim_val_inf msg = {0,}; + + msg.start_offset = reg; + msg.num_bytes = 1; + msg.wbuf = (void *)&val; + + return slim_change_val_element(slim, &msg); +} + +static struct regmap_bus regmap_slimbus_bus = { + .reg_write = regmap_slimbus_byte_reg_write, + .reg_read = regmap_slimbus_byte_reg_read, +}; + +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"); diff --git a/include/linux/regmap.h b/include/linux/regmap.h index 978abfb..49c8db1 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, @@ -566,6 +571,19 @@ int regmap_attach_dev(struct device *dev, struct regmap *map, 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 * * @dev: Device that will be interacted with