From patchwork Sun Jun 9 22:00:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 17708 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f197.google.com (mail-vc0-f197.google.com [209.85.220.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1209D2390C for ; Sun, 9 Jun 2013 22:01:07 +0000 (UTC) Received: by mail-vc0-f197.google.com with SMTP id ha12sf918101vcb.8 for ; Sun, 09 Jun 2013 15:01:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-beenthere:x-forwarded-to:x-forwarded-for :delivered-to:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=5WAFqpMZ+/KZOFaHP3M3b95E5hsiVJCk4De82TJq3eI=; b=O8sEB6oyicgZ71a283Wrzt0ey77a9/0wvU3/z6HPOTxcZP+CjdB6f6BtaSQHeXBZmz Dg+LTM9V8R2KUHNgTGbIyxcpdXL0q4sbcnyvb4nAfHjr6OVs6h+/Kdc7Xsov5Wzg8XPf 1qVPaR6Rqp/gezDqRGJPg53iHVBJARGE2RBcvvmeIwawfQrpxILrdw8WKhcWISXUWpI4 9k95HpA85e3e/6sQ9E47lCJI3YVxw9RabcZnECUsorcCaeDn1rvIrar+m9YnjUwbOpdt izWw3oL/m+ZybCD2eIhboivygtyvdsy+KHMln8P7r6lVcDp7unkmshcLpE3IkasefTma 8Ulw== X-Received: by 10.236.200.229 with SMTP id z65mr4903140yhn.18.1370815266525; Sun, 09 Jun 2013 15:01:06 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.1.69 with SMTP id 5ls2438930qek.92.gmail; Sun, 09 Jun 2013 15:01:06 -0700 (PDT) X-Received: by 10.52.166.46 with SMTP id zd14mr3606790vdb.0.1370815266193; Sun, 09 Jun 2013 15:01:06 -0700 (PDT) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id to9si3813723vdc.123.2013.06.09.15.01.06 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 09 Jun 2013 15:01:06 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.180; Received: by mail-vc0-f180.google.com with SMTP id gf11so1961721vcb.11 for ; Sun, 09 Jun 2013 15:01:05 -0700 (PDT) X-Received: by 10.52.36.115 with SMTP id p19mr3535344vdj.8.1370815265898; Sun, 09 Jun 2013 15:01:05 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.221.10.206 with SMTP id pb14csp48334vcb; Sun, 9 Jun 2013 15:01:05 -0700 (PDT) X-Received: by 10.112.142.102 with SMTP id rv6mr3026987lbb.49.1370815264409; Sun, 09 Jun 2013 15:01:04 -0700 (PDT) Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com [209.85.217.180]) by mx.google.com with ESMTPS id uq6si5651908lbc.9.2013.06.09.15.01.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 09 Jun 2013 15:01:04 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.217.180 is neither permitted nor denied by best guess record for domain of linus.walleij@linaro.org) client-ip=209.85.217.180; Received: by mail-lb0-f180.google.com with SMTP id o10so3301729lbi.25 for ; Sun, 09 Jun 2013 15:01:03 -0700 (PDT) X-Received: by 10.112.61.199 with SMTP id s7mr5197428lbr.53.1370815263469; Sun, 09 Jun 2013 15:01:03 -0700 (PDT) Received: from localhost.localdomain (c83-249-209-231.bredband.comhem.se. [83.249.209.231]) by mx.google.com with ESMTPSA id h8sm3111506laf.1.2013.06.09.15.01.01 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 09 Jun 2013 15:01:02 -0700 (PDT) From: Linus Walleij To: Wolfram Sang , linux-i2c@vger.kernel.org Cc: Linus Walleij Subject: [PATCH] i2c: nomadik: support elder Nomadiks Date: Mon, 10 Jun 2013 00:00:58 +0200 Message-Id: <1370815258-1351-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 1.8.1.4 X-Gm-Message-State: ALoCoQmEZu/1yA7/EfvFY5tXWaTJOMU5Zy7mWWOYE8iYpnH3ztso2+YEkhkrDyoQ4/KKqLPbgxLF X-Original-Sender: linus.walleij@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The Nomadik I2C block was introduced with the Nomadik STn8815 SoC (the STn8810 incidentally is identical to the one named i2c-stu300.c). However as developments have only been tested on the DB8500 family, it was not properly working with the STn8815 anymore. Rectify this by adding some vendor variant data in the same manner as other PrimeCells, and switch code path depending on version. Tested on the S8815 Nomadik dongle. Signed-off-by: Linus Walleij --- drivers/i2c/busses/i2c-nomadik.c | 43 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c index 37353b3..f6d18ce 100644 --- a/drivers/i2c/busses/i2c-nomadik.c +++ b/drivers/i2c/busses/i2c-nomadik.c @@ -106,6 +106,16 @@ /* maximum threshold value */ #define MAX_I2C_FIFO_THRESHOLD 15 +/** + * struct i2c_vendor_data - per-vendor variations + * @has_mtdws: variant has the MTDWS bit + * @fifodepth: variant FIFO depth + */ +struct i2c_vendor_data { + bool has_mtdws; + u32 fifodepth; +}; + enum i2c_status { I2C_NOP, I2C_ON_GOING, @@ -138,6 +148,7 @@ struct i2c_nmk_client { /** * struct nmk_i2c_dev - private data structure of the controller. + * @vendor: vendor data for this variant. * @adev: parent amba device. * @adap: corresponding I2C adapter. * @irq: interrupt line for the controller. @@ -155,6 +166,7 @@ struct i2c_nmk_client { * @busy: Busy doing transfer. */ struct nmk_i2c_dev { + struct i2c_vendor_data *vendor; struct amba_device *adev; struct i2c_adapter adap; int irq; @@ -431,7 +443,7 @@ static int read_i2c(struct nmk_i2c_dev *dev, u16 flags) irq_mask = (I2C_IT_RXFNF | I2C_IT_RXFF | I2C_IT_MAL | I2C_IT_BERR); - if (dev->stop) + if (dev->stop || !dev->vendor->has_mtdws) irq_mask |= I2C_IT_MTD; else irq_mask |= I2C_IT_MTDWS; @@ -511,7 +523,7 @@ static int write_i2c(struct nmk_i2c_dev *dev, u16 flags) * set the MTDWS bit (Master Transaction Done Without Stop) * to start repeated start operation */ - if (dev->stop) + if (dev->stop || !dev->vendor->has_mtdws) irq_mask |= I2C_IT_MTD; else irq_mask |= I2C_IT_MTDWS; @@ -978,6 +990,8 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id) struct device_node *np = adev->dev.of_node; struct nmk_i2c_dev *dev; struct i2c_adapter *adap; + struct i2c_vendor_data *vendor = id->data; + u32 max_fifo_threshold = (vendor->fifodepth / 2) - 1; if (!pdata) { if (np) { @@ -994,12 +1008,25 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id) pdata = &u8500_i2c; } + if (pdata->tft > max_fifo_threshold) { + dev_warn(&adev->dev, "requested TX FIFO threshold %u, adjusted down to %u\n", + pdata->tft, max_fifo_threshold); + pdata->tft = max_fifo_threshold; + } + + if (pdata->rft > max_fifo_threshold) { + dev_warn(&adev->dev, "requested RX FIFO threshold %u, adjusted down to %u\n", + pdata->rft, max_fifo_threshold); + pdata->rft = max_fifo_threshold; + } + dev = kzalloc(sizeof(struct nmk_i2c_dev), GFP_KERNEL); if (!dev) { dev_err(&adev->dev, "cannot allocate memory\n"); ret = -ENOMEM; goto err_no_mem; } + dev->vendor = vendor; dev->busy = false; dev->adev = adev; amba_set_drvdata(adev, dev); @@ -1134,14 +1161,26 @@ static int nmk_i2c_remove(struct amba_device *adev) return 0; } +static struct i2c_vendor_data vendor_stn8815 = { + .has_mtdws = false, + .fifodepth = 16, /* Guessed from TFTR/RFTR = 7 */ +}; + +static struct i2c_vendor_data vendor_db8500 = { + .has_mtdws = true, + .fifodepth = 32, /* Guessed from TFTR/RFTR = 15 */ +}; + static struct amba_id nmk_i2c_ids[] = { { .id = 0x00180024, .mask = 0x00ffffff, + .data = &vendor_stn8815, }, { .id = 0x00380024, .mask = 0x00ffffff, + .data = &vendor_db8500, }, {}, };