From patchwork Wed Nov 20 18:23:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taras Kondratiuk X-Patchwork-Id: 292844 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 85ACB2C012B for ; Thu, 21 Nov 2013 05:24:00 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754595Ab3KTSX7 (ORCPT ); Wed, 20 Nov 2013 13:23:59 -0500 Received: from mail-ea0-f179.google.com ([209.85.215.179]:55023 "EHLO mail-ea0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754588Ab3KTSX6 (ORCPT ); Wed, 20 Nov 2013 13:23:58 -0500 Received: by mail-ea0-f179.google.com with SMTP id r15so4081143ead.24 for ; Wed, 20 Nov 2013 10:23:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=96PHsFykp54UkercNdZbEk5tICw3161cji7GNbDqcXM=; b=KXFPvgcZ23X5pjGcbLlB0fVzr7K45XmIHoI1drPYe+waPgFcrWccEaYo6WV370ONem Ob4uuTXKE5zwzk3awJoWnfAIPG12L9QqPkmSe5mqBRa7GslardOJ898WhrdSkLMT9saa DUprECszkZjAKaeVlh/rVLuhc3quSfIo1ideRG0WCi0W1W8rU6LaCYLyRiJSRtzT9Ifa YeJki4jtkXCrqWF5TNZ8Yyxtl1mY6mqYFTMRhwd6P5XTgTBDx2Hq7xYeKAgeowfIVqsG y9BJb5pnWonr/ZgkBcRkToTGdxovbNKOYrh8qq9YC6HLWZOVqdcsgntb1qu29Ze1VxpI mlVw== X-Gm-Message-State: ALoCoQnqODtPjpkJ4Yt7SAB5i7CGvwODHhoOD5mOSXIQAfFeeVTUzL7cJKPnlYCauVTyV8zWdnEV X-Received: by 10.15.26.131 with SMTP id n3mr2636479eeu.21.1384971837604; Wed, 20 Nov 2013 10:23:57 -0800 (PST) Received: from condor-x220.synapse.com ([195.238.93.36]) by mx.google.com with ESMTPSA id v45sm12584258eef.11.2013.11.20.10.23.56 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 20 Nov 2013 10:23:57 -0800 (PST) From: Taras Kondratiuk To: Wolfram Sang Cc: Santosh Shilimkar , patches@linaro.org, linaro-networking@linaro.org, linaro-kernel@lists.linaro.org, Sekhar Nori , Kevin Hilman , davinci-linux-open-source@linux.davincidsp.com, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] i2c: davinci: raw read and write endian fix Date: Wed, 20 Nov 2013 20:23:44 +0200 Message-Id: <1384971824-7707-1-git-send-email-taras.kondratiuk@linaro.org> X-Mailer: git-send-email 1.7.9.5 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org I2C IP block expect LE data, but CPU may operate in BE mode. Need to use endian neutral functions to read/write h/w registers. I.e instead of __raw_read[lw] and __raw_write[lw] functions code need to use read[lw]_relaxed and write[lw]_relaxed functions. If the first simply reads/writes register, the second will byteswap it if host operates in BE mode. Changes are trivial sed like replacement of __raw_xxx functions with xxx_relaxed variant. Signed-off-by: Taras Kondratiuk Reviewed-by: Grygorii Strashko --- Based on Linus' master tip (b4789b8). Tested on Keystone2 EVM. drivers/i2c/busses/i2c-davinci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c index 132369f..a629447 100644 --- a/drivers/i2c/busses/i2c-davinci.c +++ b/drivers/i2c/busses/i2c-davinci.c @@ -125,12 +125,12 @@ static struct davinci_i2c_platform_data davinci_i2c_platform_data_default = { static inline void davinci_i2c_write_reg(struct davinci_i2c_dev *i2c_dev, int reg, u16 val) { - __raw_writew(val, i2c_dev->base + reg); + writew_relaxed(val, i2c_dev->base + reg); } static inline u16 davinci_i2c_read_reg(struct davinci_i2c_dev *i2c_dev, int reg) { - return __raw_readw(i2c_dev->base + reg); + return readw_relaxed(i2c_dev->base + reg); } /* Generate a pulse on the i2c clock pin. */