Add a compile time switch to distinguish between 7-bit and 8-bit I2C address

usage. The comment in the code should explain the situation.

Discussed with:	 ian@
This commit is contained in:
andreast 2015-11-04 22:46:30 +00:00
parent b2d9de8ee8
commit 92a607efab

View File

@ -148,10 +148,16 @@ ofw_iicbus_attach(device_t dev)
if (dinfo == NULL) if (dinfo == NULL)
continue; continue;
/* /*
* OFW uses 7-bit I2C address format (see ePAPR), * FreeBSD drivers expect I2C addresses to be expressed as
* but system expect 8-bit. * 8-bit values. Apple OFW data contains 8-bit values, but
* Linux FDT data contains 7-bit values, so shift them up to
* 8-bit format.
*/ */
#ifdef AIM
dinfo->opd_dinfo.addr = paddr;
#else
dinfo->opd_dinfo.addr = paddr << 1; dinfo->opd_dinfo.addr = paddr << 1;
#endif
if (ofw_bus_gen_setup_devinfo(&dinfo->opd_obdinfo, child) != if (ofw_bus_gen_setup_devinfo(&dinfo->opd_obdinfo, child) !=
0) { 0) {
free(dinfo, M_DEVBUF); free(dinfo, M_DEVBUF);