From patchwork Fri Jul 21 11:14:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenjh chenjh X-Patchwork-Id: 9856663 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 09C0660388 for ; Fri, 21 Jul 2017 11:23:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E2EC528799 for ; Fri, 21 Jul 2017 11:23:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D7449287B4; Fri, 21 Jul 2017 11:23:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM autolearn=no version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9AB4428799 for ; Fri, 21 Jul 2017 11:23:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=4UDDgrlzeYUI6NFEsoMYCyV5uZJ/xhU0vfYV9KNFAt0=; b=GBnIX33Qqzs72Yq5hFw07BnoU/ ZzAEVOseZEDuxXKYieQZwzuiLro+GVq/BYed0/wiAxyGNhXTUhoBD1sSnOMrM32X6Sr8xw1SedEtD 711n7vZiECth/XbGk0tqNjsC8nMnExkFX5Dth6dUHiLwUlMLF68vHbVRQxysLwpcUH5F/G8bYJoQR vjbt+RrSHKnjtMA4KDwVC/8ExwUBpWFDwaeRetLAU46uxOBJ6UkusXXxl4czbEf8LFhQC6q7YzgP7 xdxvmKMqTq1kEDsz0SC61XC11BFJoRuP9r0DR7yBZNv3vNRl+N6JWK5OvVgshEFRQPanE/y6uaIov 2FCUYMQw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dYW1u-00029O-2w; Fri, 21 Jul 2017 11:23:34 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dYW1p-000162-NV for linux-rockchip@bombadil.infradead.org; Fri, 21 Jul 2017 11:23:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=4F4bABVXW9+vzxQgnNYi+NkTQEm8vTt8nuy4BayESVo=; b=bYjGeqmZgG6XKmEBmy1dkVLgc dwUwaB6xcS46abQcXCtBWdpIvvM0UJzbZMzQlJYj2VQNbMJ7RRB7Seg1NGItKJgOYoaSzVDyVrPS1 ie757dNcJSCiADz6o4dx6wdk1qcF1onQNBqYYSC7Jd8eC/SUDz9++VDl/mRuhqnw6+jMh7OJYeO15 4KtCTef+4iNMxWPQCZGWfoL9kGb17d2nAwkIPNUErmhTqtjHLFAUBcKjN6GyBRff8YzmRkKyMILpn fHe3qXC66OKZzQ8M+sVtHKukaJ/bu0uBnZ2Ln5WZ2CUtdX1J5YMQpE816WlduzW8MW3e7GPw8nS3R R0y4EBKZw==; Received: from regular1.263xmail.com ([211.150.99.136]) by casper.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dYVv0-0001Fz-5p for linux-rockchip@lists.infradead.org; Fri, 21 Jul 2017 11:16:30 +0000 Received: from chenjh?rock-chips.com (unknown [192.168.167.177]) by regular1.263xmail.com (Postfix) with ESMTP id 4927757; Fri, 21 Jul 2017 19:15:47 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id 0FAE9364; Fri, 21 Jul 2017 19:15:45 +0800 (CST) X-RL-SENDER: chenjh@rock-chips.com X-FST-TO: gnurou@gmail.com X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: chenjh@rock-chips.com X-UNIQUE-TAG: <16321788b24ead5420d211778e7362a6> X-ATTACHMENT-NUM: 0 X-SENDER: chenjh@rock-chips.com X-DNS-TYPE: 0 Received: from unknown (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith SMTP id 949O2LHIU; Fri, 21 Jul 2017 19:15:47 +0800 (CST) From: Joseph Chen To: gnurou@gmail.com, linus.walleij@linaro.org, dmitry.torokhov@gmail.com Subject: [PATCH v7 01/12] mfd: rk808: fix up the chip id get failed Date: Fri, 21 Jul 2017 19:14:30 +0800 Message-Id: <1500635681-12477-2-git-send-email-chenjh@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1500635681-12477-1-git-send-email-chenjh@rock-chips.com> References: <1500635681-12477-1-git-send-email-chenjh@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170721_121627_828657_91B580B7 X-CRM114-Status: GOOD ( 12.69 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: huangtao@rock-chips.com, devicetree@vger.kernel.org, linux-gpio@vger.kernel.org, broonie@kernel.org, zhangqing@rock-chips.com, linux-kernel@vger.kernel.org, robh+dt@kernel.org, lgirdwood@gmail.com, linux-rockchip@lists.infradead.org, wdc@rock-chips.com, tony.xie@rock-chips.com, linux-input@vger.kernel.org, mark.rutland@arm.com, w.egorov@phytec.de MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Elaine Zhang the rk8xx chip id is: ((MSB << 8) | LSB) & 0xfff0 Signed-off-by: Elaine Zhang --- drivers/mfd/rk808.c | 21 +++++++++++++++------ include/linux/mfd/rk808.h | 1 + 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c index fd087cb..3334a2a 100644 --- a/drivers/mfd/rk808.c +++ b/drivers/mfd/rk808.c @@ -325,7 +325,7 @@ static int rk808_probe(struct i2c_client *client, void (*pm_pwroff_fn)(void); int nr_pre_init_regs; int nr_cells; - int pm_off = 0; + int pm_off = 0, msb, lsb; int ret; int i; @@ -333,14 +333,23 @@ static int rk808_probe(struct i2c_client *client, if (!rk808) return -ENOMEM; - rk808->variant = i2c_smbus_read_word_data(client, RK808_ID_MSB); - if (rk808->variant < 0) { - dev_err(&client->dev, "Failed to read the chip id at 0x%02x\n", + /* read Chip variant */ + msb = i2c_smbus_read_byte_data(client, RK808_ID_MSB); + if (msb < 0) { + dev_err(&client->dev, "failed to read the chip id at 0x%x\n", RK808_ID_MSB); - return rk808->variant; + return msb; } - dev_dbg(&client->dev, "Chip id: 0x%x\n", (unsigned int)rk808->variant); + lsb = i2c_smbus_read_byte_data(client, RK808_ID_LSB); + if (lsb < 0) { + dev_err(&client->dev, "failed to read the chip id at 0x%x\n", + RK808_ID_LSB); + return lsb; + } + + rk808->variant = ((msb << 8) | lsb) & RK8XX_ID_MSK; + dev_info(&client->dev, "Chip id: 0x%x\n", (unsigned int)rk808->variant); switch (rk808->variant) { case RK808_ID: diff --git a/include/linux/mfd/rk808.h b/include/linux/mfd/rk808.h index 83701ef..54feb14 100644 --- a/include/linux/mfd/rk808.h +++ b/include/linux/mfd/rk808.h @@ -298,6 +298,7 @@ enum rk818_reg { #define VOUT_LO_INT BIT(0) #define CLK32KOUT2_EN BIT(0) +#define RK8XX_ID_MSK 0xfff0 enum { BUCK_ILMIN_50MA, BUCK_ILMIN_100MA,