From owner-freebsd-hackers@freebsd.org Sun Aug 19 13:53:36 2018 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A98CC1066771; Sun, 19 Aug 2018 13:53:36 +0000 (UTC) (envelope-from rajfbsd@gmail.com) Received: from mail-wm0-x236.google.com (mail-wm0-x236.google.com [IPv6:2a00:1450:400c:c09::236]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0B5D376EEE; Sun, 19 Aug 2018 13:53:36 +0000 (UTC) (envelope-from rajfbsd@gmail.com) Received: by mail-wm0-x236.google.com with SMTP id t25-v6so11329249wmi.3; Sun, 19 Aug 2018 06:53:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Tl40/EUx5fzuQv/rqv+5h+VYXB9PemqtD9b3O0nk/pQ=; b=eDzoFkodc/6D893yCUxhK8ybPFMTtaU02TAAS1QlUjdn5iIGuFOwluHC0cfyN7DyI5 AyBap6QMMLM1Vfm4aURYnDX6QE1mrRNYs5RHHKTA9p7qGT4ydtFZj8oYiBGksOwhIeYw +LITdxOUJtFuv6qIMsKfPybcuE05/jyc/WrG0NOD4U9cn+626rkW7XuGFkzD8ws2uil1 uU0uo9MnkhLRPawZ85FbQomz+OMKTcQRrEGp0MNNnWd832ktpITkPd/kmex2Im5DQtJd qJIjDD9YTJZWIlQLeQanidA6oj0jKt11DsnyRNG21guuTk3ZJaqFpogjFVWl7Fun7bm7 GLAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Tl40/EUx5fzuQv/rqv+5h+VYXB9PemqtD9b3O0nk/pQ=; b=pbukGbnPspQwAOgcr2LHyQvI7SUYkxEeDYot6zHNekQEhUos2U/wNgR86/w2NTABBV psHXtSFaUadFNSSYW3SeSTvAgcA8ug0cZHvrSR4ucR22Yd3xxg3ggV2h15FR8+VPQ6Ud cOMxCQ5MnJP9T+hZdhOYLqFcY2nd9TPNNVcX1AID9wxMHuIjwm7Tczx2vc92HLPqk9Bv TR/yQTeTgeji5aWlZlkPDy+7dS3VfVjWlvrBt+MIq6yzLju8NT8ysrVTZv8t1D6ANhnK UQYFhdxi10WYOsSxtn+mQPKaO1iOXvebYAa8eaz/n/1trV/IfQ08svKX4CAhaomUtWw6 zgSw== X-Gm-Message-State: AOUpUlGt/LUvt5lEi6J1Q5Tt67EcKDMbzArTtDvwJZiZYnFef73U9kgV 8LgfsdfcPSiEYdcO1O7ZhPfCm4VH5oNwkhoOySncgRVq X-Google-Smtp-Source: AA+uWPzYXEqCZzoIki6qiLKXdUSbi58MP8lDO7JWyoS9164ezednUTwuGMiKexfalthuOwvvZjM7BmYGH8ggBjP//mQ= X-Received: by 2002:a1c:20cb:: with SMTP id g194-v6mr24514815wmg.102.1534686814907; Sun, 19 Aug 2018 06:53:34 -0700 (PDT) MIME-Version: 1.0 References: <1534523216.27158.17.camel@freebsd.org> In-Reply-To: <1534523216.27158.17.camel@freebsd.org> From: Rajesh Kumar Date: Sun, 19 Aug 2018 19:23:22 +0530 Message-ID: Subject: Re: Need a clarification regarding I2C bus frequency in FreeBSD To: ian@freebsd.org Cc: freebsd-drivers@freebsd.org, freebsd-hackers@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.27 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Aug 2018 13:53:36 -0000 Hi Ian, Basically, I want to set the I2C clock frequency for Designware IP in our board to 150Mhz. So, I was looking for the way in FreeBSD. So, Is this the frequency which is configured through the clock high/low registers? I see the those register are coded to 100 and 125 currently, I am not sure how that value is arrived. If it needs to be configured for 150Mhz, how to derive the appropriate values? I looked at the DW_apb_i2c databook section 3.11 to understand about it. I am still unclear. I see a comment saying "Program based on 25000 Hz clock". In my case, should they be programmed based on 150Mhz clock? On Fri, Aug 17, 2018 at 9:57 PM Ian Lepore wrote: > On Fri, 2018-08-17 at 11:48 +0530, Rajesh Kumar wrote: > > Hi, > > > > I am trying to use the I2C designware controller driver available in > > FreeBSD (ig4_iic.c) in our boards. > > > > Is there a clean way, I can set the I2C bus frequency from the controller > > driver itself, rather than using device hints, FDT, tunables etc., > > Something like, if the driver is loaded for our boards (identified using > > the PCI or ACPI ID's), then the frequency of the I2C bus needs to be > > hardcoded from driver itself. This is to avoid additional configs from > the > > config file. > > > > I tried adding a new interface "iicbus_set_frequency" (in line with > > iicbus_get_frequency) and tried calling that from the ig4 driver after > the > > "iicbus" child is added. But, iicbus instance is created only after ig4 > > driver is loaded. So, calling iicbus_set_frequency after child addition > > leads to system panic (as there is no iicbus softc at this point). > > > > Let me know if you need any details. > > > > Thanks, > > Rajesh. > > I don't really understand what you're asking for. The ig4_iic > controller driver doesn't appear to support bus frequency settings at > all, it just loads hard-coded values into the clock high/low registers > and never changes them. If you want to locally modify the driver to run > at a different hard-coded speed for your application, just change lines > 589-592 in ig4_iic.c and continue to ignore the speed set by the bus > driver when handling iicbus_reset. > > -- Ian >