From patchwork Sun Nov 4 14:39:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10666887 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 54722109C for ; Sun, 4 Nov 2018 14:39:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 449692969B for ; Sun, 4 Nov 2018 14:39:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 393AB29907; Sun, 4 Nov 2018 14:39:19 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE7792969B for ; Sun, 4 Nov 2018 14:39:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729912AbeKDXyc (ORCPT ); Sun, 4 Nov 2018 18:54:32 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:44851 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729914AbeKDXyb (ORCPT ); Sun, 4 Nov 2018 18:54:31 -0500 Received: by mail-wr1-f65.google.com with SMTP id j17-v6so1520518wrq.11 for ; Sun, 04 Nov 2018 06:39:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4cU7lM9t8MU50pU3ngfNZQkLgID358+Y1s/OYiUQvXA=; b=K8Vgn6icU5rmNHta/AEvE2tzYxao9+5+JaHCK9jkaixNpxJbFBSJnxVXwomyMA8cma s3lhZMl4nQfrBvbJWbPRAO4mg7PtvMmyUWTGm29GkfnaqCM1lgyFrEuExhRLw822MJvq 3RM38/i96gqCwLkPurwVjcTEFwoftkqFvwKKxSj70jRQRyagS8jHTzPcblsjrwlv1lrh vKLuymz0xZBkYUaHGwnJdsG0URImTyC04CRXFK5yBzvXnet1O7yXak+5c89Hz4yBRwqZ mXlXFMFctNz6Cn8EMDDEvj5IAZISlAYU5R6L5EQRYBMB+I7VnIO+xqt7CJIBcOfkqtRt Xudw== X-Gm-Message-State: AGRZ1gLEp/T9zsUnU/rVSeDitxcYazHA+3wzxLCgkPn2jGDEeAa6+obq 9C8d7IrPWgi2m75Hw2Q52r1ugw== X-Google-Smtp-Source: AJdET5chl2rcwniZ+F0M3u/lSp/5IfnS3sp3TFUWviPPYyckri4K0+DsGgoxUIjnR3RNAHr6oD614A== X-Received: by 2002:adf:fd49:: with SMTP id h9-v6mr16914767wrs.280.1541342356215; Sun, 04 Nov 2018 06:39:16 -0800 (PST) Received: from localhost.localdomain ([151.66.25.206]) by smtp.gmail.com with ESMTPSA id w18-v6sm4203591wrn.66.2018.11.04.06.39.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 04 Nov 2018 06:39:15 -0800 (PST) From: Lorenzo Bianconi To: jic23@kernel.org Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 2/7] iio: imu: st_lsm6dsx: reboot memory content after reset Date: Sun, 4 Nov 2018 15:39:01 +0100 Message-Id: <71f6b6a308a74c863926a9de28cf51d42d26b859.1541341926.git.lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Perform a memory content reboot after device reset Signed-off-by: Lorenzo Bianconi --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index c8b993bea757..e3ebd04d8078 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -56,6 +56,7 @@ #define ST_LSM6DSX_REG_WHOAMI_ADDR 0x0f #define ST_LSM6DSX_REG_RESET_ADDR 0x12 #define ST_LSM6DSX_REG_RESET_MASK BIT(0) +#define ST_LSM6DSX_REG_BOOT_MASK BIT(7) #define ST_LSM6DSX_REG_BDU_ADDR 0x12 #define ST_LSM6DSX_REG_BDU_MASK BIT(6) #define ST_LSM6DSX_REG_INT2_ON_INT1_ADDR 0x13 @@ -778,12 +779,21 @@ static int st_lsm6dsx_init_device(struct st_lsm6dsx_hw *hw) u8 drdy_int_reg; int err; - err = regmap_write(hw->regmap, ST_LSM6DSX_REG_RESET_ADDR, - ST_LSM6DSX_REG_RESET_MASK); + err = regmap_update_bits(hw->regmap, ST_LSM6DSX_REG_RESET_ADDR, + ST_LSM6DSX_REG_RESET_MASK, + FIELD_PREP(ST_LSM6DSX_REG_RESET_MASK, 1)); if (err < 0) return err; - msleep(200); + msleep(50); + + err = regmap_update_bits(hw->regmap, ST_LSM6DSX_REG_RESET_ADDR, + ST_LSM6DSX_REG_BOOT_MASK, + FIELD_PREP(ST_LSM6DSX_REG_BOOT_MASK, 1)); + if (err < 0) + return err; + + msleep(50); /* enable Block Data Update */ err = regmap_update_bits(hw->regmap, ST_LSM6DSX_REG_BDU_ADDR,