Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1881rwb; Wed, 7 Dec 2022 13:34:02 -0800 (PST) X-Google-Smtp-Source: AA0mqf6RlsGYdZGss+ErFNOsPKHGScwA4sroTu9u2L6LYlg1yZL/EUUOAqoVUL8hQIU2WUycXN/d X-Received: by 2002:a17:906:a113:b0:7b2:7c9a:1849 with SMTP id t19-20020a170906a11300b007b27c9a1849mr77371300ejy.733.1670448842035; Wed, 07 Dec 2022 13:34:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670448842; cv=none; d=google.com; s=arc-20160816; b=Ws/+MMfvasPcdLW/DSmeCqj7SLsgceoW2Lu7q3en9az4MY76mENaPea1GolrVV2C++ LIOrTDg25F9c2QnnxdWVfiG/JXW0tMeBCtDRLKQ0Y5jZMo2si3OAzRk1LFsSFWvQQVwB wb+mUf7o6m3nv3t4l3O7BxeXuDXwFgibLS16+nXzvaizw06lGGAUZRfNMeNZdQDpWzZk uQufpTW8ZF+udozOPCYtnPb/ueeEpCliDJx9gF4I/112eGv1dhHzgxmT16P6DM9Q87M6 kx/+7hkr8x6trjDl3h/kKG0YDb6ylOnHNZ23fRoiWCNA7QjbpJf19sk2byjUAXyMdZfb rBnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=5mynKz5oCR+Be228hwbU8PAPBPy+Q/WCZLZqKob1ZyY=; b=PkRtfLKVZm4U9jBaVUOZLSvE/kKXRl8m360CDUt+zFMOeVvI7JTHe0f4+GAJDjOMNq jSLQxeVmtJ1TS2ePkD8c+/LGFXmyxV6ntAxX+QsLLMes/lkENEL4hU1rcuCknmWINruv vsSkt/4GZ5GKt5vRjHLxUURPwANWv34b1ifElTj9QZKu/xDxdRRxnHfG5QlB+UXjSAzN nsdxp0nIwOk7f5s1gLNyYAHH3/jCxECC1J6elWptyL/JiwFCkuQMnvGgA/BVuNli8Jk5 wHn2KKp76SYfXzHmKgQdJmJKx5Dxsbawkgn4Trlj/GBSBJoSw2Awk3d2spiulMhXzFZO h7ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=K9Bw0uYC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i6-20020a1709064fc600b0078d93325645si19332109ejw.405.2022.12.07.13.33.07; Wed, 07 Dec 2022 13:34:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=K9Bw0uYC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230086AbiLGUxH (ORCPT + 75 others); Wed, 7 Dec 2022 15:53:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230013AbiLGUwr (ORCPT ); Wed, 7 Dec 2022 15:52:47 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35C238324B for ; Wed, 7 Dec 2022 12:51:17 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id i19-20020a253b13000000b0070358cca7f7so6306981yba.9 for ; Wed, 07 Dec 2022 12:51:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=5mynKz5oCR+Be228hwbU8PAPBPy+Q/WCZLZqKob1ZyY=; b=K9Bw0uYC5EINGJ0SvI1INZ2sag4QfyGThlbB2Zt3HAHUnI+Oa7hKjMuD8YLFZ7rSre 8Vfp81jZdch4auKOIS1u61VnYeDU7NnBqrKxpgE+pUgzGyPwVy6OytACzzxNXvbpfbWJ t9+5kaM+8VllcO/yeRnmvOBDMglyHW0TOwz3ri938gHynFPisQ6u2r+twv7wQzDtSqJx UR/lZaYU1G3QIRVxzg4B2jVXa2QRXpjCS7mGEfd/1VJ/VtQbcBNdfz/IOxJCZF8TGI7G oOTDv9EBJnYNEcFFJtCBETYRP6vvcZqsLaGhnXCQvaBevfeHIrM+nrmF/lxC5WW6H4LK SBYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=5mynKz5oCR+Be228hwbU8PAPBPy+Q/WCZLZqKob1ZyY=; b=oRTkmzNvcmFwr4npQzC/np9TM7VEtWYVsp56aqMySM66Rzboqkl1BDtjXWKMInO33Y kydjk0eTYE1U15afoNdheyuu5I9BYU3Xlqz8rhXWw9zSI8j5Iti0cUAqBMCZq4JnyzG4 qUlZIxwlOf/y0qs4kktPNnPXcOYPGHXOMjhBWtq2qvYqg/zMbP7Uxs8mtZGAZOM16nYa ed5+jODZB4WaX6Gnnt78q342ygJkY1I3zXU8kBp5X9r4BKTBC1Ux2eE3qCcTRptJAaGO QP6QYXx+ke7D3bbWNykfMDga5l+Tnwv38aZ1qz4f/2YXQ6nbLNSqfuLlbrkvUFjWX6VI KPpQ== X-Gm-Message-State: ANoB5pmtKoPYW5bHsigEtR0Z55phVBae6OyBrJYUdwdnOSICknz1VUYy fVhkzuVrwH2PIWVmLS6e6tlY4DEwwl4v/KqA X-Received: from zenghuchen.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:2448]) (user=zenghuchen job=sendgmr) by 2002:a25:248d:0:b0:6f1:29d9:44ba with SMTP id k135-20020a25248d000000b006f129d944bamr61196926ybk.632.1670446276466; Wed, 07 Dec 2022 12:51:16 -0800 (PST) Date: Wed, 7 Dec 2022 15:50:59 -0500 Mime-Version: 1.0 X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog Message-ID: <20221207205059.3848851-1-zenghuchen@google.com> Subject: [PATCH] I3C: export SETDASA method From: Jack Chen To: Alexandre Belloni Cc: linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, Jesus Sanchez-Palencia , Mark Slevinsky , Jack Chen Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Because not all I3C drivers have the hot-join feature ready, and especially not all I3C devices support hot-join feature, exporting SETDASA method could be useful. With this function, the I3C controller could perform a DAA to I3C devices when users decide to turn these I3C devices off and on again during run-time. Tested: This change has been tested with turnning off an I3C device and turning on it again during run-time. The device driver calls SETDASA method to perform DAA to the device. And communication between I3C controller and device is set up again correctly. Signed-off-by: Jack Chen --- drivers/i3c/device.c | 20 ++++++++++++++++++++ drivers/i3c/internals.h | 1 + drivers/i3c/master.c | 19 +++++++++++++++++++ include/linux/i3c/device.h | 2 ++ 4 files changed, 42 insertions(+) diff --git a/drivers/i3c/device.c b/drivers/i3c/device.c index e92d3e9a52bd..9762630b917e 100644 --- a/drivers/i3c/device.c +++ b/drivers/i3c/device.c @@ -50,6 +50,26 @@ int i3c_device_do_priv_xfers(struct i3c_device *dev, } EXPORT_SYMBOL_GPL(i3c_device_do_priv_xfers); +/** + * i3c_device_do_setdasa() - do I3C dynamic address assignement with + * static address + * + * @dev: device with which the DAA should be done + * + * Return: 0 in case of success, a negative error core otherwise. + */ +int i3c_device_do_setdasa(struct i3c_device *dev) +{ + int ret; + + i3c_bus_normaluse_lock(dev->bus); + ret = i3c_dev_setdasa_locked(dev->desc); + i3c_bus_normaluse_unlock(dev->bus); + + return ret; +} +EXPORT_SYMBOL_GPL(i3c_device_do_setdasa); + /** * i3c_device_get_info() - get I3C device information * diff --git a/drivers/i3c/internals.h b/drivers/i3c/internals.h index 86b7b44cfca2..908a807badaf 100644 --- a/drivers/i3c/internals.h +++ b/drivers/i3c/internals.h @@ -15,6 +15,7 @@ extern struct bus_type i3c_bus_type; void i3c_bus_normaluse_lock(struct i3c_bus *bus); void i3c_bus_normaluse_unlock(struct i3c_bus *bus); +int i3c_dev_setdasa_locked(struct i3c_dev_desc *dev); int i3c_dev_do_priv_xfers_locked(struct i3c_dev_desc *dev, struct i3c_priv_xfer *xfers, int nxfers); diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index 351c81a929a6..d7e6f6c99aea 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -2708,6 +2708,25 @@ int i3c_master_unregister(struct i3c_master_controller *master) } EXPORT_SYMBOL_GPL(i3c_master_unregister); +int i3c_dev_setdasa_locked(struct i3c_dev_desc *dev) +{ + struct i3c_master_controller *master; + + if (!dev) + return -ENOENT; + + master = i3c_dev_get_master(dev); + if (!master) + return -EINVAL; + + if (!dev->boardinfo || !dev->boardinfo->init_dyn_addr || + !dev->boardinfo->static_addr) + return -EINVAL; + + return i3c_master_setdasa_locked(master, dev->info.static_addr, + dev->boardinfo->init_dyn_addr); +} + int i3c_dev_do_priv_xfers_locked(struct i3c_dev_desc *dev, struct i3c_priv_xfer *xfers, int nxfers) diff --git a/include/linux/i3c/device.h b/include/linux/i3c/device.h index 8242e13e7b0b..90b6e0f7d29f 100644 --- a/include/linux/i3c/device.h +++ b/include/linux/i3c/device.h @@ -293,6 +293,8 @@ int i3c_device_do_priv_xfers(struct i3c_device *dev, struct i3c_priv_xfer *xfers, int nxfers); +int i3c_device_do_setdasa(struct i3c_device *dev); + void i3c_device_get_info(struct i3c_device *dev, struct i3c_device_info *info); struct i3c_ibi_payload { -- 2.39.0.rc0.267.gcb52ba06e7-goog