Skip to content

Instantly share code, notes, and snippets.

@tsutsui
Created October 29, 2019 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsutsui/8455b390c32d18f80d0a73c588d73bce to your computer and use it in GitHub Desktop.
Save tsutsui/8455b390c32d18f80d0a73c588d73bce to your computer and use it in GitHub Desktop.
NetBSD/zaurus 9.0_BETA workaround patches
Index: arch/zaurus/conf/Makefile.zaurus.inc
===================================================================
RCS file: /cvsroot/src/sys/arch/zaurus/conf/Makefile.zaurus.inc,v
retrieving revision 1.9
diff -u -p -d -r1.9 Makefile.zaurus.inc
--- arch/zaurus/conf/Makefile.zaurus.inc 25 Aug 2015 02:38:15 -0000 1.9
+++ arch/zaurus/conf/Makefile.zaurus.inc 29 Oct 2019 14:49:11 -0000
@@ -20,6 +20,8 @@ SYSTEM_LD_TAIL_EXTRA+=; \
KERNEL_BASE_VIRT= $(LOADADDRESS)
KERNLDSCRIPT= ldscript
+TEXTADDR= # defined in ldscript
+LINKENTRY= # defined in ldscript
EXTRA_CLEAN+= netbsd.map assym.d ldscript tmp
Index: arch/zaurus/dev/wm8731_zaudio.c
===================================================================
RCS file: /cvsroot/src/sys/arch/zaurus/dev/wm8731_zaudio.c,v
retrieving revision 1.3
diff -u -p -d -r1.3 wm8731_zaudio.c
--- arch/zaurus/dev/wm8731_zaudio.c 8 May 2019 13:40:17 -0000 1.3
+++ arch/zaurus/dev/wm8731_zaudio.c 29 Oct 2019 14:49:11 -0000
@@ -188,18 +188,19 @@ wm8731_write(struct zaudio_softc *sc, in
int
wm8731_match(device_t parent, cfdata_t cf, struct i2c_attach_args *ia)
{
- int match_result;
if (ZAURUS_ISC1000 || ZAURUS_ISC3000)
return 0;
- if (iic_use_direct_match(ia, cf, NULL, &match_result))
- return match_result;
-
- /* indirect config - check typical address */
- if (ia->ia_addr == WM8731_ADDRESS)
- return I2C_MATCH_ADDRESS_ONLY;
-
+ if (ia->ia_name) {
+ /* direct config - check name */
+ if (strcmp(ia->ia_name, "zaudio") == 0)
+ return 1;
+ } else {
+ /* indirect config - check typical address */
+ if (ia->ia_addr == WM8731_ADDRESS)
+ return 1;
+ }
return 0;
}
Index: arch/zaurus/dev/wm8750_zaudio.c
===================================================================
RCS file: /cvsroot/src/sys/arch/zaurus/dev/wm8750_zaudio.c,v
retrieving revision 1.3
diff -u -p -d -r1.3 wm8750_zaudio.c
--- arch/zaurus/dev/wm8750_zaudio.c 8 May 2019 13:40:17 -0000 1.3
+++ arch/zaurus/dev/wm8750_zaudio.c 29 Oct 2019 14:49:11 -0000
@@ -220,18 +220,19 @@ wm8750_write(struct zaudio_softc *sc, in
int
wm8750_match(device_t parent, cfdata_t cf, struct i2c_attach_args *ia)
{
- int match_result;
if (ZAURUS_ISC860)
return 0;
- if (iic_use_direct_match(ia, cf, NULL, &match_result))
- return match_result;
-
- /* indirect config - check typical address */
- if (ia->ia_addr == WM8750_ADDRESS)
- return I2C_MATCH_ADDRESS_ONLY;
-
+ if (ia->ia_name) {
+ /* direct config - check name */
+ if (strcmp(ia->ia_name, "zaudio") == 0)
+ return 1;
+ } else {
+ /* indirect config - check typical address */
+ if (ia->ia_addr == WM8750_ADDRESS)
+ return 1;
+ }
return 0;
}
Index: arch/zaurus/stand/zbsdmod/Makefile
===================================================================
RCS file: /cvsroot/src/sys/arch/zaurus/stand/zbsdmod/Makefile,v
retrieving revision 1.10
diff -u -p -d -r1.10 Makefile
--- arch/zaurus/stand/zbsdmod/Makefile 31 Jan 2016 15:32:13 -0000 1.10
+++ arch/zaurus/stand/zbsdmod/Makefile 29 Oct 2019 14:49:11 -0000
@@ -10,8 +10,18 @@ OBJS= zbsdmod.o
SRCS= zbsdmod.c
NOMAN= # defined
+OBJCOPY_FLAGS= \
+ -R .debug_abbrev \
+ -R .debug_aranges \
+ -R .debug_info \
+ -R .debug_line \
+ -R .debug_loc \
+ -R .debug_ranges \
+ -R .debug_str \
+ -R .eh_frame
+
realall: ${OBJS}
- ${OBJCOPY} -R .eh_frame ${.OBJDIR}/zbsdmod.o
+ ${OBJCOPY} ${OBJCOPY_FLAGS} ${.OBJDIR}/zbsdmod.o
.include <bsd.klinks.mk>
.include <bsd.prog.mk>
@@ -21,13 +31,14 @@ afterinstall:
${OBJS} ${DESTDIR}/${BINDIR}
CPUFLAGS=
-COPTS= -Os
+DBG= -Os
CFLAGS+= -fno-strict-aliasing
-CFLAGS+= -DMACHINE=\"${MACHINE}\" -DUTS_RELEASE=\"2.4.20\"
-CPPFLAGS+= ${ARM_APCS_FLAGS} -mcpu=xscale
-CPPFLAGS+= -nostdinc -D_STANDALONE
+CFLAGS+= -ffreestanding -nostdinc
+CFLAGS+= ${ARM_APCS_FLAGS} -mcpu=xscale
+CPPFLAGS+= -DMACHINE=\"${MACHINE}\" -DUTS_RELEASE=\"2.4.20\"
+CPPFLAGS+= -D_STANDALONE
CPPFLAGS+= -I${.OBJDIR} -I${S}
release: check_RELEASEDIR
${HOST_INSTALL_FILE} -m ${NONBINMODE} ${OBJS} \
- ${RELEASEDIR}/${MACHINE}/installation
+ ${RELEASEDIR}/${RELEASEMACHINEDIR}/installation
Index: arch/zaurus/stand/zbsdmod/compat_linux.h
===================================================================
RCS file: /cvsroot/src/sys/arch/zaurus/stand/zbsdmod/compat_linux.h,v
retrieving revision 1.6
diff -u -p -d -r1.6 compat_linux.h
--- arch/zaurus/stand/zbsdmod/compat_linux.h 11 Dec 2011 14:05:39 -0000 1.6
+++ arch/zaurus/stand/zbsdmod/compat_linux.h 29 Oct 2019 14:49:11 -0000
@@ -64,6 +64,7 @@ extern int register_chrdev(unsigned int,
extern int unregister_chrdev(unsigned int, const char *);
extern void printk(const char *, ...) __printflike(1, 2);
extern void *memcpy(void *, const void *, size_t);
+extern void *memset(void *, int, size_t);
/* procfs support */
struct proc_dir_entry {
Index: arch/zaurus/stand/zbsdmod/zbsdmod.c
===================================================================
RCS file: /cvsroot/src/sys/arch/zaurus/stand/zbsdmod/zbsdmod.c,v
retrieving revision 1.9
diff -u -p -d -r1.9 zbsdmod.c
--- arch/zaurus/stand/zbsdmod/zbsdmod.c 2 Dec 2013 18:36:11 -0000 1.9
+++ arch/zaurus/stand/zbsdmod/zbsdmod.c 29 Oct 2019 14:49:11 -0000
@@ -262,6 +262,10 @@ elf32bsdboot(void)
(((char *)elf) + phdr[i].p_offset)[sz];
}
}
+ if (IS_BSS(phdr[i])) {
+ memset((void *)(phdr[i].p_vaddr + phdr[i].p_filesz), 0,
+ phdr[i].p_memsz - phdr[i].p_filesz);
+ }
}
addr = (int *)(elf->e_entry);
@@ -284,6 +288,13 @@ elf32bsdboot(void)
"mov r1, r1;"
"sub pc, pc, #4;"
"mov r1, #(0x00000010 | 0x00000020);"
+ /*
+ * Put the rest of instructions into the same cacheline
+ * to make sure no I$ refill after invalidation.
+ */
+ "b 2f;"
+ ".align 5;"
+ "2:"
"mcr p15, 0, r1, c1, c0, 0;" /* Write new control register */
"mcr p15, 0, r1, c8, c7, 0;" /* invalidate I+D TLB */
"mcr p15, 0, r1, c7, c5, 0;" /* invalidate I$ and BTB */
Index: dev/i2c/i2c.c
===================================================================
RCS file: /cvsroot/src/sys/dev/i2c/i2c.c,v
retrieving revision 1.69
diff -u -p -d -r1.69 i2c.c
--- dev/i2c/i2c.c 26 Mar 2019 09:20:38 -0000 1.69
+++ dev/i2c/i2c.c 29 Oct 2019 14:49:12 -0000
@@ -59,7 +59,6 @@ __KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.69
#include <dev/i2c/i2cvar.h>
-#include "ioconf.h"
#include "locators.h"
#ifndef I2C_MAX_ADDR
@@ -67,7 +66,6 @@ __KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.69
#endif
struct iic_softc {
- device_t sc_dev;
i2c_tag_t sc_tag;
int sc_type;
device_t sc_devices[I2C_MAX_ADDR + 1];
@@ -99,6 +97,8 @@ const struct cdevsw iic_cdevsw = {
.d_flag = D_OTHER
};
+extern struct cfdriver iic_cd;
+
static void iic_smbus_intr_thread(void *);
static void iic_fill_compat(struct i2c_attach_args*, const char*,
size_t, char **);
@@ -109,9 +109,8 @@ iic_print_direct(void *aux, const char *
struct i2c_attach_args *ia = aux;
if (pnp != NULL)
- aprint_normal("%s at %s addr 0x%02x",
- ia->ia_name ? ia->ia_name : "(unknown)",
- pnp, ia->ia_addr);
+ aprint_normal("%s at %s addr 0x%02x", ia->ia_name, pnp,
+ ia->ia_addr);
else
aprint_normal(" addr 0x%02x", ia->ia_addr);
@@ -123,243 +122,37 @@ iic_print(void *aux, const char *pnp)
{
struct i2c_attach_args *ia = aux;
- if (ia->ia_addr != (i2c_addr_t)IICCF_ADDR_DEFAULT)
+ if (ia->ia_addr != (i2c_addr_t)-1)
aprint_normal(" addr 0x%x", ia->ia_addr);
return UNCONF;
}
-static bool
-iic_is_special_address(i2c_addr_t addr)
-{
-
- /*
- * See: https://www.i2c-bus.org/addressing/
- */
-
- /* General Call (read) / Start Byte (write) */
- if (addr == 0x00)
- return (true);
-
- /* CBUS Addresses */
- if (addr == 0x01)
- return (true);
-
- /* Reserved for Different Bus Formats */
- if (addr == 0x02)
- return (true);
-
- /* Reserved for future purposes */
- if (addr == 0x03)
- return (true);
-
- /* High Speed Master Code */
- if ((addr & 0x7c) == 0x04)
- return (true);
-
- /* 10-bit Slave Addressing prefix */
- if ((addr & 0x7c) == 0x78)
- return (true);
-
- /* Reserved for future purposes */
- if ((addr & 0x7c) == 0x7c)
- return (true);
-
- return (false);
-}
-
-static int
-iic_probe_none(struct iic_softc *sc,
- const struct i2c_attach_args *ia, int flags)
-{
-
- return (0);
-}
-
-static int
-iic_probe_smbus_quick_write(struct iic_softc *sc,
- const struct i2c_attach_args *ia, int flags)
-{
- int error;
-
- if ((error = iic_acquire_bus(ia->ia_tag, flags)) == 0) {
- error = iic_smbus_quick_write(ia->ia_tag, ia->ia_addr, flags);
- }
- (void) iic_release_bus(ia->ia_tag, flags);
-
- return (error);
-}
-
-static int
-iic_probe_smbus_receive_byte(struct iic_softc *sc,
- const struct i2c_attach_args *ia, int flags)
-{
- int error;
-
- if ((error = iic_acquire_bus(ia->ia_tag, flags)) == 0) {
- uint8_t dummy;
-
- error = iic_smbus_receive_byte(ia->ia_tag, ia->ia_addr,
- &dummy, flags);
- }
- (void) iic_release_bus(ia->ia_tag, flags);
-
- return (error);
-}
-
-static bool
-iic_indirect_driver_is_whitelisted(struct iic_softc *sc, cfdata_t cf)
-{
- prop_object_iterator_t iter;
- prop_array_t whitelist;
- prop_string_t pstr;
- prop_type_t ptype;
- bool rv = false;
-
- whitelist = prop_dictionary_get(device_properties(sc->sc_dev),
- I2C_PROP_INDIRECT_DEVICE_WHITELIST);
- if (whitelist == NULL) {
- /* No whitelist -> everything allowed */
- return (true);
- }
-
- if ((ptype = prop_object_type(whitelist)) != PROP_TYPE_ARRAY) {
- aprint_error_dev(sc->sc_dev,
- "invalid property type (%d) for '%s'; must be array (%d)\n",
- ptype, I2C_PROP_INDIRECT_DEVICE_WHITELIST, PROP_TYPE_ARRAY);
- return (false);
- }
-
- iter = prop_array_iterator(whitelist);
- while ((pstr = prop_object_iterator_next(iter)) != NULL) {
- if (prop_string_equals_cstring(pstr, cf->cf_name)) {
- rv = true;
- break;
- }
- }
- prop_object_iterator_release(iter);
-
- return (rv);
-}
-
static int
iic_search(device_t parent, cfdata_t cf, const int *ldesc, void *aux)
{
struct iic_softc *sc = device_private(parent);
struct i2c_attach_args ia;
- int (*probe_func)(struct iic_softc *,
- const struct i2c_attach_args *, int);
- prop_string_t pstr;
- i2c_addr_t first_addr, last_addr;
-
- /*
- * Before we do any more work, consult the allowed-driver
- * white-list for this bus (if any).
- */
- if (iic_indirect_driver_is_whitelisted(sc, cf) == false)
- return (0);
-
- /* default to "quick write". */
- probe_func = iic_probe_smbus_quick_write;
-
- pstr = prop_dictionary_get(device_properties(sc->sc_dev),
- I2C_PROP_INDIRECT_PROBE_STRATEGY);
- if (pstr == NULL) {
- /* Use the default. */
- } else if (prop_string_equals_cstring(pstr,
- I2C_PROBE_STRATEGY_QUICK_WRITE)) {
- probe_func = iic_probe_smbus_quick_write;
- } else if (prop_string_equals_cstring(pstr,
- I2C_PROBE_STRATEGY_RECEIVE_BYTE)) {
- probe_func = iic_probe_smbus_receive_byte;
- } else if (prop_string_equals_cstring(pstr,
- I2C_PROBE_STRATEGY_NONE)) {
- probe_func = iic_probe_none;
- } else {
- aprint_error_dev(sc->sc_dev,
- "unknown probe strategy '%s'; defaulting to '%s'\n",
- prop_string_cstring_nocopy(pstr),
- I2C_PROBE_STRATEGY_QUICK_WRITE);
-
- /* Use the default. */
- }
ia.ia_tag = sc->sc_tag;
+ ia.ia_size = cf->cf_loc[IICCF_SIZE];
ia.ia_type = sc->sc_type;
ia.ia_name = NULL;
ia.ia_ncompat = 0;
ia.ia_compat = NULL;
- ia.ia_prop = NULL;
-
- if (cf->cf_loc[IICCF_ADDR] == IICCF_ADDR_DEFAULT) {
- /*
- * This particular config directive has
- * wildcarded the address, so we will
- * scan the entire bus for it.
- */
- first_addr = 0;
- last_addr = I2C_MAX_ADDR;
- } else {
- /*
- * This config directive hard-wires the i2c
- * bus address for the device, so there is
- * no need to go poking around at any other
- * addresses.
- */
- if (cf->cf_loc[IICCF_ADDR] < 0 ||
- cf->cf_loc[IICCF_ADDR] > I2C_MAX_ADDR) {
- /* Invalid config directive! */
- return (0);
- }
- first_addr = last_addr = cf->cf_loc[IICCF_ADDR];
- }
- for (ia.ia_addr = first_addr; ia.ia_addr <= last_addr; ia.ia_addr++) {
- int error, match_result;
-
- /*
- * Skip I2C addresses that are reserved for
- * special purposes.
- */
- if (iic_is_special_address(ia.ia_addr))
- continue;
-
- /*
- * Skip addresses where a device is already attached.
- */
+ for (ia.ia_addr = 0; ia.ia_addr <= I2C_MAX_ADDR; ia.ia_addr++) {
if (sc->sc_devices[ia.ia_addr] != NULL)
continue;
- /*
- * Call the "match" routine for the device. If that
- * returns success, then call the probe strategy
- * function.
- *
- * We do it in this order because i2c devices tend
- * to be found at a small number of possible addresses
- * (e.g. read-time clocks that are only ever found at
- * 0x68). This gives the driver a chance to skip any
- * address that are not valid for the device, saving
- * us from having to poke at the bus to see if anything
- * is there.
- */
- match_result = config_match(parent, cf, &ia);
- if (match_result <= 0)
- continue;
-
- /*
- * If the quality of the match by the driver was low
- * (i.e. matched on being a valid address only, didn't
- * perform any hardware probe), invoke our probe routine
- * to see if it looks like something is really there.
- */
- if (match_result == I2C_MATCH_ADDRESS_ONLY &&
- (error = (*probe_func)(sc, &ia, I2C_F_POLL)) != 0)
+ if (cf->cf_loc[IICCF_ADDR] != -1 &&
+ cf->cf_loc[IICCF_ADDR] != ia.ia_addr)
continue;
- sc->sc_devices[ia.ia_addr] =
- config_attach(parent, cf, &ia, iic_print);
+ if (config_match(parent, cf, &ia) > 0)
+ sc->sc_devices[ia.ia_addr] =
+ config_attach(parent, cf, &ia, iic_print);
}
return 0;
@@ -407,7 +200,6 @@ iic_attach(device_t parent, device_t sel
aprint_naive("\n");
aprint_normal(": I2C bus\n");
- sc->sc_dev = self;
sc->sc_tag = iba->iba_tag;
sc->sc_type = iba->iba_type;
ic = sc->sc_tag;
@@ -440,7 +232,7 @@ iic_attach(device_t parent, device_t sel
unsigned int i, count;
prop_dictionary_t dev;
prop_data_t cdata;
- uint32_t addr;
+ uint32_t addr, size;
uint64_t cookie;
const char *name;
struct i2c_attach_args ia;
@@ -452,15 +244,17 @@ iic_attach(device_t parent, device_t sel
dev = prop_array_get(child_devices, i);
if (!dev) continue;
if (!prop_dictionary_get_cstring_nocopy(
- dev, "name", &name)) {
- /* "name" property is optional. */
- name = NULL;
- }
+ dev, "name", &name))
+ continue;
if (!prop_dictionary_get_uint32(dev, "addr", &addr))
continue;
if (!prop_dictionary_get_uint64(dev, "cookie", &cookie))
cookie = 0;
loc[IICCF_ADDR] = addr;
+ if (prop_dictionary_get_uint32(dev, "size", &size))
+ loc[IICCF_SIZE] = size;
+ else
+ size = loc[IICCF_SIZE] = IICCF_SIZE_DEFAULT;
memset(&ia, 0, sizeof ia);
ia.ia_addr = addr;
@@ -468,7 +262,7 @@ iic_attach(device_t parent, device_t sel
ia.ia_tag = ic;
ia.ia_name = name;
ia.ia_cookie = cookie;
- ia.ia_prop = dev;
+ ia.ia_size = size;
buf = NULL;
cdata = prop_dictionary_get(dev, "compatible");
@@ -477,21 +271,14 @@ iic_attach(device_t parent, device_t sel
prop_data_data_nocopy(cdata),
prop_data_size(cdata), &buf);
- if (name == NULL && cdata == NULL) {
+ if (addr > I2C_MAX_ADDR) {
aprint_error_dev(self,
- "WARNING: ignoring bad child device entry "
- "for address 0x%02x\n", addr);
- } else {
- if (addr > I2C_MAX_ADDR) {
- aprint_error_dev(self,
- "WARNING: ignoring bad device "
- "address @ 0x%02x\n", addr);
- } else if (sc->sc_devices[addr] == NULL) {
- sc->sc_devices[addr] =
- config_found_sm_loc(self, "iic",
- loc, &ia, iic_print_direct,
- NULL);
- }
+ "WARNING: ignoring bad device address "
+ "@ 0x%02x\n", addr);
+ } else if (sc->sc_devices[addr] == NULL) {
+ sc->sc_devices[addr] =
+ config_found_sm_loc(self, "iic", loc, &ia,
+ iic_print_direct, NULL);
}
if (ia.ia_compat)
@@ -684,60 +471,18 @@ iic_fill_compat(struct i2c_attach_args *
ia->ia_ncompat = count;
}
-/*
- * iic_compatible_match --
- * Match a device's "compatible" property against the list
- * of compatible strings provided by the driver.
- */
int
-iic_compatible_match(const struct i2c_attach_args *ia,
- const struct device_compatible_entry *compats,
- const struct device_compatible_entry **matching_entryp)
-{
- int match_result;
-
- match_result = device_compatible_match(ia->ia_compat, ia->ia_ncompat,
- compats, matching_entryp);
- if (match_result) {
- match_result =
- MIN(I2C_MATCH_DIRECT_COMPATIBLE + match_result - 1,
- I2C_MATCH_DIRECT_COMPATIBLE_MAX);
- }
-
- return match_result;
-}
-
-/*
- * iic_use_direct_match --
- * Helper for direct-config of i2c. Returns true if this is
- * a direct-config situation, along with with match result.
- * Returns false if the driver should use indirect-config
- * matching logic.
- */
-bool
-iic_use_direct_match(const struct i2c_attach_args *ia, const cfdata_t cf,
- const struct device_compatible_entry *compats,
- int *match_resultp)
+iic_compat_match(struct i2c_attach_args *ia, const char ** compats)
{
- int res;
-
- KASSERT(match_resultp != NULL);
-
- if (ia->ia_name != NULL &&
- strcmp(ia->ia_name, cf->cf_name) == 0) {
- *match_resultp = I2C_MATCH_DIRECT_SPECIFIC;
- return true;
- }
+ int i;
- if (ia->ia_ncompat > 0 && ia->ia_compat != NULL) {
- res = iic_compatible_match(ia, compats, NULL);
- if (res) {
- *match_resultp = res;
- return true;
+ for (; compats && *compats; compats++) {
+ for (i = 0; i < ia->ia_ncompat; i++) {
+ if (strcmp(*compats, ia->ia_compat[i]) == 0)
+ return 1;
}
}
-
- return false;
+ return 0;
}
static int
@@ -848,9 +593,8 @@ iic_ioctl(dev_t dev, u_long cmd, void *d
}
-CFATTACH_DECL3_NEW(iic, sizeof(struct iic_softc),
- iic_match, iic_attach, iic_detach, NULL, iic_rescan, iic_child_detach,
- DVF_DETACH_SHUTDOWN);
+CFATTACH_DECL2_NEW(iic, sizeof(struct iic_softc),
+ iic_match, iic_attach, iic_detach, NULL, iic_rescan, iic_child_detach);
MODULE(MODULE_CLASS_DRIVER, iic, "i2cexec,i2c_bitbang");
Index: dev/i2c/i2c_exec.c
===================================================================
RCS file: /cvsroot/src/sys/dev/i2c/i2c_exec.c,v
retrieving revision 1.12
diff -u -p -d -r1.12 i2c_exec.c
--- dev/i2c/i2c_exec.c 25 Jul 2019 04:20:13 -0000 1.12
+++ dev/i2c/i2c_exec.c 29 Oct 2019 14:49:12 -0000
@@ -44,7 +44,6 @@ __KERNEL_RCSID(0, "$NetBSD: i2c_exec.c,v
#include <sys/module.h>
#include <sys/event.h>
#include <sys/conf.h>
-#include <sys/kernel.h>
#define _I2C_PRIVATE
#include <dev/i2c/i2cvar.h>
@@ -54,41 +53,6 @@ static uint8_t iic_smbus_pec(int, uint8_
static int i2cexec_modcmd(modcmd_t, void *);
-static inline int
-iic_op_flags(int flags)
-{
-
- return flags | (cold ? I2C_F_POLL : 0);
-}
-
-/*
- * iic_acquire_bus:
- *
- * Acquire the I2C bus for use by a client.
- */
-int
-iic_acquire_bus(i2c_tag_t tag, int flags)
-{
-
- flags = iic_op_flags(flags);
-
- return (*tag->ic_acquire_bus)(tag->ic_cookie, flags);
-}
-
-/*
- * iic_release_bus:
- *
- * Relese the I2C bus, allowing another client to use it.
- */
-void
-iic_release_bus(i2c_tag_t tag, int flags)
-{
-
- flags = iic_op_flags(flags);
-
- (*tag->ic_release_bus)(tag->ic_cookie, flags);
-}
-
/*
* iic_exec:
*
@@ -108,8 +72,6 @@ iic_exec(i2c_tag_t tag, i2c_op_t op, i2c
int error;
size_t len;
- flags = iic_op_flags(flags);
-
if ((flags & I2C_F_PEC) && cmdlen > 0 && tag->ic_exec != NULL) {
uint8_t data[33]; /* XXX */
uint8_t b[3];
Index: dev/i2c/i2c_io.h
===================================================================
RCS file: /cvsroot/src/sys/dev/i2c/i2c_io.h,v
retrieving revision 1.4
diff -u -p -d -r1.4 i2c_io.h
--- dev/i2c/i2c_io.h 28 Oct 2017 06:27:32 -0000 1.4
+++ dev/i2c/i2c_io.h 29 Oct 2019 14:49:12 -0000
@@ -38,7 +38,6 @@
#ifndef _DEV_I2C_I2C_IO_H_
#define _DEV_I2C_I2C_IO_H_
-#include <sys/types.h>
#include <sys/ioccom.h>
/* I2C bus address. */
Index: dev/i2c/i2cvar.h
===================================================================
RCS file: /cvsroot/src/sys/dev/i2c/i2cvar.h,v
retrieving revision 1.18
diff -u -p -d -r1.18 i2cvar.h
--- dev/i2c/i2cvar.h 10 Dec 2018 00:31:45 -0000 1.18
+++ dev/i2c/i2cvar.h 29 Oct 2019 14:49:12 -0000
@@ -38,7 +38,6 @@
#ifndef _DEV_I2C_I2CVAR_H_
#define _DEV_I2C_I2CVAR_H_
-#include <sys/device.h>
#include <dev/i2c/i2c_io.h>
#include <prop/proplib.h>
@@ -50,20 +49,6 @@
#define I2C_F_POLL 0x08 /* poll, don't sleep */
#define I2C_F_PEC 0x10 /* smbus packet error checking */
-/* i2c bus instance properties */
-#define I2C_PROP_INDIRECT_PROBE_STRATEGY \
- "i2c-indirect-probe-strategy"
-#define I2C_PROBE_STRATEGY_QUICK_WRITE \
- "smbus-quick-write"
-#define I2C_PROBE_STRATEGY_RECEIVE_BYTE \
- "smbus-receive-byte"
-#define I2C_PROBE_STRATEGY_NONE \
- "none"
-
-#define I2C_PROP_INDIRECT_DEVICE_WHITELIST \
- "i2c-indirect-device-whitelist"
- /* value is a prop_array of prop_strings */
-
struct ic_intr_list {
LIST_ENTRY(ic_intr_list) il_next;
int (*il_intr)(void *);
@@ -133,13 +118,13 @@ struct i2cbus_attach_args {
struct i2c_attach_args {
i2c_tag_t ia_tag; /* our controller */
i2c_addr_t ia_addr; /* address of device */
+ int ia_size; /* size (for EEPROMs) */
int ia_type; /* bus type */
/* only set if using direct config */
const char * ia_name; /* name of the device */
int ia_ncompat; /* number of pointers in the
ia_compat array */
const char ** ia_compat; /* chip names */
- prop_dictionary_t ia_prop; /* dictionnary for this device */
/*
* The following is of limited usefulness and should only be used
* in rare cases where we really know what we are doing. Example:
@@ -149,8 +134,6 @@ struct i2c_attach_args {
* may be present. Example: on OpenFirmware machines the device
* tree OF node - if available. This info is hard to transport
* down to MD drivers through the MI i2c bus otherwise.
- *
- * On ACPI platforms this is the ACPI_HANDLE of the device.
*/
uintptr_t ia_cookie; /* OF node in openfirmware machines */
};
@@ -159,33 +142,7 @@ struct i2c_attach_args {
* API presented to i2c controllers.
*/
int iicbus_print(void *, const char *);
-
-/*
- * API presented to i2c devices.
- */
-int iic_compatible_match(const struct i2c_attach_args *,
- const struct device_compatible_entry *,
- const struct device_compatible_entry **);
-bool iic_use_direct_match(const struct i2c_attach_args *, const cfdata_t,
- const struct device_compatible_entry *, int *);
-
-/*
- * Constants to indicate the quality of a match made by a driver's
- * match routine, from lowest to higest:
- *
- * -- Address only; no other checks were made.
- *
- * -- Address + device probed and recognized.
- *
- * -- Direct-config match by "compatible" string.
- *
- * -- Direct-config match by specific driver name.
- */
-#define I2C_MATCH_ADDRESS_ONLY 1
-#define I2C_MATCH_ADDRESS_AND_PROBE 2
-#define I2C_MATCH_DIRECT_COMPATIBLE 10
-#define I2C_MATCH_DIRECT_COMPATIBLE_MAX 99
-#define I2C_MATCH_DIRECT_SPECIFIC 100
+int iic_compat_match(struct i2c_attach_args*, const char **);
#ifdef _I2C_PRIVATE
/*
@@ -208,8 +165,11 @@ bool iic_use_direct_match(const struct i
* Simplified API for clients of the i2c framework. Definitions
* in <dev/i2c/i2c_io.h>.
*/
-int iic_acquire_bus(i2c_tag_t, int);
-void iic_release_bus(i2c_tag_t, int);
+#define iic_acquire_bus(ic, flags) \
+ (*(ic)->ic_acquire_bus)((ic)->ic_cookie, (flags))
+#define iic_release_bus(ic, flags) \
+ (*(ic)->ic_release_bus)((ic)->ic_cookie, (flags))
+
int iic_exec(i2c_tag_t, i2c_op_t, i2c_addr_t, const void *,
size_t, void *, size_t, int);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment