From patchwork Mon Mar 25 15:33:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lothar Rubusch X-Patchwork-Id: 13602422 Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 54D9954912; Mon, 25 Mar 2024 15:34:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711380891; cv=none; b=sp4x/DKQkQlX7lrK7+B4+Fxm8CuZqbzSGkLxoPv3d+u/d71F9TMCWJEVhFvRdUQVb0X5QCezKHBBK7kV0vr70nlu7KmpcXmfJtNoF8yYfaGplVtsO+jIjvO/tQgBrVnStcoQq9FDXPyAaR4kQj2czDh6hxjv+nmoPUss074eK3U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711380891; c=relaxed/simple; bh=iKFinwSCIrAzuhZju333qXfiLrNqU3nEpbENeB8YuEY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GGfRCoZYzU6D+Av2HxqhXzdVj7/+lsQ7edkmpyJ7VgusTQgD/AXur2HqdpS3twyf+jnmH0RAajN4X55z76+pNt2WI/TCrw2cDgdpexAXPXv+P/0pnrczgvUl40WyYwdJdOY7XGXcu1SfPqyoWWFushkCr6dVIvJ2ZUUR0esKqUk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=MmlFaR5O; arc=none smtp.client-ip=209.85.208.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MmlFaR5O" Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-56bf6591865so3152694a12.0; Mon, 25 Mar 2024 08:34:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711380887; x=1711985687; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yLkugZ41ZOy6ra5p6BTFzeyEFCqQHWApOAwI5fgcVQY=; b=MmlFaR5O4lLD9dsrVxr/khxhWhA/dGRSDfTiss5Y0KEu10Q82NQwMIPV7ag7eyHKRR T0StBn6dOLLNAoik8WXNMhyr1mIH0k9dq2BwssbK0acEPEornaIzHGjV3HLmyT311SNM AZsqE+VqtDrDfQWY1Svukpksj0xSxg8yfDK3PzkTVCZuTqrVKm1CEOVM+reGeaTXqM4A 2kNHVPY1sImSioGu/488cC+dFLLmMxve6HeD9cwf8NENIPs0f5LFtiG3B7gdR/2cjZWk U9yXpo3+pIX+KZlP+b5CKXTRn/fcNshOMc6YiuplETTFemSCAf21rYsDkCzKqGjzBKB9 d/cQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711380887; x=1711985687; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yLkugZ41ZOy6ra5p6BTFzeyEFCqQHWApOAwI5fgcVQY=; b=LhLJ6/0T7qI2Qi/oWderQ/pwIN6VnxVxrGNThquQwkNT4t7sTumMNUg4vXfsD3dSYs C8RAo9JQWz1mXP7MaTAAgVrTXjyaBAIGNvifa7YQJxyIPYyMw8uYDMT9+yRPt+ZIUiC8 0qEUXQQ9a0QXFHZ1QCQchbbqKwBbo0aZho/KAa9UG9RYlgf9+Gx0nZ6+hfuHZfGvqmUk JBQ47yPxISLpgCWoWVm7VnsjN36qhjJ0OMQS5zveiIdKYLdGmEPmtrHL179Ks7FbhMhY RJX1iMuDBg+FUlES3hDW/iqyvbJfme9TKATFQ6T6SdlR04qjjsH3WHrn4QZ2VAGIYkpm 0oVA== X-Forwarded-Encrypted: i=1; AJvYcCVq8o2Ww3T8wWupO/ZfVibYq7SHHvHt4WXvKUUeVG5c+maP8GycHBhw2OchSCgLtE4hPrX57hp4LMtxS+v6OAYaT9CAaWwf1LHaF6idW+7AfhgqjkVc8rWN9c3EMeVExKcMODpdNuLWGQ== X-Gm-Message-State: AOJu0Yyg4MGYGMnhS8Z0WwpFInO35JoKs+oqDiMjQee0GniCmJx4CLJd 1qZHCeKZT1W+F+G7KJPuTLXKM2vywbiQXLwRxfR8iBaMBhsgeaLn X-Google-Smtp-Source: AGHT+IF/kaIka1A/VUobqqXApZ1ckaZ2VnXLE4sPlKs6LoJkfUMQSktjyXYdmruCGt6kNwOi0jHiWw== X-Received: by 2002:a17:906:304b:b0:a46:64e3:e284 with SMTP id d11-20020a170906304b00b00a4664e3e284mr4416202ejd.74.1711380887353; Mon, 25 Mar 2024 08:34:47 -0700 (PDT) Received: from 764c7355c69b.v.cablecom.net (84-72-156-211.dclient.hispeed.ch. [84.72.156.211]) by smtp.gmail.com with ESMTPSA id u13-20020a17090626cd00b00a45200fe2b5sm3142382ejc.224.2024.03.25.08.34.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 08:34:47 -0700 (PDT) From: Lothar Rubusch To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, eraretuya@gmail.com, l.rubusch@gmail.com Subject: [PATCH v4 1/7] iio: accel: adxl345: Make data_range obsolete Date: Mon, 25 Mar 2024 15:33:50 +0000 Message-Id: <20240325153356.46112-2-l.rubusch@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240325153356.46112-1-l.rubusch@gmail.com> References: <20240325153356.46112-1-l.rubusch@gmail.com> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Replace write() data_format by regmap_update_bits(), because bus specific pre-configuration may have happened before on the same register. Changes then need to be masked. Remove the data_range field from the struct adxl345_data, because it is not used anymore. Signed-off-by: Lothar Rubusch --- drivers/iio/accel/adxl345_core.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl345_core.c index 8bd30a23e..be6758015 100644 --- a/drivers/iio/accel/adxl345_core.c +++ b/drivers/iio/accel/adxl345_core.c @@ -42,13 +42,13 @@ #define ADXL345_DATA_FORMAT_4G 1 #define ADXL345_DATA_FORMAT_8G 2 #define ADXL345_DATA_FORMAT_16G 3 +#define ADXL345_DATA_FORMAT_MSK ~((u8) BIT(6)) /* ignore spi-3wire */ #define ADXL345_DEVID 0xE5 struct adxl345_data { const struct adxl345_chip_info *info; struct regmap *regmap; - u8 data_range; }; #define ADXL345_CHANNEL(index, axis) { \ @@ -219,14 +219,13 @@ int adxl345_core_probe(struct device *dev, struct regmap *regmap) data = iio_priv(indio_dev); data->regmap = regmap; /* Enable full-resolution mode */ - data->data_range = ADXL345_DATA_FORMAT_FULL_RES; data->info = device_get_match_data(dev); if (!data->info) return -ENODEV; - ret = regmap_write(data->regmap, ADXL345_REG_DATA_FORMAT, - data->data_range); - if (ret < 0) + ret = regmap_update_bits(regmap, ADXL345_REG_DATA_FORMAT, + ADXL345_DATA_FORMAT_MSK, ADXL345_DATA_FORMAT_FULL_RES); + if (ret) return dev_err_probe(dev, ret, "Failed to set data range\n"); indio_dev->name = data->info->name; From patchwork Mon Mar 25 15:33:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lothar Rubusch X-Patchwork-Id: 13602423 Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5CFC280C0D; Mon, 25 Mar 2024 15:34:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711380892; cv=none; b=JJqsin+f1Q4pWobxt65/eg8GltXBJP8UKQiXM5yc8EjPijOzdeECBVyb6jFIBnDS9X4JGka/8DvBL9iF0M5Loh+sIuFBTpKJnWKh7eDKm8eXhWYR8tM2hROSHXyO9ajYcEt5N144fxvYDro2WVZzUB88dwtV/E49yAxBsPDPu2U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711380892; c=relaxed/simple; bh=MJxDtiNn0WiBHEqI4ZWGVPbhPTs1Sp2fyf0QcQ2WkZs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=X7HC+nOckICQV1o5rfyt/6uD61OUL7PTsvVHRY90aarqXf0EAzKbw9+y6aadv+PYCKAMVPhrFyuglcEusa5Jp2X3TzZMd5WuGCx0Koacjy1s+dUVzwmH3szbsMmDUxtQu/xnrFrz1Che2C2hGoZi3QaJCCWjJX+zKsCz1lXiQNM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=BnLm4ZfF; arc=none smtp.client-ip=209.85.167.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BnLm4ZfF" Received: by mail-lf1-f45.google.com with SMTP id 2adb3069b0e04-513d599dbabso5857062e87.1; Mon, 25 Mar 2024 08:34:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711380888; x=1711985688; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Q62qeE9LUbJvesqIjmh+/4XQ6lfIbcixIfyRLYsEjls=; b=BnLm4ZfFBSwup2deIHXm4nxXGTQ3dEEIRg1jhrpHnQrNpeudCQRb5pBnF7yWGr2Qak haQW27oGGBzD40S4yjG6DNOwPVWnakxlYQyqOdxFzTPGwmY2lvSnddjJBvyWBboXzQRp 38YFGFXZ/4Xup1/dzaqoFTRzchy1rzfcn3BXj/pgU3SuEYZsT1Ltx7PibH57mHN1j/PV le7AI0e0YUX0GD5L1ApDjIjt/oRwQCX5flouS725xpr31ou5KgeCo484GknBkvMRhm7D 4vW/F4ntlUBkH9QYjVFfK+CXvafUQ3ZkJwJ/V9UAjuksvC+sQtDmkvkfIK03f/WpvRyK B3gQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711380888; x=1711985688; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Q62qeE9LUbJvesqIjmh+/4XQ6lfIbcixIfyRLYsEjls=; b=V7mAW/1QKK90yrELS3JjiT1PwyC/zT0O2f/RBUR4m4G9wh2X29UfWRzvKjNndFb9bO Kq7pz6CT6VEBAQnFrbYOp07NLmhoJMVN0Q8q/ll4sJFEq7QZdY/fnttCtwydUrwYWi+x TPbHZUHNqYkGNGYxTCVg7AkowImDs8C7dLhmIX51RTC4r6NSJ9z387uulS+FK34piJlv xJgCkyv9z2OMr9hx1ePt1h6YTzOtVSfZ7r6JOmMPy0a+nUQWdyPlh35xBRkNUTSak8Tl khNLqfJw0fkNU7V2bISFYEytSl2V8V9zqXolVZkK/OMD116z6sF+EEukKLFzlgvle22a OWgQ== X-Forwarded-Encrypted: i=1; AJvYcCX9VY0eLCt+sDLqd0me0FpQEFD6Ge/OacFl1TAM2vi+5k9w7OPAIU0p8O7LidpRSdwfm7nG9iAhN3CaA2BLmGWOJDgnInXqLKzl3hdYy1afrQ/xMMqoxBzQx0jjzytPgPconzoUGKtjLg== X-Gm-Message-State: AOJu0Yy7wDqEd0yThLkfWMTFREB2/f2TBPFY8qrP5d2zKjh6O/vX6+zb zTMcdOltMI6JO0q1NGBr4OXWWc+du14av0Vo/PQpb6zIA0Vt4My/ X-Google-Smtp-Source: AGHT+IHN+BG2YwuZj/MlFEd8j2tNOM2Ms/3d6dyNmISJAqVbq2i7+PiP79e2J1RO3Pbue+Wf0fvWSg== X-Received: by 2002:a19:430c:0:b0:515:9ee7:ce45 with SMTP id q12-20020a19430c000000b005159ee7ce45mr4845126lfa.49.1711380888346; Mon, 25 Mar 2024 08:34:48 -0700 (PDT) Received: from 764c7355c69b.v.cablecom.net (84-72-156-211.dclient.hispeed.ch. [84.72.156.211]) by smtp.gmail.com with ESMTPSA id u13-20020a17090626cd00b00a45200fe2b5sm3142382ejc.224.2024.03.25.08.34.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 08:34:48 -0700 (PDT) From: Lothar Rubusch To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, eraretuya@gmail.com, l.rubusch@gmail.com Subject: [PATCH v4 2/7] iio: accel: adxl345: Group bus configuration Date: Mon, 25 Mar 2024 15:33:51 +0000 Message-Id: <20240325153356.46112-3-l.rubusch@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240325153356.46112-1-l.rubusch@gmail.com> References: <20240325153356.46112-1-l.rubusch@gmail.com> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In the probe function group bus configuration and the indio_dev initialization to improve readability. Signed-off-by: Lothar Rubusch --- drivers/iio/accel/adxl345_core.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl345_core.c index be6758015..469015e9c 100644 --- a/drivers/iio/accel/adxl345_core.c +++ b/drivers/iio/accel/adxl345_core.c @@ -218,22 +218,23 @@ int adxl345_core_probe(struct device *dev, struct regmap *regmap) data = iio_priv(indio_dev); data->regmap = regmap; - /* Enable full-resolution mode */ + data->info = device_get_match_data(dev); if (!data->info) return -ENODEV; - ret = regmap_update_bits(regmap, ADXL345_REG_DATA_FORMAT, - ADXL345_DATA_FORMAT_MSK, ADXL345_DATA_FORMAT_FULL_RES); - if (ret) - return dev_err_probe(dev, ret, "Failed to set data range\n"); - indio_dev->name = data->info->name; indio_dev->info = &adxl345_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = adxl345_channels; indio_dev->num_channels = ARRAY_SIZE(adxl345_channels); + /* Enable full-resolution mode */ + ret = regmap_update_bits(regmap, ADXL345_REG_DATA_FORMAT, + ADXL345_DATA_FORMAT_MSK, ADXL345_DATA_FORMAT_FULL_RES); + if (ret) + return dev_err_probe(dev, ret, "Failed to set data range\n"); + /* Enable measurement mode */ ret = adxl345_powerup(data->regmap); if (ret < 0) From patchwork Mon Mar 25 15:33:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lothar Rubusch X-Patchwork-Id: 13602424 Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 43904811F1; Mon, 25 Mar 2024 15:34:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711380893; cv=none; b=n4zCYfKDq15U9+Q3lpYd+ftn3muefrlsj1ntvzzwJpw0qq6fUUSVZlaQDR0/4WhMzo3FFzQDcd3btEre77WpufwCbWIv/cMBefn7AbXORv2k310y7nLupsVkIdkr9ZNbn7bIbDwXo8s85558kd+U8xnbqFUYQ1GE0zcfinFHs2c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711380893; c=relaxed/simple; bh=+V8DFNWF4YEqwBXLncKDoMI1ttfk7hCpvo+Y4VoMUTM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YBgxbs3RGCNccfpAJLMp2DXodAjEQ++XeoJh1yx5O/GZpQ8E0lYpuby3sozyReXALAju05ky2z7zBfj/O/t1AXgLNBPqH4UdKARx19qSvQToLQy+CjN5xkDgYO0cabgTYoPagkE/81ypzcRzMWOljdxqmLjrZCpLK3dgktymN4M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=VcOJ9JWS; arc=none smtp.client-ip=209.85.218.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VcOJ9JWS" Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-a47385a4379so462572766b.0; Mon, 25 Mar 2024 08:34:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711380889; x=1711985689; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PRyL2dhzaW6eUI5gOVnZcHnarOYXwzosHg6YqH3UA9A=; b=VcOJ9JWSkCj3qt2q6g4PUc12NA3+8AytBhnf0w730yY0Azo8VvXAdKDSdw6EqfDnf5 eba4isRxopwtRW/waS7Mn9nk58BeBdl3c840ORMUnj8swts2Wx7ciTtlfyyniFtZopS2 gSpK/K1WBBOKO/PYZ8rNC8NDc90RznWiA+4URurmtunpEKCyE39H4cLEV+2uyLctPfRH uRgatNG4UKHpb7eXES846jn8dR0FIyCqvqQ+k3L8mfflhTNJkXH4pTWFBC5v1OW9iDBU pkf8IoSKChXZL64njcrpKLgYDpHEc0TsMNadpuaPMyJ75UvsEE7DOjyh0MJUnr8r/XK1 lF6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711380889; x=1711985689; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PRyL2dhzaW6eUI5gOVnZcHnarOYXwzosHg6YqH3UA9A=; b=OEiY0mmPVrugYPQ6OROBlabPTPZJoAxyHlLp7Diba6hUFIb1gm+1hgnENCZCk5gDhu ajoCMq9pXt54VRCxPWawmNEMR96sj5We3vg+SVOHfzANMuO6bhs9fsMoh01UGML5I2Rr OgEJMpmZ0enC7zDnltrnOCFd/cwPP7IQtqPy6e3R69GqY7LJb8vy9g2EkVRKg/9p3jAu 5zUEnOCWh6i2eHOAyo+q5AZBLwMRvKcLbDrhD6TT7dW2oJDnf1j1TKWPT4hflevH9tnI Ywv0XmHc5N9GPEWJl+vtnOQlYrOMhfusuw7WPm5xCzvO+PFX8Fj9D5frOqOqQK37ZXcE cEGA== X-Forwarded-Encrypted: i=1; AJvYcCVJS4cwt6uUmxzKJGvEmAgaqBKphjnjH+7FARnUixDSF1BH4Sb6sza0taKt4QbU7DxfHxFedZcdIj5GVRtnrG7vNSX+mF7/Oi7bBf0n9o7MDWULScgd9tQ6ZFWvbKrYWMwpUI3GYa6SKw== X-Gm-Message-State: AOJu0YxjSUgfjflk2L35Rcc+suOTyV4gN0/Bz+hdNLkkNaP+xEbL9De0 uoUlxDhy5IbfsNVxVWxPnZnZRI8Fro1oGHrx+SpfuMRu9n1epkdK X-Google-Smtp-Source: AGHT+IHbB5Uf3wQSMPhJiU5VVMgCO6h+Nj70Sj13mfvMZnOyPk8UqpCvkW9cUJQ7J2NOJpATfVxw9A== X-Received: by 2002:a17:906:744:b0:a45:f9c5:3024 with SMTP id z4-20020a170906074400b00a45f9c53024mr5255862ejb.11.1711380889407; Mon, 25 Mar 2024 08:34:49 -0700 (PDT) Received: from 764c7355c69b.v.cablecom.net (84-72-156-211.dclient.hispeed.ch. [84.72.156.211]) by smtp.gmail.com with ESMTPSA id u13-20020a17090626cd00b00a45200fe2b5sm3142382ejc.224.2024.03.25.08.34.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 08:34:49 -0700 (PDT) From: Lothar Rubusch To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, eraretuya@gmail.com, l.rubusch@gmail.com Subject: [PATCH v4 3/7] iio: accel: adxl345: Move defines to header Date: Mon, 25 Mar 2024 15:33:52 +0000 Message-Id: <20240325153356.46112-4-l.rubusch@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240325153356.46112-1-l.rubusch@gmail.com> References: <20240325153356.46112-1-l.rubusch@gmail.com> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Move defines to the header file. This keeps the defines block together in one location, when extended by new shared defines which then have to be in the header file. Signed-off-by: Lothar Rubusch --- drivers/iio/accel/adxl345.h | 31 +++++++++++++++++++++++++++++++ drivers/iio/accel/adxl345_core.c | 29 ----------------------------- 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/drivers/iio/accel/adxl345.h b/drivers/iio/accel/adxl345.h index 284bd387c..ee169fed4 100644 --- a/drivers/iio/accel/adxl345.h +++ b/drivers/iio/accel/adxl345.h @@ -8,6 +8,37 @@ #ifndef _ADXL345_H_ #define _ADXL345_H_ +#include + +#define ADXL345_REG_DEVID 0x00 +#define ADXL345_REG_OFSX 0x1E +#define ADXL345_REG_OFSY 0x1F +#define ADXL345_REG_OFSZ 0x20 +#define ADXL345_REG_OFS_AXIS(index) (ADXL345_REG_OFSX + (index)) +#define ADXL345_REG_BW_RATE 0x2C +#define ADXL345_REG_POWER_CTL 0x2D +#define ADXL345_REG_DATA_FORMAT 0x31 +#define ADXL345_REG_DATAX0 0x32 +#define ADXL345_REG_DATAY0 0x34 +#define ADXL345_REG_DATAZ0 0x36 +#define ADXL345_REG_DATA_AXIS(index) \ + (ADXL345_REG_DATAX0 + (index) * sizeof(__le16)) + +#define ADXL345_BW_RATE GENMASK(3, 0) +#define ADXL345_BASE_RATE_NANO_HZ 97656250LL + +#define ADXL345_POWER_CTL_MEASURE BIT(3) +#define ADXL345_POWER_CTL_STANDBY 0x00 + +#define ADXL345_DATA_FORMAT_FULL_RES BIT(3) /* Up to 13-bits resolution */ +#define ADXL345_DATA_FORMAT_2G 0 +#define ADXL345_DATA_FORMAT_4G 1 +#define ADXL345_DATA_FORMAT_8G 2 +#define ADXL345_DATA_FORMAT_16G 3 +#define ADXL345_DATA_FORMAT_MSK ~((u8) BIT(6)) /* ignore spi-3wire */ + +#define ADXL345_DEVID 0xE5 + /* * In full-resolution mode, scale factor is maintained at ~4 mg/LSB * in all g ranges. diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl345_core.c index 469015e9c..eba9c048a 100644 --- a/drivers/iio/accel/adxl345_core.c +++ b/drivers/iio/accel/adxl345_core.c @@ -17,35 +17,6 @@ #include "adxl345.h" -#define ADXL345_REG_DEVID 0x00 -#define ADXL345_REG_OFSX 0x1e -#define ADXL345_REG_OFSY 0x1f -#define ADXL345_REG_OFSZ 0x20 -#define ADXL345_REG_OFS_AXIS(index) (ADXL345_REG_OFSX + (index)) -#define ADXL345_REG_BW_RATE 0x2C -#define ADXL345_REG_POWER_CTL 0x2D -#define ADXL345_REG_DATA_FORMAT 0x31 -#define ADXL345_REG_DATAX0 0x32 -#define ADXL345_REG_DATAY0 0x34 -#define ADXL345_REG_DATAZ0 0x36 -#define ADXL345_REG_DATA_AXIS(index) \ - (ADXL345_REG_DATAX0 + (index) * sizeof(__le16)) - -#define ADXL345_BW_RATE GENMASK(3, 0) -#define ADXL345_BASE_RATE_NANO_HZ 97656250LL - -#define ADXL345_POWER_CTL_MEASURE BIT(3) -#define ADXL345_POWER_CTL_STANDBY 0x00 - -#define ADXL345_DATA_FORMAT_FULL_RES BIT(3) /* Up to 13-bits resolution */ -#define ADXL345_DATA_FORMAT_2G 0 -#define ADXL345_DATA_FORMAT_4G 1 -#define ADXL345_DATA_FORMAT_8G 2 -#define ADXL345_DATA_FORMAT_16G 3 -#define ADXL345_DATA_FORMAT_MSK ~((u8) BIT(6)) /* ignore spi-3wire */ - -#define ADXL345_DEVID 0xE5 - struct adxl345_data { const struct adxl345_chip_info *info; struct regmap *regmap; From patchwork Mon Mar 25 15:33:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lothar Rubusch X-Patchwork-Id: 13602425 Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A0E181AC4; Mon, 25 Mar 2024 15:34:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711380893; cv=none; b=CtpexqmNbmOvjYa57tFiJ7mFihHdyu+kaRWBGv4Flh4M9l0RD2vFv00dtyohWtqNfduZzHPMt91sMf5i27PvIK6KS1ZsXHzlM5Vo1tFIKNxidXkrnj9PVvoLfojPwmssOLm3UavZF4sSAMpQZB8AlrCskIw9iKpBeV76yzp+3qo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711380893; c=relaxed/simple; bh=pToit27TqLaZTZVIWd9WSIUZ1i+05Dk9aFS/Q3bfuoY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=i/1QDDpIy1d6/yzNrZ45jkj713rVtTogIgZAHtskwhleSRDvF7VviuTC2Afbem6eitDXaQ3x9lLTM+e8GlPIXlC+pmVZLZkWKYSChHryXquhMhSixCOst1+cLrC0ZesCHrHD2cP+CL2XpE37aBCsLH6a74QZM5QR6O8aHNFwXhk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=eMfvY0IB; arc=none smtp.client-ip=209.85.218.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eMfvY0IB" Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-a466a27d30aso557010666b.1; Mon, 25 Mar 2024 08:34:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711380890; x=1711985690; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6xtVnBwEs4bYQsVbe2uhOnHxLXkyj8rDngprTSIhtgU=; b=eMfvY0IBXWmz8zimMaxR1LOGGQSHYU8vqPQM7xqxq+MGLtxHTzGw095QnoWZBvD/+S LXYh18U7Yj2L3GsUpejNhxZiB6LB/hF2lK6MdIRO7nDNZHfqxml+IEEmrEIITYaMwjqO dy7uQKuJdCxV0g4QKct2yuqzokOAy7fyYCTSJdJnrMvtv9GR0MFAEDm9vF0YbNc2DoIJ NNfMX0XpMVwOXTOKMNP7q3T5+StjbCLiUXQiDkxBBwyGcbOV2vHbyIpAUmbEGIpfLlyP yrhnWhpooZOJnxxp3h0fFaoI1Xc2iQeXY+ChbCNFZc1nQwIOhdJPI6B5d97EBjJNyBWm 2TEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711380890; x=1711985690; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6xtVnBwEs4bYQsVbe2uhOnHxLXkyj8rDngprTSIhtgU=; b=pMW6O05X2yWQrAUGQU4LmK9XDYNBCup2sl21E40wjvG67vH+1YrNAmbOafv/0G4GKt Midp36nvmjeQ0v6e/TMLC8AKcdnHGRpdLOF+//HcRveoYxAcNuNcea81AdBbvG1BkBmt t3+7AyHS1S2OyC+2ZqjODHBWTLnZ6Ly+Om5upFuGzbCXp5l1ypvkud3kSOkKUKpoPTYG rhX0Uq8zSPu7QIQsYMXEYnen0x9d1JBoocKCfv54EgR03sE7rnwA4i5vrKe9Abi2ae+G RkehTxw/i52CYJGqKtraX0zVuqRF/CqeB8Poc4SithnK4zVzMf4wXIn5bzChZMyZF+7K 2IZQ== X-Forwarded-Encrypted: i=1; AJvYcCUL4pd1mZ+YMk5e/YDszFw1HAUsJHBmubdDAlAYrNNHarwX6w4gJ7DVV4QyWIOouyIZu/jTlLAbJ4kJOPOEpMUNfUy/nuByGV/V/Y+0X47sEZ3HpMtCuGRVf4D4YMuyzciQZ1zcwKXhqA== X-Gm-Message-State: AOJu0YyGu0fY2DeZMK9/+b8W1cOY2rdWsrao1vmnj8Dpdo+GBkZV2jbY zdK2wegVmSoqjFeunX87jIb6AN5T2J8LSHougMd29mDpFhGvkRht1J5qdZe+WdE= X-Google-Smtp-Source: AGHT+IGVUmFgkxgq//pLm6j5DJT/mQLd/o7s+zZL7Jq37avlN98P/S2K7jEw101TfUx3ozVEe5v5kQ== X-Received: by 2002:a17:906:811:b0:a46:22fc:74d3 with SMTP id e17-20020a170906081100b00a4622fc74d3mr4734839ejd.72.1711380890424; Mon, 25 Mar 2024 08:34:50 -0700 (PDT) Received: from 764c7355c69b.v.cablecom.net (84-72-156-211.dclient.hispeed.ch. [84.72.156.211]) by smtp.gmail.com with ESMTPSA id u13-20020a17090626cd00b00a45200fe2b5sm3142382ejc.224.2024.03.25.08.34.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 08:34:50 -0700 (PDT) From: Lothar Rubusch To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, eraretuya@gmail.com, l.rubusch@gmail.com Subject: [PATCH v4 4/7] dt-bindings: iio: accel: adxl345: Add spi-3wire Date: Mon, 25 Mar 2024 15:33:53 +0000 Message-Id: <20240325153356.46112-5-l.rubusch@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240325153356.46112-1-l.rubusch@gmail.com> References: <20240325153356.46112-1-l.rubusch@gmail.com> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add spi-3wire because the driver optionally supports spi-3wire. Signed-off-by: Lothar Rubusch --- Documentation/devicetree/bindings/iio/accel/adi,adxl345.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/accel/adi,adxl345.yaml b/Documentation/devicetree/bindings/iio/accel/adi,adxl345.yaml index 07cacc3f6..280ed479e 100644 --- a/Documentation/devicetree/bindings/iio/accel/adi,adxl345.yaml +++ b/Documentation/devicetree/bindings/iio/accel/adi,adxl345.yaml @@ -32,6 +32,8 @@ properties: spi-cpol: true + spi-3wire: true + interrupts: maxItems: 1 From patchwork Mon Mar 25 15:33:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lothar Rubusch X-Patchwork-Id: 13602426 Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D3143E498; Mon, 25 Mar 2024 15:34:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711380895; cv=none; b=DgyNCTnscmyNJ/B1pR7MecPHg7jvARgRU0+oZDp4t6ceTpHQjqiyvhH28MA8L7+/EWSOT07GXNVUXhq7n6Rmd3j4S7bNx2zvZYwo2naWXvNrRdLeSnhUOEkM5tzkl+evM8zXyy3yNUsDore/rk3Ddwvh0zw6OQf6KP4iysq0yYo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711380895; c=relaxed/simple; bh=/2mSw34ubOjCSkINOakka+pJYxBDJy/KNLR6V7CRKgY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=C40/kdC/uw04g3PaeJKvTi4p6Wqcvr2n8lb4eEX4UTsgYqRMmE6AYcEI3iqHWyBwCAO97lEFztSQMSDpHn/7wrZYiVlbuBGXoeo5j3wj0a/EzjQv2IiyRbgsPuTK9AIXA6hDBtw/6aF2Z41rEeNZEpozth9pWrUu2QU+9UjKw/g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=bzpIQPkc; arc=none smtp.client-ip=209.85.208.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bzpIQPkc" Received: by mail-ed1-f44.google.com with SMTP id 4fb4d7f45d1cf-56bf6591865so3152792a12.0; Mon, 25 Mar 2024 08:34:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711380891; x=1711985691; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JJsG/u26fANj8HMmDcxhC2mSREXIwDZdu5OFv3zb+zw=; b=bzpIQPkc4IkKaNvbI9ksSqTbIaJpAaKVU/o7t/HkIdsuHm0Vi/dMmVPdhs+yD5zgrK lT8bEJ1qzjiJKNhlKmRfj0PaPTYDUc62OkcpC5ABtsd/fhsJJxy8/haAFbv2uGB2kdwF WEt9nOJSSdY70AB1snp+sE+CTfLJldqKKrd3tR/Z1yV5V5G/BSZtGRkPVZg0RcR2rvCL ZdA/Q/VXQeVVJmR9ctvht1IiQsxnxKGEUUCH6bth555ffUCzYR/MEp9S+bcCbP/xsjlB 9tfxBfDyPDghJD5VzJ5ZvsLCddjPVlpxFZkTNeWvHqYyqYBM/8a/uULaE8fd9d3Cdks1 bcAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711380891; x=1711985691; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JJsG/u26fANj8HMmDcxhC2mSREXIwDZdu5OFv3zb+zw=; b=Oj8lSWJ0lM34tFbH22pAYlrug67G7RSkq8hMupe2mVMqCObnWdMIyB2obHxONqzVWU cJT35rfNbBx86IZvA3kNoPizfZHmdp1YUP9anLiOIpB+7G//zd9F78pZxotU3PBblVw2 WepE/wqzuppNsvA3dtJL390BuU8YusGAKr1Fvtwbclmu8RXhz7upaP6nnT3UbaBIv514 tA74nYB8ZQhjxcxEFZDFl1zAOeYZ07go06rWP6N1hVwgwTtt7SKvwLNrhYgzW+tzz97q 4/YsnBjrEffxotYcWEVB0Rg3/oOeNnptZIaxZwCFPEK3b7XXe4aS+HaxHvZrX+YwUyeZ xVfw== X-Forwarded-Encrypted: i=1; AJvYcCVZHaQwl89MgL2/H/T7Bj2GAvxBam6W0oMRwZKBE5b6HC88Jj1PIUo7UIg9NLcycuXl7CTn7cHKx2plprq+ODkip6y5u9FHw+N5KGF5E9/eRHliC0uVDegWT7/GyPcT2RDlLi6CJcT7IQ== X-Gm-Message-State: AOJu0YydiPJCuy1fjVQZ7vCMaplFVvFqaIwszocErpdXXpXPmrQBUX3u ABwC144+MJpuke+BKeO42k0sYn+/OCTNiQpO/N+HzpgC+eYcy26K X-Google-Smtp-Source: AGHT+IFy1Y3RJgXdyJqmoq/0ZsaeR1o3plSyfFO1h4d1uVZLkNnbWutn3mNYRx/Hg1zkERxFJtrcbg== X-Received: by 2002:a17:907:994a:b0:a46:b798:9571 with SMTP id kl10-20020a170907994a00b00a46b7989571mr4404426ejc.58.1711380891621; Mon, 25 Mar 2024 08:34:51 -0700 (PDT) Received: from 764c7355c69b.v.cablecom.net (84-72-156-211.dclient.hispeed.ch. [84.72.156.211]) by smtp.gmail.com with ESMTPSA id u13-20020a17090626cd00b00a45200fe2b5sm3142382ejc.224.2024.03.25.08.34.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 08:34:51 -0700 (PDT) From: Lothar Rubusch To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, eraretuya@gmail.com, l.rubusch@gmail.com Subject: [PATCH v4 5/7] iio: accel: adxl345: Pass function pointer to core Date: Mon, 25 Mar 2024 15:33:54 +0000 Message-Id: <20240325153356.46112-6-l.rubusch@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240325153356.46112-1-l.rubusch@gmail.com> References: <20240325153356.46112-1-l.rubusch@gmail.com> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add a function pointer argument to the probe function in the core module to provide a way to pre-configure the bus. The passed setup function can be prepared in the bus specific spi or the i2c module, or NULL otherwise. It shall then be executed in the bus independent core module. Signed-off-by: Lothar Rubusch --- drivers/iio/accel/adxl345.h | 3 ++- drivers/iio/accel/adxl345_core.c | 10 +++++++++- drivers/iio/accel/adxl345_i2c.c | 2 +- drivers/iio/accel/adxl345_spi.c | 2 +- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/iio/accel/adxl345.h b/drivers/iio/accel/adxl345.h index ee169fed4..620a2e0f0 100644 --- a/drivers/iio/accel/adxl345.h +++ b/drivers/iio/accel/adxl345.h @@ -59,6 +59,7 @@ struct adxl345_chip_info { int uscale; }; -int adxl345_core_probe(struct device *dev, struct regmap *regmap); +int adxl345_core_probe(struct device *dev, struct regmap *regmap, + int (*setup)(struct device*, struct regmap*)); #endif /* _ADXL345_H_ */ diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl345_core.c index eba9c048a..476d729bc 100644 --- a/drivers/iio/accel/adxl345_core.c +++ b/drivers/iio/accel/adxl345_core.c @@ -168,13 +168,21 @@ static void adxl345_powerdown(void *regmap) regmap_write(regmap, ADXL345_REG_POWER_CTL, ADXL345_POWER_CTL_STANDBY); } -int adxl345_core_probe(struct device *dev, struct regmap *regmap) +int adxl345_core_probe(struct device *dev, struct regmap *regmap, + int (*setup)(struct device*, struct regmap*)) { struct adxl345_data *data; struct iio_dev *indio_dev; u32 regval; int ret; + /* Perform optional initial bus specific configuration */ + if (setup) { + ret = setup(dev, regmap); + if (ret) + return ret; + } + ret = regmap_read(regmap, ADXL345_REG_DEVID, ®val); if (ret < 0) return dev_err_probe(dev, ret, "Error reading device ID\n"); diff --git a/drivers/iio/accel/adxl345_i2c.c b/drivers/iio/accel/adxl345_i2c.c index a3084b0a8..4065b8f7c 100644 --- a/drivers/iio/accel/adxl345_i2c.c +++ b/drivers/iio/accel/adxl345_i2c.c @@ -27,7 +27,7 @@ static int adxl345_i2c_probe(struct i2c_client *client) if (IS_ERR(regmap)) return dev_err_probe(&client->dev, PTR_ERR(regmap), "Error initializing regmap\n"); - return adxl345_core_probe(&client->dev, regmap); + return adxl345_core_probe(&client->dev, regmap, NULL); } static const struct adxl345_chip_info adxl345_i2c_info = { diff --git a/drivers/iio/accel/adxl345_spi.c b/drivers/iio/accel/adxl345_spi.c index 93ca349f1..1c0513bd3 100644 --- a/drivers/iio/accel/adxl345_spi.c +++ b/drivers/iio/accel/adxl345_spi.c @@ -33,7 +33,7 @@ static int adxl345_spi_probe(struct spi_device *spi) if (IS_ERR(regmap)) return dev_err_probe(&spi->dev, PTR_ERR(regmap), "Error initializing regmap\n"); - return adxl345_core_probe(&spi->dev, regmap); + return adxl345_core_probe(&spi->dev, regmap, NULL); } static const struct adxl345_chip_info adxl345_spi_info = { From patchwork Mon Mar 25 15:33:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lothar Rubusch X-Patchwork-Id: 13602427 Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 76677839E6; Mon, 25 Mar 2024 15:34:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711380896; cv=none; b=XBJfnT2qd6syEmWhlrgjyscNB5X+wN6xxx6ahJk/6Zt5NBK/4GQ0iWxDnEsQYxcHm9XdiB4B0xatf7lUrtbU/QLtr2nD5g1FEPIuQaXeFmwJod16GAiZC47Yqc6YMoUi+Wi+KWkzKIHhcqo4q+WRA3F7mxLThkMCAC4gLMVsr+w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711380896; c=relaxed/simple; bh=hARmtm4rTtaFJuBULTQfdo9eTIL2pJjKJoGGzQJIVXs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NpPDNpbrD8TOArGz66u2+NhIZ9ZEN5qvE+JmjwU0chVslPYSMPPC0/kHTFl8aUOqUw19f8vP5bH47frBHmnfEo7S+bMKuOSVoTy150VismO8QOKvJ6aqtvy88hBl7Z5aBL4zqiDA9nHUIQEQAKLIMY8GkOpxUbikA3VQw8QoJRs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fszZjiXl; arc=none smtp.client-ip=209.85.208.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fszZjiXl" Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-56c1364ff79so1276484a12.1; Mon, 25 Mar 2024 08:34:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711380893; x=1711985693; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kncRhP2pT3ITSlMJR34JQI/1lm9wSvt8Ld4xw8gbYnM=; b=fszZjiXl3bOgpfU3XybGPV1BwO/yhW3kwTN9ra6hI2mEQG0pX6wUHXJBJAHcWV+4LW mA6llR/x7SKqEBKcp3+a33U06OmyEgQ4B/DmdfYPCCb5zS3r1C1Qyib6biKXFxv/1mz+ CibdoTlqRH9TVGyOHmsvbfRfR5uvdWdNgRVPS9nSLAWSm9S5j5s9VB5E0ORMJpzN+vk3 H7xMe2OUqjRuXHX2VZmZ8SU852FYg1HGcQn6Q6PZ3aP/43nYbjazWM2D4yBitA2D4mfm eKtHTQy1Dih/z997BLeamyk6AD7REButmQJB06l2Dl/SgkIAXFZmZqMmR2iVrnIqV99e 32dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711380893; x=1711985693; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kncRhP2pT3ITSlMJR34JQI/1lm9wSvt8Ld4xw8gbYnM=; b=g5+wNEIKps00c4htFPg35QJRh3BQV3NZZQNSwqYZmb70ey1Kd65ub0NnVKJ+5i+641 mruAzmCv6qvZV/M2xmdRApuyW6QGJ6PPcfdRR5VKOmch9nFpeShiQ0ZIJlIOQ89OzcCY 4H6ZNi8QlbfcpQzoKuS7VR48dTS/HOaXlZrsbIVKs+w6pB2/6cHL3MNbVUpE9uI/nMPQ /pOxXU87MraJ3Fj6FCZ+OuX1GGrIjymr3k2ZbhfeyOZXR0Xln2ce8jrwpYv6skMhAgm7 5N3C4yfFj7gPDZM7k+KIOzX4vP0GSEaaLYGW6zz6dGwbmMJ+9bvqOeSYeIsU/S0Nl3u0 ELDA== X-Forwarded-Encrypted: i=1; AJvYcCUgdW1c1LGR3aMwH2wyWbRKH92skw5VCr3mwg97Tmeu4TtBaGKHy+rRZBBZGeBH2Mw4PCOI66lq1euI6PbnRg+bBUCGiBsTefcS/V4zGES5f8oLd0ByaUzNadOoHTRY1ejvD/ugJYI+pA== X-Gm-Message-State: AOJu0YyeEr1EvBjgCNFiyhG5L8hVMw1SZoVUsOVFHOH6yagHlRqPGAmt TsWlNHY4Qky0SxHXGyGkSUNSegXB4mWo4NaAQkh9/GkJCRMEra8b X-Google-Smtp-Source: AGHT+IFWO/l7ZW7wmITmIZ6PJURGgtIwl+CB/Bp7KN0Pbr87Q40eX4kT41S98QRPKjK/9t26KqRAag== X-Received: by 2002:a17:906:289b:b0:a47:1b14:423 with SMTP id o27-20020a170906289b00b00a471b140423mr4806853ejd.57.1711380892631; Mon, 25 Mar 2024 08:34:52 -0700 (PDT) Received: from 764c7355c69b.v.cablecom.net (84-72-156-211.dclient.hispeed.ch. [84.72.156.211]) by smtp.gmail.com with ESMTPSA id u13-20020a17090626cd00b00a45200fe2b5sm3142382ejc.224.2024.03.25.08.34.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 08:34:52 -0700 (PDT) From: Lothar Rubusch To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, eraretuya@gmail.com, l.rubusch@gmail.com Subject: [PATCH v4 6/7] iio: accel: adxl345: Add comment to probe Date: Mon, 25 Mar 2024 15:33:55 +0000 Message-Id: <20240325153356.46112-7-l.rubusch@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240325153356.46112-1-l.rubusch@gmail.com> References: <20240325153356.46112-1-l.rubusch@gmail.com> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add a comment to the probe() function to describe the passed function pointer setup in particular. Signed-off-by: Lothar Rubusch --- drivers/iio/accel/adxl345_core.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl345_core.c index 476d729bc..cc3da4ece 100644 --- a/drivers/iio/accel/adxl345_core.c +++ b/drivers/iio/accel/adxl345_core.c @@ -168,6 +168,16 @@ static void adxl345_powerdown(void *regmap) regmap_write(regmap, ADXL345_REG_POWER_CTL, ADXL345_POWER_CTL_STANDBY); } +/** + * adxl345_core_probe() - probe and setup for the adxl345 accelerometer, + * also covers the adlx375 accelerometer + * @dev: Driver model representation of the device + * @regmap: Regmap instance for the device + * @setup: Setup routine to be executed right before the standard device + * setup + * + * Return: 0 on success, negative errno on error + */ int adxl345_core_probe(struct device *dev, struct regmap *regmap, int (*setup)(struct device*, struct regmap*)) { From patchwork Mon Mar 25 15:33:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lothar Rubusch X-Patchwork-Id: 13602428 Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB00A82D74; Mon, 25 Mar 2024 15:34:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711380897; cv=none; b=YCkgz6AKHps+1i76WZglMLpyZGqGpM0WXIVo53s2qO4imgq/NKN1m9dxcYWuSKQxsEGeZu9ZtK10C7/sRdQZvr62UUQA8yC95MRLlx1codyon6d7JjmRoElqpBg+CVxI+nk3fNQoeA27J99V0CM+BfHKE1KYbvVhO+BP8tofE+s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711380897; c=relaxed/simple; bh=VpmSCUo4LCSDAreg17AyaXZjU/kMgoCoxrBfLAVsbns=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Kk4i5vZXgCn18DNbj4E3Puoajum0c/GzWDlPgkdMgtR08CGG6975am7501rVgwOhwXN8NXi+uXA9W3c670SxIGfCzrWxbLLoYEHn0VmVIL4v4z70mMjB6/puF+AK1SxI3caPdgL/IxKMyxUvrwE3i16UtSOkThDEuTWl4aQXqH0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FWJDz+yz; arc=none smtp.client-ip=209.85.167.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FWJDz+yz" Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-513dc9d6938so5617942e87.2; Mon, 25 Mar 2024 08:34:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711380894; x=1711985694; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CiSHINdO4QQ9dGEkUNG8gKxPDwA7BezRYNLVvF2c4GI=; b=FWJDz+yzomkrbc6FXZUNN8OTlDrCAwaVNBb9ATK7zlo3//HaVnlcy4f4DUKoW0tZS7 m5fzTb9JpOGNmwZBaZG3sbvv4WiXnGz+njQrett79NQ8NoeInXPYCR/Fwziex1Wa/sJ7 6Mu/jX7F30qdWexK8CtrpdLdhh8s+/qEx+t+oTQ5T4w2YLCi1gxnnvdp0m0tUhY9+LXn GEJ177dQZpAq8jfjSN+QG3Y298VaTQmHznd2bzrTQ+xUbCSDlYkg4yEYIb1c7pbitvk/ NnTPA6Li01IgrJhVlFoZixjBKuPnO21qyxmIudegx7lpuP+9QIQbOPQN/Z6kg1Jbu/fp BN0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711380894; x=1711985694; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CiSHINdO4QQ9dGEkUNG8gKxPDwA7BezRYNLVvF2c4GI=; b=HanqLK1OhkTA4wl96vwuJhRRFCJ8WDp569eLZbiebjHVcWJWyh/4pf54d+pkv7w+RI iGmYUqXvDfBFeiupkazvIhKDKBkSlKD8XrFurz1zray68JmFfvqv1K/vz8UGpMLKYTVZ EUOxrt8giwuOfg/OJm0JX76SzBsW/w+euPgonU21agmwk7GRs9mz62/8kocx9DIcDrrM wCo7BcWTFP5A/Ks9zPeV3rE74unJrbuOsHP4LdUHUSD2Yu4sHTNSfWqbS9F79s2vavIU uuC4IaZjyeL3VdNs0PG0wOucbLACLKsMCRXjKoanFoDROS7/tfja7qeSBdhwdHFuO2i9 b+2Q== X-Forwarded-Encrypted: i=1; AJvYcCWN83047bVa8EdEMJPROixvC7ubyd+C7SAdzNEcCsnanwOfS6KME9bhG20VVtCsuirPpq+VuP6DW5nv/I5Al5Tg5RzZZf5fme5/Gmmauw8A08ss/XD0SLCQwgM/TaBbcWpjVJzMOgsRyQ== X-Gm-Message-State: AOJu0Yztj+e+t0/6qzbPwI0a/DZsu/Timc3Iah2yi6nuApMsd9UznJWs q3NmxTrVQpDyL+xFQwRCC+RDuEgZou8c3FiKdUkg+K8q2sJkrd4/ X-Google-Smtp-Source: AGHT+IEwy3EYA8kKvQPY3gjgvTL1CYxxrX54THrLiN66C1zBx3z6uDkuHjcp5TU9+9lJcfYG7H660w== X-Received: by 2002:ac2:554c:0:b0:513:d339:8b1 with SMTP id l12-20020ac2554c000000b00513d33908b1mr4663596lfk.27.1711380893781; Mon, 25 Mar 2024 08:34:53 -0700 (PDT) Received: from 764c7355c69b.v.cablecom.net (84-72-156-211.dclient.hispeed.ch. [84.72.156.211]) by smtp.gmail.com with ESMTPSA id u13-20020a17090626cd00b00a45200fe2b5sm3142382ejc.224.2024.03.25.08.34.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 08:34:53 -0700 (PDT) From: Lothar Rubusch To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, eraretuya@gmail.com, l.rubusch@gmail.com Subject: [PATCH v4 7/7] iio: accel: adxl345: Add spi-3wire option Date: Mon, 25 Mar 2024 15:33:56 +0000 Message-Id: <20240325153356.46112-8-l.rubusch@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240325153356.46112-1-l.rubusch@gmail.com> References: <20240325153356.46112-1-l.rubusch@gmail.com> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add a setup function implementation to the spi module to enable spi-3wire as option when specified in the device-tree. Signed-off-by: Lothar Rubusch --- drivers/iio/accel/adxl345.h | 1 + drivers/iio/accel/adxl345_spi.c | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/iio/accel/adxl345.h b/drivers/iio/accel/adxl345.h index 620a2e0f0..55a72ca38 100644 --- a/drivers/iio/accel/adxl345.h +++ b/drivers/iio/accel/adxl345.h @@ -36,6 +36,7 @@ #define ADXL345_DATA_FORMAT_8G 2 #define ADXL345_DATA_FORMAT_16G 3 #define ADXL345_DATA_FORMAT_MSK ~((u8) BIT(6)) /* ignore spi-3wire */ +#define ADXL345_DATA_FORMAT_SPI_3WIRE BIT(6) #define ADXL345_DEVID 0xE5 diff --git a/drivers/iio/accel/adxl345_spi.c b/drivers/iio/accel/adxl345_spi.c index 1c0513bd3..f145d5c1d 100644 --- a/drivers/iio/accel/adxl345_spi.c +++ b/drivers/iio/accel/adxl345_spi.c @@ -20,6 +20,16 @@ static const struct regmap_config adxl345_spi_regmap_config = { .read_flag_mask = BIT(7) | BIT(6), }; +static int adxl345_spi_setup(struct device *dev, struct regmap *regmap) +{ + struct spi_device *spi = container_of(dev, struct spi_device, dev); + + if (spi->mode & SPI_3WIRE) + return regmap_write(regmap, ADXL345_REG_DATA_FORMAT, + ADXL345_DATA_FORMAT_SPI_3WIRE); + return 0; +} + static int adxl345_spi_probe(struct spi_device *spi) { struct regmap *regmap; @@ -33,7 +43,7 @@ static int adxl345_spi_probe(struct spi_device *spi) if (IS_ERR(regmap)) return dev_err_probe(&spi->dev, PTR_ERR(regmap), "Error initializing regmap\n"); - return adxl345_core_probe(&spi->dev, regmap, NULL); + return adxl345_core_probe(&spi->dev, regmap, adxl345_spi_setup); } static const struct adxl345_chip_info adxl345_spi_info = {