From owner-svn-src-all@freebsd.org Thu Nov 5 20:26:31 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 80E7EA2793B for ; Thu, 5 Nov 2015 20:26:31 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-qg0-x236.google.com (mail-qg0-x236.google.com [IPv6:2607:f8b0:400d:c04::236]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 32D4C1234 for ; Thu, 5 Nov 2015 20:26:31 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by qgec40 with SMTP id c40so15534631qge.2 for ; Thu, 05 Nov 2015 12:26:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp_com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=LZd7pAF+PYqwegtj3xOAtFqLXNlXNX+pk3NvU+QP4oo=; b=0flbw9FYhQ/nZtgW63pFHKdNOGpcc5mO2267bJ7OKGSmZIeLEI00znyEjeLgRy4gtf y7t3NFYo0kewiZwtfngLletDCOhr9yVqCSd6nT7bzeGIVCdLUDhtJh7sRA8ek2TRZhUz rBp2XySP6lQDuqX33y+253FYPqUrcU7KqA//JNCYe7MHc2fyd5Pbg4JhwMkFurwhR7f0 TKm2rAcNiAkG6kTsf/2VHl0YPqjP7ZbO+XNxejnW0s3LvYpEJ8SSR3iXWtw5keQrQKCc YjABzItX2jY1i8xqXrrAmcpDUdL2ajhS75wnjrq4HktZbGLQjjdtrY8FPr9PA1BtFrHO cHiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=LZd7pAF+PYqwegtj3xOAtFqLXNlXNX+pk3NvU+QP4oo=; b=ixhbyEf0Fnb3pqjC1ahMblEW8Ix4j/M5wEYzR9Gdy4+zJsEvQR7m21B5+ITHdHYEno MexAHhyGbIAazVjE+IiqxqBDGcV9SL49DYeV38Jd4rX/2Yxw06BrkL+qBujU/hZn6erG 2L8O21TCnsb5jKPHSj7XwHFBI51XyRKF2XN9W25L0Snc2BxEPGh7PgpZRqPRcVhwqK6v Ho5SoehdegLWsyL7yPYigcvkFfcr0NEEasml0hzuWzX0GyEqFYjKrWwPZBN9H+HKZmw3 sR8/qfvt93yCKmDlmBuKw1gIUH6Xh+8FtXdYU6ns9HzPY7TgzC4DuRSI4fir6AUV2X/5 l7eA== X-Gm-Message-State: ALoCoQl5BSfP2IgqVKZjt4EgJAz0F1k6XezBE1X2l3gtqohlPjlxPnFazZjsfo/xWSYq0dWzUinU MIME-Version: 1.0 X-Received: by 10.140.19.13 with SMTP id 13mr9512344qgg.97.1446755190190; Thu, 05 Nov 2015 12:26:30 -0800 (PST) Sender: wlosh@bsdimp.com Received: by 10.140.104.226 with HTTP; Thu, 5 Nov 2015 12:26:30 -0800 (PST) X-Originating-IP: [2601:280:4900:3700:1c53:4baf:e617:68c6] In-Reply-To: <563BB466.8020801@freebsd.org> References: <201511042246.tA4MkUYU010551@repo.freebsd.org> <563BB466.8020801@freebsd.org> Date: Thu, 5 Nov 2015 13:26:30 -0700 X-Google-Sender-Auth: vL9ewDSDIunjE9IE0PUVKVCxvNY Message-ID: Subject: Re: svn commit: r290373 - head/sys/dev/ofw From: Warner Losh To: Nathan Whitehorn Cc: Andreas Tobler , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.20 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Nov 2015 20:26:31 -0000 I'd suggested that this be driven off a global quirk like u_int fdt_quirks; #define FDT_QUIRK_8BIT_IIC_ADDR 1 ... if (fdt_quirks & FDT_QUIRK_8BIT_IIC_ADDR) dinfo->opd_dinfo.addr = paddr; else dinfo->opd_dinfo.addr = paddr << 1; And the platform code, whatever that means, would set it when it "knows" this is the case. Warner On Thu, Nov 5, 2015 at 12:56 PM, Nathan Whitehorn wrote: > I'm not sure this is the best way to do this: we have AIM systems that use > FDT, for example. Can we make it a quirk in the host-bus driver? Or do a > run-time check to see if the root node has MacRISC in its compatible > property? > -Nathan > > On 11/04/15 14:46, Andreas Tobler wrote: > >> Author: andreast >> Date: Wed Nov 4 22:46:30 2015 >> New Revision: 290373 >> URL: https://svnweb.freebsd.org/changeset/base/290373 >> >> Log: >> 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@ >> >> Modified: >> head/sys/dev/ofw/ofw_iicbus.c >> >> Modified: head/sys/dev/ofw/ofw_iicbus.c >> >> ============================================================================== >> --- head/sys/dev/ofw/ofw_iicbus.c Wed Nov 4 19:09:42 2015 >> (r290372) >> +++ head/sys/dev/ofw/ofw_iicbus.c Wed Nov 4 22:46:30 2015 >> (r290373) >> @@ -148,10 +148,16 @@ ofw_iicbus_attach(device_t dev) >> if (dinfo == NULL) >> continue; >> /* >> - * OFW uses 7-bit I2C address format (see ePAPR), >> - * but system expect 8-bit. >> + * FreeBSD drivers expect I2C addresses to be expressed as >> + * 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; >> +#endif >> if (ofw_bus_gen_setup_devinfo(&dinfo->opd_obdinfo, child) >> != >> 0) { >> free(dinfo, M_DEVBUF); >> >> > >