From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2768BC282DA for ; Tue, 16 Apr 2019 06:15:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F37B22075B for ; Tue, 16 Apr 2019 06:15:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727232AbfDPGP5 (ORCPT ); Tue, 16 Apr 2019 02:15:57 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:48220 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726805AbfDPGP5 (ORCPT ); Tue, 16 Apr 2019 02:15:57 -0400 Received: from localhost (unknown [IPv6:2a01:e0a:2c:6930:b93f:9fae:b276:a89a]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: bbrezillon) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id F0993260C42; Tue, 16 Apr 2019 07:15:54 +0100 (BST) Date: Tue, 16 Apr 2019 08:15:51 +0200 From: Boris Brezillon To: Vitor Soares Cc: linux-iio@vger.kernel.org, linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, pmeerw@pmeerw.net, lars@metafoo.de, knaack.h@gmx.de, jic23@kernel.org, lorenzo.bianconi83@gmail.com, bbrezillon@kernel.org, rafael@kernel.org, gregkh@linuxfoundation.org, broonie@kernel.org, joao.pinto@synopsys.com Subject: Re: [PATCH 1/3] remap: Add I3C bus support Message-ID: <20190416081551.6f21bc38@collabora.com> In-Reply-To: References: Organization: Collabora X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Typo in the subject: s/remap/regmap/ On Mon, 15 Apr 2019 21:19:39 +0200 Vitor Soares wrote: > Add basic support for I3C bus. > This is a simple implementation that only give support > for Read and Write commands. > > Signed-off-by: Vitor Soares > --- > drivers/base/regmap/Kconfig | 6 +++- > drivers/base/regmap/Makefile | 1 + > drivers/base/regmap/regmap-i3c.c | 62 ++++++++++++++++++++++++++++++++++++++++ > include/linux/regmap.h | 20 +++++++++++++ > 4 files changed, 88 insertions(+), 1 deletion(-) > create mode 100644 drivers/base/regmap/regmap-i3c.c > > diff --git a/drivers/base/regmap/Kconfig b/drivers/base/regmap/Kconfig > index 6ad5ef4..c8bbf53 100644 > --- a/drivers/base/regmap/Kconfig > +++ b/drivers/base/regmap/Kconfig > @@ -4,7 +4,7 @@ > # subsystems should select the appropriate symbols. > > config REGMAP > - default y if (REGMAP_I2C || REGMAP_SPI || REGMAP_SPMI || REGMAP_W1 || REGMAP_AC97 || REGMAP_MMIO || REGMAP_IRQ) > + default y if (REGMAP_I2C || REGMAP_SPI || REGMAP_SPMI || REGMAP_W1 || REGMAP_AC97 || REGMAP_MMIO || REGMAP_IRQ || REGMAP_I3C) > select IRQ_DOMAIN if REGMAP_IRQ > bool > > @@ -49,3 +49,7 @@ config REGMAP_SOUNDWIRE > config REGMAP_SCCB > tristate > depends on I2C > + > +config REGMAP_I3C > + tristate > + depends on I3C > diff --git a/drivers/base/regmap/Makefile b/drivers/base/regmap/Makefile > index f5b4e88..ff6c7d8 100644 > --- a/drivers/base/regmap/Makefile > +++ b/drivers/base/regmap/Makefile > @@ -16,3 +16,4 @@ obj-$(CONFIG_REGMAP_IRQ) += regmap-irq.o > obj-$(CONFIG_REGMAP_W1) += regmap-w1.o > obj-$(CONFIG_REGMAP_SOUNDWIRE) += regmap-sdw.o > obj-$(CONFIG_REGMAP_SCCB) += regmap-sccb.o > +obj-$(CONFIG_REGMAP_I3C) += regmap-i3c.o > diff --git a/drivers/base/regmap/regmap-i3c.c b/drivers/base/regmap/regmap-i3c.c > new file mode 100644 > index 0000000..565997b > --- /dev/null > +++ b/drivers/base/regmap/regmap-i3c.c > @@ -0,0 +1,62 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Copyright (c) 2018 Synopsys, Inc. and/or its affiliates. > + * > + * Author: Vitor Soares > + */ > + > +#include > +#include > +#include > +#include > + > +static int regmap_i3c_write(void *context, const void *data, size_t count) > +{ > + struct device *dev = context; > + struct i3c_device *i3c = dev_to_i3cdev(dev); > + struct i3c_priv_xfer xfers[] = { > + { > + .rnw = false, > + .len = count, > + .data.out = data, > + }, > + }; > + > + return i3c_device_do_priv_xfers(i3c, xfers, 1); > +} > + > +static int regmap_i3c_read(void *context, > + const void *reg, size_t reg_size, > + void *val, size_t val_size) > +{ > + struct device *dev = context; > + struct i3c_device *i3c = dev_to_i3cdev(dev); > + struct i3c_priv_xfer xfers[2]; > + > + xfers[0].rnw = false; > + xfers[0].len = reg_size; > + xfers[0].data.out = reg; > + > + xfers[1].rnw = true; > + xfers[1].len = val_size; > + xfers[1].data.in = val; > + > + return i3c_device_do_priv_xfers(i3c, xfers, 2); > +} > + > +static struct regmap_bus regmap_i3c = { > + .write = regmap_i3c_write, > + .read = regmap_i3c_read, > +}; > + > +struct regmap *__devm_regmap_init_i3c(struct i3c_device *i3c, > + const struct regmap_config *config, > + struct lock_class_key *lock_key, > + const char *lock_name) > +{ > + return __devm_regmap_init(&i3c->dev, ®map_i3c, &i3c->dev, config, > + lock_key, lock_name); > +} > +EXPORT_SYMBOL_GPL(__devm_regmap_init_i3c); > + > +MODULE_LICENSE("GPL"); > diff --git a/include/linux/regmap.h b/include/linux/regmap.h > index daeec7d..f65984d 100644 > --- a/include/linux/regmap.h > +++ b/include/linux/regmap.h > @@ -25,6 +25,7 @@ struct module; > struct clk; > struct device; > struct i2c_client; > +struct i3c_device; > struct irq_domain; > struct slim_device; > struct spi_device; > @@ -624,6 +625,10 @@ 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); > +struct regmap *__devm_regmap_init_i3c(struct i3c_device *i3c, > + const struct regmap_config *config, > + struct lock_class_key *lock_key, > + const char *lock_name); > /* > * Wrapper for regmap_init macros to include a unique lockdep key and name > * for each call. No-op if CONFIG_LOCKDEP is not set. > @@ -982,6 +987,21 @@ bool regmap_ac97_default_volatile(struct device *dev, unsigned int reg); > #define devm_regmap_init_slimbus(slimbus, config) \ > __regmap_lockdep_wrapper(__devm_regmap_init_slimbus, #config, \ > slimbus, config) > + > +/** > + * devm_regmap_init_i3c() - Initialise managed register map Maybe we should have a more specific name here, as some might want to access registers using HDR modes (devm_regmap_init_i3c_sdr()?) > + * > + * @i3c: 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. The regmap will be automatically freed by the > + * device management code. > + */ > +#define devm_regmap_init_i3c(i3c, config) \ > + __regmap_lockdep_wrapper(__devm_regmap_init_i3c, #config, \ > + i3c, config) > + > int regmap_mmio_attach_clk(struct regmap *map, struct clk *clk); > void regmap_mmio_detach_clk(struct regmap *map); > void regmap_exit(struct regmap *map); From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B02ABC282DD for ; Tue, 16 Apr 2019 11:12:28 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7DD7320857 for ; Tue, 16 Apr 2019 11:12:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Wmbav75F" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7DD7320857 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-i3c-bounces+linux-i3c=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=urTptU3uBQz69OFdE574bE9beNUchv4lRcv1SCtOL44=; b=Wmbav75FMNwJdA zj7/xmK1MgQx82sXa8hQUIvonJT4f2kuswW+djzRcGZvz38QH7GB1N/Zvhd+KuYLsRLosRuxrVMrx +4YkX4ziAealBz8lFu+g33VfpUKcKXpsj8u0SdZOt9mN2M5XX1u9dzTpB4xmCZo3/pwe/e9t7+G8f ouUGsOI5hdJBKcZJ3+3KNFu5DXc3yJQcXHM0FfrKGIlGHxCvAoGiWttY/M7ZyBnPqjjSG/angzjgG C7QUZfgCsWdobZkkzsYu8E3LnXVNgcQRsTGCzUEnZI8cMrgViZo7l5vJrtWEK0pEkGyxsjuLGtgV2 dBdS2gVvtJozGBsXqZ+g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hGM0p-0001Fb-Uo; Tue, 16 Apr 2019 11:12:27 +0000 Received: from bhuna.collabora.co.uk ([46.235.227.227]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hGHNs-0001Cm-K0 for linux-i3c@lists.infradead.org; Tue, 16 Apr 2019 06:16:00 +0000 Received: from localhost (unknown [IPv6:2a01:e0a:2c:6930:b93f:9fae:b276:a89a]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: bbrezillon) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id F0993260C42; Tue, 16 Apr 2019 07:15:54 +0100 (BST) Date: Tue, 16 Apr 2019 08:15:51 +0200 From: Boris Brezillon To: Vitor Soares Subject: Re: [PATCH 1/3] remap: Add I3C bus support Message-ID: <20190416081551.6f21bc38@collabora.com> In-Reply-To: References: Organization: Collabora X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190415_231556_921872_B9D1AD11 X-CRM114-Status: GOOD ( 22.21 ) X-Mailman-Approved-At: Tue, 16 Apr 2019 04:12:26 -0700 X-BeenThere: linux-i3c@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux I3C List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lars@metafoo.de, bbrezillon@kernel.org, linux-iio@vger.kernel.org, gregkh@linuxfoundation.org, joao.pinto@synopsys.com, rafael@kernel.org, linux-kernel@vger.kernel.org, broonie@kernel.org, pmeerw@pmeerw.net, knaack.h@gmx.de, lorenzo.bianconi83@gmail.com, linux-i3c@lists.infradead.org, jic23@kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-i3c" Errors-To: linux-i3c-bounces+linux-i3c=archiver.kernel.org@lists.infradead.org Typo in the subject: s/remap/regmap/ On Mon, 15 Apr 2019 21:19:39 +0200 Vitor Soares wrote: > Add basic support for I3C bus. > This is a simple implementation that only give support > for Read and Write commands. > > Signed-off-by: Vitor Soares > --- > drivers/base/regmap/Kconfig | 6 +++- > drivers/base/regmap/Makefile | 1 + > drivers/base/regmap/regmap-i3c.c | 62 ++++++++++++++++++++++++++++++++++++++++ > include/linux/regmap.h | 20 +++++++++++++ > 4 files changed, 88 insertions(+), 1 deletion(-) > create mode 100644 drivers/base/regmap/regmap-i3c.c > > diff --git a/drivers/base/regmap/Kconfig b/drivers/base/regmap/Kconfig > index 6ad5ef4..c8bbf53 100644 > --- a/drivers/base/regmap/Kconfig > +++ b/drivers/base/regmap/Kconfig > @@ -4,7 +4,7 @@ > # subsystems should select the appropriate symbols. > > config REGMAP > - default y if (REGMAP_I2C || REGMAP_SPI || REGMAP_SPMI || REGMAP_W1 || REGMAP_AC97 || REGMAP_MMIO || REGMAP_IRQ) > + default y if (REGMAP_I2C || REGMAP_SPI || REGMAP_SPMI || REGMAP_W1 || REGMAP_AC97 || REGMAP_MMIO || REGMAP_IRQ || REGMAP_I3C) > select IRQ_DOMAIN if REGMAP_IRQ > bool > > @@ -49,3 +49,7 @@ config REGMAP_SOUNDWIRE > config REGMAP_SCCB > tristate > depends on I2C > + > +config REGMAP_I3C > + tristate > + depends on I3C > diff --git a/drivers/base/regmap/Makefile b/drivers/base/regmap/Makefile > index f5b4e88..ff6c7d8 100644 > --- a/drivers/base/regmap/Makefile > +++ b/drivers/base/regmap/Makefile > @@ -16,3 +16,4 @@ obj-$(CONFIG_REGMAP_IRQ) += regmap-irq.o > obj-$(CONFIG_REGMAP_W1) += regmap-w1.o > obj-$(CONFIG_REGMAP_SOUNDWIRE) += regmap-sdw.o > obj-$(CONFIG_REGMAP_SCCB) += regmap-sccb.o > +obj-$(CONFIG_REGMAP_I3C) += regmap-i3c.o > diff --git a/drivers/base/regmap/regmap-i3c.c b/drivers/base/regmap/regmap-i3c.c > new file mode 100644 > index 0000000..565997b > --- /dev/null > +++ b/drivers/base/regmap/regmap-i3c.c > @@ -0,0 +1,62 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Copyright (c) 2018 Synopsys, Inc. and/or its affiliates. > + * > + * Author: Vitor Soares > + */ > + > +#include > +#include > +#include > +#include > + > +static int regmap_i3c_write(void *context, const void *data, size_t count) > +{ > + struct device *dev = context; > + struct i3c_device *i3c = dev_to_i3cdev(dev); > + struct i3c_priv_xfer xfers[] = { > + { > + .rnw = false, > + .len = count, > + .data.out = data, > + }, > + }; > + > + return i3c_device_do_priv_xfers(i3c, xfers, 1); > +} > + > +static int regmap_i3c_read(void *context, > + const void *reg, size_t reg_size, > + void *val, size_t val_size) > +{ > + struct device *dev = context; > + struct i3c_device *i3c = dev_to_i3cdev(dev); > + struct i3c_priv_xfer xfers[2]; > + > + xfers[0].rnw = false; > + xfers[0].len = reg_size; > + xfers[0].data.out = reg; > + > + xfers[1].rnw = true; > + xfers[1].len = val_size; > + xfers[1].data.in = val; > + > + return i3c_device_do_priv_xfers(i3c, xfers, 2); > +} > + > +static struct regmap_bus regmap_i3c = { > + .write = regmap_i3c_write, > + .read = regmap_i3c_read, > +}; > + > +struct regmap *__devm_regmap_init_i3c(struct i3c_device *i3c, > + const struct regmap_config *config, > + struct lock_class_key *lock_key, > + const char *lock_name) > +{ > + return __devm_regmap_init(&i3c->dev, ®map_i3c, &i3c->dev, config, > + lock_key, lock_name); > +} > +EXPORT_SYMBOL_GPL(__devm_regmap_init_i3c); > + > +MODULE_LICENSE("GPL"); > diff --git a/include/linux/regmap.h b/include/linux/regmap.h > index daeec7d..f65984d 100644 > --- a/include/linux/regmap.h > +++ b/include/linux/regmap.h > @@ -25,6 +25,7 @@ struct module; > struct clk; > struct device; > struct i2c_client; > +struct i3c_device; > struct irq_domain; > struct slim_device; > struct spi_device; > @@ -624,6 +625,10 @@ 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); > +struct regmap *__devm_regmap_init_i3c(struct i3c_device *i3c, > + const struct regmap_config *config, > + struct lock_class_key *lock_key, > + const char *lock_name); > /* > * Wrapper for regmap_init macros to include a unique lockdep key and name > * for each call. No-op if CONFIG_LOCKDEP is not set. > @@ -982,6 +987,21 @@ bool regmap_ac97_default_volatile(struct device *dev, unsigned int reg); > #define devm_regmap_init_slimbus(slimbus, config) \ > __regmap_lockdep_wrapper(__devm_regmap_init_slimbus, #config, \ > slimbus, config) > + > +/** > + * devm_regmap_init_i3c() - Initialise managed register map Maybe we should have a more specific name here, as some might want to access registers using HDR modes (devm_regmap_init_i3c_sdr()?) > + * > + * @i3c: 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. The regmap will be automatically freed by the > + * device management code. > + */ > +#define devm_regmap_init_i3c(i3c, config) \ > + __regmap_lockdep_wrapper(__devm_regmap_init_i3c, #config, \ > + i3c, config) > + > int regmap_mmio_attach_clk(struct regmap *map, struct clk *clk); > void regmap_mmio_detach_clk(struct regmap *map); > void regmap_exit(struct regmap *map); _______________________________________________ linux-i3c mailing list linux-i3c@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-i3c