From nobody Sun Feb 20 11:39:01 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 8742619D18AE; Sun, 20 Feb 2022 11:39:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4K1k3T3MMQz4hRD; Sun, 20 Feb 2022 11:39:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645357141; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=IxmfAhFUA7wtNt7KXsRrk9U3zRXCWb4Igk+g66RO0co=; b=qiqFx7OtAEsU2WjqEj9qu7HhGvQqN7mxjW42oqmN2yBdunpidJQaYSpU3iHRZeN/e2rUMv PCvS1pvVpI5D8hdIUyOEnM3ve/OpiqS7UWEuAEClAeZNkA//9OsPQJGLSxmYz0aBzUan36 Lx2eI8W/C1GhafoiachNu6MG0GPi44g1oOFiUwtqfDzC6bpIvHukxLwYtz5c2bn49Tg9pi br44gclNOzZbal4gQDfUrvgztC70BSLgRjpWLTtatVhaofbxBm5tLtqA8jBwZjGzKLQTqM 5BT5/ukAPN/jdhITfnCOuQK6CIZhzw1W9PmKh4KrLoAubo9OSGAKgdqkwsV52A== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4F1361BF1D; Sun, 20 Feb 2022 11:39:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 21KBd15j072901; Sun, 20 Feb 2022 11:39:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21KBd1qc072900; Sun, 20 Feb 2022 11:39:01 GMT (envelope-from git) Date: Sun, 20 Feb 2022 11:39:01 GMT Message-Id: <202202201139.21KBd1qc072900@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Michal Meloun Subject: git: 1bd3e8ba6966 - main - ofw_iicbus: Add method for manual setting of basic OFW parameters. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mmel X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1bd3e8ba696633ccd7525030d951b58ade167814 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645357141; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=IxmfAhFUA7wtNt7KXsRrk9U3zRXCWb4Igk+g66RO0co=; b=QAsaS0FgVGrfuImBdeV/zeExwucMNEz1Y7h48x7yNYcx10YqqkYkvhgCD9sQCiGxPii4U7 dDT6wuBP71+7wRICbIo6DE1cqtTDsYUyoEV5Cvt3IoyP7G7dzn8n47/MoyD8miy7BOt4dU sRLWL8f4HT/PNrYvovsZPf5uNeEUPX7zCuwn8r9SJwRoJoS0yvdLt1WbKTafPEMKMGrI6w 5sFlu9nw7qzK1wPPC440vuUHUX3UGWqUEWMM55tf0dLPeUMhlCNy2rVleeaZxNxgrLhtNS dzMP4wspejeiNsgg51x0Q7d8aW8HoS/YpsxU7hnfc+AxMdDmk1M+IcuoTnSTtg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1645357141; a=rsa-sha256; cv=none; b=QckcYv4pTO6xu4OhLSFwnjvZOIj5DJGsYJXAqY/HGPwbugAc2qLsbdPTMhiRJ+NJ49VMz0 hnsjdSJPrxEQuuTH56NFf131O4/eeXpmU+S0v8s4QjX+I4Sq6AdZr65CIkI1Fxd/KKJQHN 9W96KFxXbtpgGxRJzsVH7zl/5oATDHamz5x7X9T12q7O755Z91gJAEIQNOIJeV8C+d6ilu rk8GIxYgiKM3s5uKVegbT9BpCuUx41VEaaGbWfAh9emwNEkfkVNvH1FnNfabHZCdyvoKnW W0bMu3zzbweUelUH62IqXNc/bf0nypl+PYaT52mrPifMxjkI5L0XXTvYHGXMcQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mmel: URL: https://cgit.FreeBSD.org/src/commit/?id=1bd3e8ba696633ccd7525030d951b58ade167814 commit 1bd3e8ba696633ccd7525030d951b58ade167814 Author: Michal Meloun AuthorDate: 2022-02-20 09:45:14 +0000 Commit: Michal Meloun CommitDate: 2022-02-20 11:25:58 +0000 ofw_iicbus: Add method for manual setting of basic OFW parameters. Some IIC multifunction devices may have multiple I2C addresses per chip, but only the primary address is listed in the DT (e.g. MAX776200). In this case, the sub-devices for the secondary addresses must be created manually with fixed OFW parameters (node, name, compatibility string, IIC address). Add a bus method to the ofw_iicbus interface that does this. MFC after: 4 weeks --- sys/conf/files | 1 + sys/dev/iicbus/ofw_iicbus.c | 29 ++++++++++++++++++++++++++++ sys/dev/iicbus/ofw_iicbus_if.m | 43 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+) diff --git a/sys/conf/files b/sys/conf/files index f002598d1c3d..fb57567d3e87 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1854,6 +1854,7 @@ dev/iicbus/mux/ltc430x.c optional ltc430x dev/iicbus/mux/pca954x.c optional pca954x dev/iicbus/nxprtc.c optional nxprtc | pcf8563 dev/iicbus/ofw_iicbus.c optional fdt iicbus +dev/iicbus/ofw_iicbus_if.m optional fdt iicbus dev/iicbus/pcf8574.c optional pcf8574 dev/iicbus/pcf8591.c optional pcf8591 dev/iicbus/rtc8583.c optional rtc8583 diff --git a/sys/dev/iicbus/ofw_iicbus.c b/sys/dev/iicbus/ofw_iicbus.c index 9be05d73abde..2ccc9698e5bd 100644 --- a/sys/dev/iicbus/ofw_iicbus.c +++ b/sys/dev/iicbus/ofw_iicbus.c @@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$"); #include #include "iicbus_if.h" +#include "ofw_iicbus_if.h" /* Methods */ static device_probe_t ofw_iicbus_probe; @@ -50,6 +51,8 @@ static device_t ofw_iicbus_add_child(device_t dev, u_int order, const char *name, int unit); static const struct ofw_bus_devinfo *ofw_iicbus_get_devinfo(device_t bus, device_t dev); +static int ofw_iicbus_set_devinfo(device_t bus, device_t dev, + phandle_t ofw_node, char *ofw_name, char *ofw_compat, int i2c_addr); static device_method_t ofw_iicbus_methods[] = { /* Device interface */ @@ -68,6 +71,9 @@ static device_method_t ofw_iicbus_methods[] = { DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node), DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type), + /* ofw_iicbus interface */ + DEVMETHOD(ofw_iicbus_set_devinfo, ofw_iicbus_set_devinfo), + DEVMETHOD_END }; @@ -238,3 +244,26 @@ ofw_iicbus_get_devinfo(device_t bus, device_t dev) dinfo = device_get_ivars(dev); return (&dinfo->opd_obdinfo); } + +static int +ofw_iicbus_set_devinfo(device_t bus, device_t dev, phandle_t ofw_node, + char *ofw_name, char *ofw_compat, int i2c_addr) +{ + struct ofw_iicbus_devinfo *devi; + + /* + * Setup OFW-related parts of the ivars for manually + * created ofw_iicbus childern. + */ + devi = device_get_ivars(dev); + if (devi == NULL) + return (ENXIO); + + devi->opd_obdinfo.obd_node = ofw_node; + if (ofw_name != NULL) + devi->opd_obdinfo.obd_name = strdup(ofw_name, M_OFWPROP); + if (ofw_compat != NULL) + devi->opd_obdinfo.obd_compat = strdup(ofw_compat, M_OFWPROP); + devi->opd_dinfo.addr = i2c_addr; + return (0); +} diff --git a/sys/dev/iicbus/ofw_iicbus_if.m b/sys/dev/iicbus/ofw_iicbus_if.m new file mode 100644 index 000000000000..a2b0bd2761db --- /dev/null +++ b/sys/dev/iicbus/ofw_iicbus_if.m @@ -0,0 +1,43 @@ +#- +# SPDX-License-Identifier: BSD-2-Clause-FreeBSD +# +# Copyright 2020 Michal Meloun +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# + +#include +#include + +INTERFACE ofw_iicbus; + +# +# Interpret interrupt +# +METHOD int set_devinfo { + device_t bus; + device_t dev; + phandle_t ofw_node; + char *ofw_name; + char *ofw_compat; + int i2c_addr; +};