From patchwork Sun Jan 6 08:37:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 154844 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2355902ljp; Sun, 6 Jan 2019 00:39:26 -0800 (PST) X-Google-Smtp-Source: ALg8bN6vEiPTJL8h3vKEkL1xX1vczwsQ0qDstgHFNUTb8qQE5cLYjDfvr/V/7tMDfUjXx+5+w8nu X-Received: by 2002:a63:1f4e:: with SMTP id q14mr6850853pgm.88.1546763966593; Sun, 06 Jan 2019 00:39:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546763966; cv=none; d=google.com; s=arc-20160816; b=N+2FBun/Iy3i+wkUxp0/T66ttOF0nGRmZZfmZs6f67kq7oFK8ZDr8Q5kdPbgWEvrhe m3CyoCSRShAUGFNHCKBD+uOFjDMiiyTvKsff1narWgk+IbSDNkwVxUGQMELvT30p4gzs 5QRkhAtrmsOxSIwytJdAjaUfRbq0ZC9ykut2qUq3OQPlMaFJy5EUEozNdtuztXG88jLV uG1vGXLPpR9G8D4UCTEPY9ra/R6XG5r5J/Cmw+R0/NXnJrzfFZBuz8uBa6dyrUII2Smc 8iEjmbW25foHFaG0eUNDI56bPBItEPFOcarKu70y/KLdOtS5ziLR3jEVl5IyRpEi144s /fJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=icIkFjpedhaGa/ExI8QpSNW2jLu5Jj9xIiSk58yRb9A=; b=wiTs/7XHdg2IPX0UrqMSTpLw2A8jKvBYt9+NbVwn+WJQAoFYx/ky8sk7mV0VAhpHZe jEJp8Rbj6oyv1h+zcruTZeKW6/vC0eDSihJej8582iHGTDbmUYHIQdSBg+xBki1pQKfC 1XenUgVRwgs8Oi9SbE+0jhAZYxq4Ict6324EjIy7HR7HSg68MCsVcSOUUKDftsi57FZb 4Q9rg2N/uPpHRUkh/nPbNgnCrW8RxkT65x41RtYoSvTZumuiW/6O9NhTZFBGN20260Aa 5O42NjPU3+Igyl39auXz0l8B0TIQ4zYmYPw+rALYOjz/MwD0JilcKP6bw8h8HzyozuTQ E4sw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j7si19322280plb.91.2019.01.06.00.39.26; Sun, 06 Jan 2019 00:39:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726770AbfAFIjZ (ORCPT + 10 others); Sun, 6 Jan 2019 03:39:25 -0500 Received: from mx2.suse.de ([195.135.220.15]:57178 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726431AbfAFIiE (ORCPT ); Sun, 6 Jan 2019 03:38:04 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id DD781AC38; Sun, 6 Jan 2019 08:38:02 +0000 (UTC) From: =?utf-8?q?Andreas_F=C3=A4rber?= To: linux-lpwan@lists.infradead.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Andrea?= =?utf-8?b?cyBGw6RyYmVy?= , "David S. Miller" Subject: [PATCH lora-next 01/11] net: lora: sx125x: Abort on wrong version Date: Sun, 6 Jan 2019 09:37:44 +0100 Message-Id: <20190106083754.6004-2-afaerber@suse.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190106083754.6004-1-afaerber@suse.de> References: <20190106083754.6004-1-afaerber@suse.de> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This helps detect issues such as the concentrator being in reset. Enhance error output while at it. Signed-off-by: Andreas Färber --- drivers/net/lora/sx125x.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) -- 2.16.4 diff --git a/drivers/net/lora/sx125x.c b/drivers/net/lora/sx125x.c index 90e7cdb9d1a8..0228d1f887a0 100644 --- a/drivers/net/lora/sx125x.c +++ b/drivers/net/lora/sx125x.c @@ -195,9 +195,13 @@ static int __maybe_unused sx125x_regmap_probe(struct device *dev, struct regmap if (true) { ret = regmap_read(priv->regmap, SX1255_VERSION, &val); if (ret) { - dev_err(dev, "version read failed\n"); + dev_err(dev, "version read failed (%d)\n", ret); return ret; } + if (val != 0x21) { + dev_err(dev, "unexpected version: %u\n", val); + return -EINVAL; + } dev_info(dev, "SX125x version: %02x\n", val); } From patchwork Sun Jan 6 08:37:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 154842 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2355679ljp; Sun, 6 Jan 2019 00:39:02 -0800 (PST) X-Google-Smtp-Source: ALg8bN4ex3wxHdziXVgAZSHg456450iFGH/sWPQwhsQJFNZRmQ3bwM6cOhIxsQuvp+MqgW4DkJ2K X-Received: by 2002:a17:902:d911:: with SMTP id c17mr58712836plz.151.1546763942866; Sun, 06 Jan 2019 00:39:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546763942; cv=none; d=google.com; s=arc-20160816; b=mP7jf9uAWkK7Jb+m3K/rO4rwldcbYso+nsvpivFXrNxiZaVvNEnv4VG0nfkyUUbsYc n5Te6GofxHYIGA/O8qtJi4Uk6h1HDqEg38FeX07FmdKlNpHM7kOZFEqGwgLA745OF4Sh pynIan/vPibKgvAn5v10OzdmBbKzkwl0nhi17yn/vyilxll1e60NQNQwbeLWckB/8kOt m8b1zB7ceqr7E3ThwSxoaCM1coJiNO81tg6Lq9fxqyg4IyTRSRh215r1ukUOdM84SkOD IoB7hyhh+DnwM2VMA4zhk6eTb4fP2kx/oL7AWneEZ/VWK7Ef99bJxSG1zCSPYU9Uv73Y jAwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=xp63cu+RHoM3Q/ojxfIL3l8BOV0AT/OGGybnNGuAzBk=; b=xbgUfqZ5SMmU1TK1hW6sk+NCRdTw2cnQ1EUht0QpNj9n8AL3hEEDa7CC9bbauLfI+G oJXFfiuFG/quoa4Gp9FeW0Qk00i2VDxMoZzsLwn881Vl0bHtT1lDms88oMhqkrFAMEoK lqhK0s5EZUH42ipiIfm5x1Bqr3IuyM/38Ps3YlsXbRKlclmJU3amY4todRSOGfwVXmKS UbSc6iRHr4ZPuJC7FLeAXF0jADXzChY/FQ0jjxJM9bB7QcXDVq2bvcnKu1Iy8Q1TD4m+ 2qVgIZdJRtXZkmvJOHa7IeuWLohDnmzwQRGqZ31DTK/xMe36x95izZj1Qwl4TV7cmxxy zAIg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u188si19648615pfb.232.2019.01.06.00.39.02; Sun, 06 Jan 2019 00:39:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726718AbfAFIjC (ORCPT + 10 others); Sun, 6 Jan 2019 03:39:02 -0500 Received: from mx2.suse.de ([195.135.220.15]:57212 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726419AbfAFIiE (ORCPT ); Sun, 6 Jan 2019 03:38:04 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id B7E55ACE3; Sun, 6 Jan 2019 08:38:03 +0000 (UTC) From: =?utf-8?q?Andreas_F=C3=A4rber?= To: linux-lpwan@lists.infradead.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Andrea?= =?utf-8?b?cyBGw6RyYmVy?= , Ben Whitten , "David S. Miller" Subject: [PATCH lora-next 04/11] net: lora: sx130x: Fix soft reset Date: Sun, 6 Jan 2019 09:37:47 +0100 Message-Id: <20190106083754.6004-5-afaerber@suse.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190106083754.6004-1-afaerber@suse.de> References: <20190106083754.6004-1-afaerber@suse.de> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The soft reset bit is volatile. As it lives in the frequently accessed page register, refrain from marking the register as volatile and instead bypass the cache for this one write. Mark the cache as dirty afterwards. This does not appear to clear it, so manually drop the whole cache. If we don't have a cache configured, this may return -EINVAL, so guard it appropriately to aid in testing. Cc: Ben Whitten Signed-off-by: Andreas Färber --- drivers/net/lora/sx130x.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) -- 2.16.4 diff --git a/drivers/net/lora/sx130x.c b/drivers/net/lora/sx130x.c index 7a387d9a75a0..4ba02836a35d 100644 --- a/drivers/net/lora/sx130x.c +++ b/drivers/net/lora/sx130x.c @@ -182,7 +182,19 @@ static int sx130x_field_write(struct sx130x_priv *priv, static int sx130x_soft_reset(struct sx130x_priv *priv) { - return sx130x_field_write(priv, F_SOFT_RESET, 1); + int ret; + + regcache_cache_bypass(priv->regmap, true); + ret = sx130x_field_write(priv, F_SOFT_RESET, 1); + regcache_cache_bypass(priv->regmap, false); + if (ret) + return ret; + + regcache_mark_dirty(priv->regmap); + if (sx130x_regmap_config.cache_type != REGCACHE_NONE) + return regcache_drop_region(priv->regmap, + 0, sx130x_regmap_config.max_register); + return 0; } static int sx130x_agc_ram_read(struct sx130x_priv *priv, u8 addr, unsigned int *val) From patchwork Sun Jan 6 08:37:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 154840 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2355484ljp; Sun, 6 Jan 2019 00:38:40 -0800 (PST) X-Google-Smtp-Source: ALg8bN6C0sFOm/eIATEpcsQAT74NikrgYUoyd4e8ecikpcfefMw+dzBqt1gLw//CopdR/RmJTkMN X-Received: by 2002:a62:c185:: with SMTP id i127mr46615561pfg.43.1546763920743; Sun, 06 Jan 2019 00:38:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546763920; cv=none; d=google.com; s=arc-20160816; b=TOL4z3FMJxfvWWoLO1jZDViQvmMKf3rKzNI5jcUwpT5McdZz4zp7H2SLYPVM7H6dkm kGMS6lbVVjO6DIXky1REJMYcIVIX88Gbv1JWaHL5AXGJp9jUNt85z7nb0J/Yi4PWdq08 nOQZUFcL9om/U9IuZIVMYAHaUTD8SHQZQGQRv4KmE0dP+aqJLAWBQyhw9dtZfUxEKEML HMBN2f4I4+VIf5O0W8v71zPVrCB8oG0iXcOORWueGNw05+PuNxJTrNWQrlBCEUorFRB6 UNY46vytcmN1bM6cas/a2JphcNPJHI5yuYggg12JfjrLQ/1isrSzpq3y08m0HnU9KGyq cF6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=lSJS9ry3sAD4R7Zz91keM/H4BNx9oPf38mBRksDclX8=; b=zUYQV0CXjrecY04LHc5FM01J5CVvxeYCoEss97/m+glXvn49efDhP2ERVp0+OoorYC yNaSUH6rKOfDRyytyBavkTn9oSN0nfN5wlv7T9laoFwUPnNPulrRNfTT7iTvirmzAnz3 X2hz7KOaG+NirGS66em+LIo1nS8ZUZ+onc27pWWebHbluQkxM3ASeU+lJSKabA0TnkNE rJhpxbjySkobmfjgw3oHfTR3wxaMCyKjmJ3GQCeHRVTfm0lB6l3xKKIfQw0ZQxlyvZmq ZygwxgujitKqdpQTq7//Pt5+nJJnu91P385RbMmCSHSb5uk6hsfBFInhLpMJIFlgaMbS lsEw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s8si57027655plq.345.2019.01.06.00.38.40; Sun, 06 Jan 2019 00:38:40 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726673AbfAFIij (ORCPT + 10 others); Sun, 6 Jan 2019 03:38:39 -0500 Received: from mx2.suse.de ([195.135.220.15]:57244 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726537AbfAFIiG (ORCPT ); Sun, 6 Jan 2019 03:38:06 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 31AF1AE24; Sun, 6 Jan 2019 08:38:05 +0000 (UTC) From: =?utf-8?q?Andreas_F=C3=A4rber?= To: linux-lpwan@lists.infradead.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Andrea?= =?utf-8?b?cyBGw6RyYmVy?= , Ben Whitten , "David S. Miller" Subject: [PATCH lora-next 08/11] net: lora: sx130x: Force regmap field write before reading status Date: Sun, 6 Jan 2019 09:37:51 +0100 Message-Id: <20190106083754.6004-9-afaerber@suse.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190106083754.6004-1-afaerber@suse.de> References: <20190106083754.6004-1-afaerber@suse.de> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Ensure that the F_FORCE_HOST_RADIO_CTRL field gets written before we read the AGC status register. Otherwise it returns status 01 instead of 87. Cc: Ben Whitten Signed-off-by: Andreas Färber --- drivers/net/lora/sx130x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.16.4 diff --git a/drivers/net/lora/sx130x.c b/drivers/net/lora/sx130x.c index a0759e277574..0a79548a7480 100644 --- a/drivers/net/lora/sx130x.c +++ b/drivers/net/lora/sx130x.c @@ -343,7 +343,7 @@ static int sx130x_agc_calibrate(struct sx130x_priv *priv) return ret; } - ret = sx130x_field_write(priv, F_FORCE_HOST_RADIO_CTRL, 0); + ret = sx130x_field_force_write(priv, F_FORCE_HOST_RADIO_CTRL, 0); if (ret) { dev_err(priv->dev, "force host control failed\n"); return ret;