From patchwork Thu Feb 16 21:16:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rask Ingemann Lambertsen X-Patchwork-Id: 9578377 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 213A660209 for ; Thu, 16 Feb 2017 21:17:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 13DFD28628 for ; Thu, 16 Feb 2017 21:17:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0889C28669; Thu, 16 Feb 2017 21:17:33 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable 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 82FA42866E for ; Thu, 16 Feb 2017 21:17:32 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=IEH5MnGLMvHvOXvnndmT5XL2zrdhBknQbFbGbjnNWG0=; b=IoNgkgQU/ZIIVU 7KEA+1WJfXfQbs+YBwtM3g7/U/Af2KN8NqWDxB7UxDr1/HtiQQQBMRuUuhSnocO02AOKlrSs0Qr+4 /gpJ9xB48FzyhyLAzf0kof5JhRs86de1OQm8LT1Wmk1PxTtVpXGV0vKILIQAvzlhQ4PQAh36/4v5n lBepjVj+I2mjSzcfMuXXjHW65+N1+YyZIWNUV0UWuQS7CO9+tcWrYO3oUJ4/fXMs5C8lUkscpOAxi S2CPylzIt5vnst1UMOQRORhZMJdxTwnJJZ+NSK+bJyT3IxWgohuTKEJlFnp97h63RFlUxCzYynFt4 P4OoAG/KfSXckQlNm5tw==; 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 1ceTQf-0005WO-UI; Thu, 16 Feb 2017 21:17:29 +0000 Received: from customer-85-204-195-167.ip4.gigabit.dk ([85.204.195.167] helo=customer-2a00-7660-0ca7-0000-0000-0000-0000-0b1b.ip6.gigabit.dk) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1ceTQa-0005SK-SI for linux-arm-kernel@lists.infradead.org; Thu, 16 Feb 2017 21:17:27 +0000 Received: from localhost (localhost6.localdomain6 [IPv6:::1]) by customer-2a00-7660-0ca7-0000-0000-0000-0000-0b1b.ip6.gigabit.dk (Postfix) with ESMTPS id BF9E4315643; Thu, 16 Feb 2017 22:16:33 +0100 (CET) Date: Thu, 16 Feb 2017 22:16:32 +0100 From: Rask Ingemann Lambertsen To: Chen-Yu Tsai Subject: AXP808 vs. AXP806 debugged, no difference? (Was: [PATCH v6 5/5] ARM: dts: sun9i: Initial support for the Sunchip CX-A99 board) Message-ID: <20170216211630.u3xddzzcpazlodkz@localhost> References: <20170210085920.7l7gswm6yjuqgdfx@lukather> <20170214233538.enkffjiw3kkfromu@localhost> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170214233538.enkffjiw3kkfromu@localhost> User-Agent: NeoMutt/20161104 (1.7.1) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170216_131725_281823_15F10DA3 X-CRM114-Status: GOOD ( 15.65 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree , Liam Girdwood , Rob Herring , linux-kernel , Mark Brown , Maxime Ripard , Lee Jones , linux-arm-kernel Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP In summary: I'll propose a new property "extended-address" or so to the existing "x-powers,axp806" compatible, because the axp808 does seem to have the register at 0xff after all, it just needs a value of 0 instead of the 16 which drivers/mfd/axp20x.c as of recently is now writing unconditionally to 0xff. A new "x-powers,axp808" compatible and new AXP808_ID is therefore not needed. This should make for a simpler and smaller patch. On Wed, Feb 15, 2017 at 12:35:39AM +0100, Rask Ingemann Lambertsen wrote: > As to touching the register at 0xff, it would be interesting to know more > precisely what goes wrong. The symptom is these messages in the log: > > [ 3.209573] axp20x-rsb sunxi-rsb-745: AXP20x variant AXP806 found > [ 3.210153] axp20x-rsb sunxi-rsb-745: Failed to set masks in 0x40: -5 > [ 3.210178] axp20x-rsb sunxi-rsb-745: failed to add irq chip: -5 > [ 3.210306] axp20x-rsb: probe of sunxi-rsb-745 failed with error -5 > > I haven't yet looked further into what happens at the RSB bus level. With the patch below applied for debugging purposes and using the "xpowers,axp806" compatible, I get: [ 3.209955] axp20x-rsb sunxi-rsb-745: AXP20x variant AXP806 found [ 3.210065] axp20x-rsb sunxi-rsb-745: Chip ID read 1 = 0x60 [ 3.210119] axp20x-rsb sunxi-rsb-745: Reg addr ext = 0x0 [ 3.210171] axp20x-rsb sunxi-rsb-745: Bus addr ext = 0x0 [ 3.210381] axp20x-rsb sunxi-rsb-745: Chip ID read 2 = 0x60 (16 written to register 0xff here) [ 3.210570] sunxi-rsb 8003400.i2c: RSB transfer data error [ 3.210596] sunxi-rsb 8003400.i2c: RSB error reading dev 58 register 3 length 1. [ 3.210625] axp20x-rsb sunxi-rsb-745: Chip ID read 3 = 0xffffffff (0 written to register 0xff here) [ 3.210828] axp20x-rsb sunxi-rsb-745: Chip ID read 4 = 0x60 I.e. register 0xff (Reg addr ext) and 0xfe (Bus addr ext) exist with a default of 0. After writing 16 to register 0xff, the chip ID (register 3) can not be read, but writing 0 to register 0xff makes the AXP808 respond again and the board boots up as normal. Also, can someone with an AXP806 confirm that it does use the same chip ID of 0x60 as the AXP808? diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c index 125b470..db557f3 100644 --- a/drivers/mfd/axp20x.c +++ b/drivers/mfd/axp20x.c @@ -910,9 +910,40 @@ int axp20x_device_probe(struct axp20x_dev *axp20x) * address. */ if (axp20x->variant == AXP806_ID) + { + int dummy; + + dummy = -1; + regmap_read(axp20x->regmap, AXP806_CHIP_ID, &dummy); + dev_info(axp20x->dev, "Chip ID read 1 = 0x%x\n", dummy); + + regmap_read(axp20x->regmap, AXP806_REG_ADDR_EXT, &dummy); + dev_info(axp20x->dev, "Reg addr ext = 0x%x\n", dummy); + regmap_read(axp20x->regmap, AXP806_BUS_ADDR_EXT, &dummy); + dev_info(axp20x->dev, "Bus addr ext = 0x%x\n", dummy); + + regmap_reinit_cache(axp20x->regmap, axp20x->regmap_cfg); + dummy = -1; + regmap_read(axp20x->regmap, AXP806_CHIP_ID, &dummy); + dev_info(axp20x->dev, "Chip ID read 2 = 0x%x\n", dummy); + regmap_write(axp20x->regmap, AXP806_REG_ADDR_EXT, AXP806_REG_ADDR_EXT_ADDR_SLAVE_MODE); + regmap_reinit_cache(axp20x->regmap, axp20x->regmap_cfg); + dummy = -1; + regmap_read(axp20x->regmap, AXP806_CHIP_ID, &dummy); + dev_info(axp20x->dev, "Chip ID read 3 = 0x%x\n", dummy); + + regmap_write(axp20x->regmap, AXP806_REG_ADDR_EXT, + 0); + + regmap_reinit_cache(axp20x->regmap, axp20x->regmap_cfg); + dummy = -1; + regmap_read(axp20x->regmap, AXP806_CHIP_ID, &dummy); + dev_info(axp20x->dev, "Chip ID read 4 = 0x%x\n", dummy); + } + ret = regmap_add_irq_chip(axp20x->regmap, axp20x->irq, IRQF_ONESHOT | IRQF_SHARED | axp20x->irq_flags, -1, axp20x->regmap_irq_chip, &axp20x->regmap_irqc); diff --git a/drivers/bus/sunxi-rsb.c b/drivers/bus/sunxi-rsb.c index 795c9d9..85e4926 100644 --- a/drivers/bus/sunxi-rsb.c +++ b/drivers/bus/sunxi-rsb.c @@ -349,6 +349,10 @@ static int sunxi_rsb_read(struct sunxi_rsb *rsb, u8 rtaddr, u8 addr, unlock: mutex_unlock(&rsb->lock); + if (ret) + dev_dbg(rsb->dev, "RSB error reading dev %u register %u length %u.\n", + rtaddr, addr, (unsigned int) len); + return ret; } @@ -386,6 +390,10 @@ static int sunxi_rsb_write(struct sunxi_rsb *rsb, u8 rtaddr, u8 addr, mutex_unlock(&rsb->lock); + if (ret) + dev_dbg(rsb->dev, "RSB error writing dev %u register %u length %u.\n", + rtaddr, addr, (unsigned int) len); + return ret; } diff --git a/drivers/bus/Makefile b/drivers/bus/Makefile index cc6364b..4b81226 100644 --- a/drivers/bus/Makefile +++ b/drivers/bus/Makefile @@ -24,3 +24,4 @@ obj-$(CONFIG_UNIPHIER_SYSTEM_BUS) += uniphier-system-bus.o obj-$(CONFIG_VEXPRESS_CONFIG) += vexpress-config.o obj-$(CONFIG_DA8XX_MSTPRI) += da8xx-mstpri.o +CFLAGS_sunxi-rsb.o += -DDEBUG -DEBUG