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
This commit is contained in:
parent
c8cc568961
commit
1bd3e8ba69
@ -1854,6 +1854,7 @@ dev/iicbus/mux/ltc430x.c optional ltc430x
|
|||||||
dev/iicbus/mux/pca954x.c optional pca954x
|
dev/iicbus/mux/pca954x.c optional pca954x
|
||||||
dev/iicbus/nxprtc.c optional nxprtc | pcf8563
|
dev/iicbus/nxprtc.c optional nxprtc | pcf8563
|
||||||
dev/iicbus/ofw_iicbus.c optional fdt iicbus
|
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/pcf8574.c optional pcf8574
|
||||||
dev/iicbus/pcf8591.c optional pcf8591
|
dev/iicbus/pcf8591.c optional pcf8591
|
||||||
dev/iicbus/rtc8583.c optional rtc8583
|
dev/iicbus/rtc8583.c optional rtc8583
|
||||||
|
@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <dev/ofw/openfirm.h>
|
#include <dev/ofw/openfirm.h>
|
||||||
|
|
||||||
#include "iicbus_if.h"
|
#include "iicbus_if.h"
|
||||||
|
#include "ofw_iicbus_if.h"
|
||||||
|
|
||||||
/* Methods */
|
/* Methods */
|
||||||
static device_probe_t ofw_iicbus_probe;
|
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);
|
const char *name, int unit);
|
||||||
static const struct ofw_bus_devinfo *ofw_iicbus_get_devinfo(device_t bus,
|
static const struct ofw_bus_devinfo *ofw_iicbus_get_devinfo(device_t bus,
|
||||||
device_t dev);
|
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[] = {
|
static device_method_t ofw_iicbus_methods[] = {
|
||||||
/* Device interface */
|
/* 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_node, ofw_bus_gen_get_node),
|
||||||
DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type),
|
DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type),
|
||||||
|
|
||||||
|
/* ofw_iicbus interface */
|
||||||
|
DEVMETHOD(ofw_iicbus_set_devinfo, ofw_iicbus_set_devinfo),
|
||||||
|
|
||||||
DEVMETHOD_END
|
DEVMETHOD_END
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -238,3 +244,26 @@ ofw_iicbus_get_devinfo(device_t bus, device_t dev)
|
|||||||
dinfo = device_get_ivars(dev);
|
dinfo = device_get_ivars(dev);
|
||||||
return (&dinfo->opd_obdinfo);
|
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);
|
||||||
|
}
|
||||||
|
43
sys/dev/iicbus/ofw_iicbus_if.m
Normal file
43
sys/dev/iicbus/ofw_iicbus_if.m
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
#-
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||||
|
#
|
||||||
|
# Copyright 2020 Michal Meloun <mmel@FreeBSD.org>
|
||||||
|
#
|
||||||
|
# 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 <sys/bus.h>
|
||||||
|
#include <dev/ofw/openfirm.h>
|
||||||
|
|
||||||
|
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;
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user