From patchwork Fri Mar 29 00:40:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lothar Rubusch X-Patchwork-Id: 13609815 Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (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 63CA95223; Fri, 29 Mar 2024 00:40:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711672842; cv=none; b=duoqFBR2a+wzs4/PqCTK19Ear386EmdoCU+iMDhlw7CHEVpQLLXhQ7Owg42dkRkb9EWpkJilMfG/2Cc5lHWO04ofvfzqk0MpgD00GbAwSlrSogxtVK13+5bvNm1WjEyiIItkhhpk0YrN20uzEKTn5WqpXz3zn9/TfthoPCXzy2w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711672842; c=relaxed/simple; bh=Thuwc5jU/GgWSwwKqdNAbuidpQuzlLpjhLu2hWojAgA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=A8eDOHUPpTIumRnGxzQqDrsSdwie/w1qGh7I2LWodiEKJvIiCLNXiImeYjrND7lSTbU+bCvn47aMccEWPPljMLasx/dO5QDVDPM03WXtB7jKa1Rw49CPrt46xIlO1V1BXLY4PgTpOYPfxOm81eIXBQjf/9v222NlL5lf1pd5xHo= 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=mSr3SP5E; arc=none smtp.client-ip=209.85.208.175 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="mSr3SP5E" Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2d68cf90ec4so22552911fa.1; Thu, 28 Mar 2024 17:40:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711672838; x=1712277638; 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=en74PRYThtLoO+VTh1LsA/OHt41VMEnZsO14VQkkbVY=; b=mSr3SP5EXoTN8Voh0QJzDBPfJ0SqMG1j2blUWHlDepcUCEb4YJQ8plSKlhEBQpgQtf dm1IfNK23TMyEzT61BOdMprJdcq40v3qTTZffSlQjX2Ig2DyeRRMXBB8pzx/WZQOGIu0 hus6KKFHYGy67ejUfaLT/PG7/tgTN8NTUHCfYuNXJH68DbOpLqo6W0eKn4AC8cDxQZL3 /Pmef/NFuIv0KgHrJFKMAj8c8LEQ5kaL1LCOu1Ae/GlRzMTMEcacOqak+OVf1PxsAOuv Ss+5+WE+V/9taqAgbMHD6sAM6k6GjZuXP+GFJtPWH41VoNdXP/8XuiMbOoKaomZ+n5xz nuRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711672838; x=1712277638; 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=en74PRYThtLoO+VTh1LsA/OHt41VMEnZsO14VQkkbVY=; b=R1dt6L/se4dvgQj3ttgobJaIbxTTolDDu9MdHq1EQhFaZcHmRmi68CHRO9niBZM/pM OOK6SIJ5w9sdj8KBkREA3uwHzv4RMm+wU/pBF2z9aicqCeIDGBzwjJw/cyP4EBlnO/UJ 7GerFGZ27DbhyWFcga6k48LXBVT08IE+B4xol53gNnUGAvHSHJetoOcBPXgreOzSGp04 VQ+TeE0rO+KEUdrsVMExOq1hjeGwC566Evl+Zg3cVrl4czFKTvPvtMrRfH+GbRfYwj5D 8rYV9ZzLirzonfDKxw3OLsFcWk1thCQi1OvaF/mNkdw/Zsk/R69cF3kVGwtSLwqtw89c q1IA== X-Forwarded-Encrypted: i=1; AJvYcCUV6yt7RL6RvC567hkxqE5SgGpnJvxKZRtiXjt91IfFtqp3LuQCtzFLoZALBVIOAzxTHA+4fssScX7hLMtnP7fvKHUGQnYaslihNn23kaCxWKUOGyey+esZVNbv74eXcvQ1Dcd2yXVzEg== X-Gm-Message-State: AOJu0Yykv0syq9c4tdXAtvNdi/PCLJd667aS1uV6pZIItUoXjQdoyjHk bWn8u93W7+UokO3Jv+r4lU5zD2qmkwInJfSfKn2RxmuJhOHzdwaK X-Google-Smtp-Source: AGHT+IHLEdypJQUYV/jdgCcMH1dpYnvwd01rFstgAhUY5O5VaHOzyRoH/NtD1Mf9a3Jp+miVgCO3Ow== X-Received: by 2002:a2e:a4c3:0:b0:2d4:83f9:2e21 with SMTP id p3-20020a2ea4c3000000b002d483f92e21mr356943ljm.42.1711672838244; Thu, 28 Mar 2024 17:40:38 -0700 (PDT) Received: from 13a4f82a8f12.v.cablecom.net (84-72-156-211.dclient.hispeed.ch. [84.72.156.211]) by smtp.gmail.com with ESMTPSA id h7-20020a0564020e0700b00568e3d3337bsm1391679edh.18.2024.03.28.17.40.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 17:40:37 -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 v6 1/7] iio: accel: adxl345: Make data_range obsolete Date: Fri, 29 Mar 2024 00:40:24 +0000 Message-Id: <20240329004030.16153-2-l.rubusch@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240329004030.16153-1-l.rubusch@gmail.com> References: <20240329004030.16153-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() to keep bus specific pre-configuration which might have happened before on the same register. The bus specific bits in data_format register then need to be masked out, 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 | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl345_core.c index 8bd30a23e..f4dec5ff1 100644 --- a/drivers/iio/accel/adxl345_core.c +++ b/drivers/iio/accel/adxl345_core.c @@ -37,7 +37,11 @@ #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_RANGE GENMASK(1, 0) /* Set the g range */ +#define ADXL345_DATA_FORMAT_JUSTIFY BIT(2) /* Left-justified (MSB) mode */ +#define ADXL345_DATA_FORMAT_FULL_RES BIT(3) /* Up to 13-bits resolution */ +#define ADXL345_DATA_FORMAT_SELF_TEST BIT(7) /* Enable a self test */ + #define ADXL345_DATA_FORMAT_2G 0 #define ADXL345_DATA_FORMAT_4G 1 #define ADXL345_DATA_FORMAT_8G 2 @@ -48,7 +52,6 @@ struct adxl345_data { const struct adxl345_chip_info *info; struct regmap *regmap; - u8 data_range; }; #define ADXL345_CHANNEL(index, axis) { \ @@ -202,6 +205,7 @@ int adxl345_core_probe(struct device *dev, struct regmap *regmap) struct adxl345_data *data; struct iio_dev *indio_dev; u32 regval; + unsigned int data_format_mask; int ret; ret = regmap_read(regmap, ADXL345_REG_DEVID, ®val); @@ -218,15 +222,23 @@ 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) + /* + * Only allow updates of bus independent bits to the data_format + * register. Keep the bus specific pre-configuration. + */ + data_format_mask = (ADXL345_DATA_FORMAT_RANGE | + ADXL345_DATA_FORMAT_JUSTIFY | + ADXL345_DATA_FORMAT_FULL_RES | + ADXL345_DATA_FORMAT_SELF_TEST); + + /* Enable full-resolution mode */ + ret = regmap_update_bits(regmap, ADXL345_REG_DATA_FORMAT, + data_format_mask, 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 Fri Mar 29 00:40:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lothar Rubusch X-Patchwork-Id: 13609816 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 5944411720; Fri, 29 Mar 2024 00:40:41 +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=1711672844; cv=none; b=SgsfRiv/sHUilWukwXWXDHPDy8p9Nm0SeCth/1cjvUl3s1ohfKnKLfMShNhp1SXS8shI3YnFX5srIs/tJO9BjBGXXM6JHKn7BpogD+avsuqIdPbWZbIHNZtEdlQ3sF0r3BQcni6ISwds4Ng89lJf/YIhf64yLCeU8JhyfUN5iHw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711672844; c=relaxed/simple; bh=HHf07n/B+1VkiALybuaC6O5pR6Els/Bni9LZ9AlsDXo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WvZ/ihiZd4LcPpwYunvV0Nri5ZTkfLI80BFqeVqykcW2eNzautNy/gLB9Ay0Wv10bxz5D90DMDcCTBwKQsvu0KeMzCLQZzXcF/BSMYwS3MQCUGBdrvGHDEp0KaTJVpOnu2wniSVFVVe3ar06yTtQ5twPTweMr8mtRtbvimyipOQ= 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=HVMR6B+X; 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="HVMR6B+X" Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-56bc5a3aeb9so1935746a12.3; Thu, 28 Mar 2024 17:40:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711672840; x=1712277640; 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=xiaRmyfs00yXQyFJiot+MPjs/cJdjRS0zbVlH6tELQU=; b=HVMR6B+XDlono+CJhQCW+jbew17aKuv5Hsg51FdRyz5+Atlrb6UKdsqlpjCcMmxYgP WcUogOcoQNY8p8Qb2mgsu94Y4JNYEyhJs979vWYyctEIEog2RHDzK7R6Ydhlk/DsDZZS iSxwckIDWdZk6gF+fGntvo30od0CXcbjlXrzSWugxSQe1T072LOateBNQB1wMF/Rg+4d 6BXIJrazyfyPUFHsmV1ufBLcNpcmOLYFfIe5rQE7a8KN10YHqagQ3aEM3lrX83dkS8dF vgpl0Z3/oILmDU7m/HkKGQ1EHIj8HrB6y9TW1Ii47ASSmnU/7Cr9rGuSkVUFIUmOrbJJ EMdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711672840; x=1712277640; 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=xiaRmyfs00yXQyFJiot+MPjs/cJdjRS0zbVlH6tELQU=; b=GfhEacjuQT4wUQePYYuhy5sN3vx9oO3w/Q+mjI4CJU6vxvPj700Vg4B5N99grRj7OX yY+lQ7q+DPMNAs6jWuRuQW8XivssarpF8vbgtuHd3By6ZOdluT8CJ8gaPyMFeFswMdsg hZRZ7OAQnKG+q4sdV4e/X0Dgs+JpkFWH1q1h6efNRLMtzDsX028wNip5PDVHIyYlEv0C VY8CA0RHG5xwju9ju6XcWHJb+BfVUqCDnzXBmOWi0GogX1VXCIeX0fK03/vxbzrtTlw+ 7qSytZoQB3aYZHo1w4+Ws+qucsS/cWh5yUxxNHg7O0KnXeujs9Q350s2Jbxqh749ZUws ggaA== X-Forwarded-Encrypted: i=1; AJvYcCXUCsHuuPceJHUqpk9g4VHAX74YRUD6ZzuWpiqZIT4Y4ki2ed8gdr1pYu5X03xNhVL8o945uBRPTQfCkMNzjxK6UIOhgrQOXiAD1fvaAMugoGNwfAYAp+texD3SxwdF2Wa1dKkcT4o6kQ== X-Gm-Message-State: AOJu0YzFOGMZvjYpGtoExfIBtLgjEjlnDXMKfmPMhG+0kbtMzwJ4idxi 6o+uScmPg9JcwjqwKX+lYhILRLxfO8Q6mMfIdJRKT6/rrfalud9I X-Google-Smtp-Source: AGHT+IGrOQLOHCIZRvmmqqZdSFPOBaphyM/PBSqIAVyvQU18lLULmNIxtsZA4NKOkZUaxso6VriP+g== X-Received: by 2002:a50:ccdd:0:b0:568:b41b:afd7 with SMTP id b29-20020a50ccdd000000b00568b41bafd7mr471627edj.29.1711672839536; Thu, 28 Mar 2024 17:40:39 -0700 (PDT) Received: from 13a4f82a8f12.v.cablecom.net (84-72-156-211.dclient.hispeed.ch. [84.72.156.211]) by smtp.gmail.com with ESMTPSA id h7-20020a0564020e0700b00568e3d3337bsm1391679edh.18.2024.03.28.17.40.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 17:40:39 -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 v6 2/7] iio: accel: adxl345: Group bus configuration Date: Fri, 29 Mar 2024 00:40:25 +0000 Message-Id: <20240329004030.16153-3-l.rubusch@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240329004030.16153-1-l.rubusch@gmail.com> References: <20240329004030.16153-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 Group the indio_dev initialization and bus configuration for improved readability. Signed-off-by: Lothar Rubusch --- drivers/iio/accel/adxl345_core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl345_core.c index f4dec5ff1..78ac6ea54 100644 --- a/drivers/iio/accel/adxl345_core.c +++ b/drivers/iio/accel/adxl345_core.c @@ -226,6 +226,12 @@ int adxl345_core_probe(struct device *dev, struct regmap *regmap) if (!data->info) return -ENODEV; + 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); + /* * Only allow updates of bus independent bits to the data_format * register. Keep the bus specific pre-configuration. @@ -241,12 +247,6 @@ int adxl345_core_probe(struct device *dev, struct regmap *regmap) 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 measurement mode */ ret = adxl345_powerup(data->regmap); if (ret < 0) From patchwork Fri Mar 29 00:40:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lothar Rubusch X-Patchwork-Id: 13609817 Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) (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 84F3E12B7D; Fri, 29 Mar 2024 00:40:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711672844; cv=none; b=P5+ha4exvqF3yJo8TmDR2Q11xbMWmBTStdAzuxK8UvbKGxIhCizoaVrqUTv2z0WSv3zqh7/kcXpHOiIqed9Wu6LkO5/FJInkTqe8yVoJ2uSpnNLCdQmGOtFzS3jgM1Z7IvfmaHDNPsac12ZZIyzGJSuVKnQUhPdpr7UVkziph/k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711672844; c=relaxed/simple; bh=aP8XoWDKMAqyC8zqtB8kZRrILNh4BKvcnm/KEBjATvo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UQuY0MINFsuN3C7O3fCl9fi+1k3YW4bzKbOwZ9MHkeUqg/hKb9vdC5IqAIlG4NtdSqbKaARXbVJED8EHVNkw67N7ArYpJMJVK4ClOPsYl9UBZgZYdaYzNR3Ad9se8GpxeUSBKkAlJBSZkIT57E5mx571NSyHcJPsnHo59j47Fp4= 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=iWZWrkNp; arc=none smtp.client-ip=209.85.208.53 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="iWZWrkNp" Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-56b8e4f38a2so1897738a12.3; Thu, 28 Mar 2024 17:40:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711672841; x=1712277641; 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=QESGkji1riXQtsL/9cuxNH551LD8cpn/5+qi4Dzrz2w=; b=iWZWrkNpmBTSJMwlmtmE9mSdYbN1yJoF41VkQXlv0WzXMU5YXbT2giMZcjR+PPLV1E ElGAgjK3Mpglc8ABZMxhsGT9s9EezFyaWVWDabrxjnBU/bLp53w4g6ZY2ZdGTtgqkmmv DVOJUl3c3GOBVr3mzmtgNobpzfWavdpgfXfis1aNf8LKgc/qRyeE0abzRqIazFzgONy2 T1eKn9KacLLbOkLtQsjun71H+g8GBA3rnE4idrNlz1zJ2YLOvNRyw+hMsaTOxgjo42Fm GPyODoP6SxNVULV5obe4XNnibmkIigNERi6xYHLJVhie/eS3UmsegyZmNJUVAmwLsQl7 /pwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711672841; x=1712277641; 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=QESGkji1riXQtsL/9cuxNH551LD8cpn/5+qi4Dzrz2w=; b=QSlLXcWjGGcJFCuWiTvUOEgGtW6sBpvjuqy3x533/pA2eQctQEE4/mozZCxbrDa72x 5xrf74sgPyTqY1PtJi8ql+KxmrtlCSV/KQ7mdtjCII6plSFOcIS+K1GvvDaAv6V4hZnJ jf7bgI0fKZ3aQEqJ264MFm4qlROtVFEWx7mNVGqxoZ3DX0Qrb+nhsYOzHlPPwqzCkLt6 OxK9r7iyeAy90qzmQO9aCwItYXEhGB7ZOlI2ce33zp9c9SlEqgb1B+UhP7A25sbFVG9Q DXmMXiVSSywXstwIQkvcwy3aqGDPpyS+ctV1juMJ0IRDq+d5CBeKaGk3d6fDCHgZ4j3b 4R+g== X-Forwarded-Encrypted: i=1; AJvYcCVKczW9c8iHOXRUTtBlCuGL3E+TRm+Nm7T0o5qM1s1AoKqQ+4k/RGoCJK6MwyH0UFohY20lCEXfW0GlUPElm4VXOYVuqRZwE3pP6hbwIRjPaOvCyJbGon9TgV8okBkzUI0upBD3uUAwpQ== X-Gm-Message-State: AOJu0YyEplnsrzxXnGL3jg5rVytRywKF/mID+Nyn+cWKQB558W/rXtd2 FyLDJmBMyKYPhEK6VTLr46NzB4RYGNfgVi2qafcpgMqXkViddo4U X-Google-Smtp-Source: AGHT+IFXJAwXscLH4CZVba7ouP+CtKrIp9U1Rk5TXtXcXr0nf3ZOqSH0xjPt2sUi/Gb5wA/j81oJ2g== X-Received: by 2002:a50:9b01:0:b0:56b:d9b0:f1c3 with SMTP id o1-20020a509b01000000b0056bd9b0f1c3mr480751edi.39.1711672840911; Thu, 28 Mar 2024 17:40:40 -0700 (PDT) Received: from 13a4f82a8f12.v.cablecom.net (84-72-156-211.dclient.hispeed.ch. [84.72.156.211]) by smtp.gmail.com with ESMTPSA id h7-20020a0564020e0700b00568e3d3337bsm1391679edh.18.2024.03.28.17.40.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 17:40:40 -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 v6 3/7] iio: accel: adxl345: Move defines to header Date: Fri, 29 Mar 2024 00:40:26 +0000 Message-Id: <20240329004030.16153-4-l.rubusch@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240329004030.16153-1-l.rubusch@gmail.com> References: <20240329004030.16153-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 from core to the header file. Keep the defines block together in one location. Signed-off-by: Lothar Rubusch --- drivers/iio/accel/adxl345.h | 32 ++++++++++++++++++++++++++++++++ drivers/iio/accel/adxl345_core.c | 32 -------------------------------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/drivers/iio/accel/adxl345.h b/drivers/iio/accel/adxl345.h index 284bd387c..732820d34 100644 --- a/drivers/iio/accel/adxl345.h +++ b/drivers/iio/accel/adxl345.h @@ -8,6 +8,38 @@ #ifndef _ADXL345_H_ #define _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_RANGE GENMASK(1, 0) /* Set the g range */ +#define ADXL345_DATA_FORMAT_JUSTIFY BIT(2) /* Left-justified (MSB) mode */ +#define ADXL345_DATA_FORMAT_FULL_RES BIT(3) /* Up to 13-bits resolution */ +#define ADXL345_DATA_FORMAT_SELF_TEST BIT(7) /* Enable a self test */ + +#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_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 78ac6ea54..2d229fa80 100644 --- a/drivers/iio/accel/adxl345_core.c +++ b/drivers/iio/accel/adxl345_core.c @@ -17,38 +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_RANGE GENMASK(1, 0) /* Set the g range */ -#define ADXL345_DATA_FORMAT_JUSTIFY BIT(2) /* Left-justified (MSB) mode */ -#define ADXL345_DATA_FORMAT_FULL_RES BIT(3) /* Up to 13-bits resolution */ -#define ADXL345_DATA_FORMAT_SELF_TEST BIT(7) /* Enable a self test */ - -#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_DEVID 0xE5 - struct adxl345_data { const struct adxl345_chip_info *info; struct regmap *regmap; From patchwork Fri Mar 29 00:40:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lothar Rubusch X-Patchwork-Id: 13609818 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (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 DF04117BB2; Fri, 29 Mar 2024 00:40:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711672845; cv=none; b=rTPxeme7+sZbLmqGwhPzNzg6jMZVUmOLDVEzF2lIotzg4oS3l82IJr57yUiTwBx3vyyszfa+FnJniPMs9o/FO41jXIHrIXeOfgbk7YoD7XYtotlXfQyxv9O0GPPTNk1dXWDK3SoJGzwqPCQdeQPLMTi1Y05+0Vg4X8slBIRZs2c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711672845; c=relaxed/simple; bh=V55YgCvLSpqkfe7ySR+HVIoEjCLAZ+Tf3byG4H1tlRk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GSDI8/JhxTXYREbrwX4INVJhdplbRPKN5/NAX4hFqZku4+XLkvygchR93O8kdb8e0CTJWrTiszZk/HgX+/BjIY4elQr/MtTMPhjavrcWzUPWgeU8yEh0uLNW4eDS9lOh5VN5jkewjSE8A/ekOVTqEIV9+CSjfsGT2nPCEXP2dpo= 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=FoY84kTu; arc=none smtp.client-ip=209.85.221.49 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="FoY84kTu" Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-341cf28e055so1084910f8f.0; Thu, 28 Mar 2024 17:40:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711672842; x=1712277642; 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=Hfn3S64P658pp7FgLTURlhXPNN360y6ZzooV24q6Qx4=; b=FoY84kTuWo3g507K1L/0BqSPd3FDRjYm1DQEMhUn/3ofRVMeVeDWPWy2zrhbBMio0/ LZv+R4NlgWvtPZ5xexnZrUu888VpbpnF0bh4Jows02rzvFb+miKLg3cvg06pRN94RDN6 6V0JD9+2K2zbRK+b8mGbWScwWeoCEE74K6fNnV8Ex1AQpHJAS2qTfZtpTv8ViRUdPQFE FkOFjThj+WBROT+7AsJbk7jQBT+kep2YjNMQG8VuJ1hgYZ960J4KSqFhEgNkMn3Il4hB RzzbGsyb1rn1qirBSUwx8AWDrflXsFoFPPAr5kSC4lI+As4/6DaWVbftb0DD5s6XMhYm 3MQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711672842; x=1712277642; 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=Hfn3S64P658pp7FgLTURlhXPNN360y6ZzooV24q6Qx4=; b=snz9A5mW+xotNAHT+xc87Co9yhbSmsAHn9j1IdrOLv123Zk1kPi8JjQd7xvJpYqsdU 12InJt1nwu/JBTYsmncgEtAvPIt0BGL/6sKoa7i+6x917tko4ku1Ws7ixbGyvDewdy8P 9Nl5PfswsQCkrOL5sep49zEWLhQv+PqFBnU0hFlnGUoxjeXR2/QwZmvUdXUVw7geJx5q QaYm8aydkTSsgaNKlvWNFNOS59ZYvGuR+uCvSUPC4UfiC8yi/MHHpXtfEVwfnpToApMD kaWNtLnm4nREC6rZXzmqjedaEWpaGU6pSG5MUO/ifLo4jL4/fRHmnZ6B/bSotLmYCCO7 yRLw== X-Forwarded-Encrypted: i=1; AJvYcCXzofQSpaE6OuIiJRHTqhbachMizq2d5YP0SRBUCTo0cYWr5v7iXK53EoZT8XjAPOIhoJZG2Ynb/geX19HcahmdKOlHGjkf+qYhDnwgORzYOGQQzMBi2rHh+vViByEkf+tiOUqCeBx3YQ== X-Gm-Message-State: AOJu0Yxezcn9+XkKsmFsS6l9BU4rDio//jlRUlmWQ/eccxRjKTdAPR2f SrZCXLpHuR2n+pOOLM2mLuC47CSvBS6tVzjvbsYhnn2nOnr3HowR X-Google-Smtp-Source: AGHT+IFZm1frbVYStg1yuODYIU74d/4zgKC1XNB6+RkT3EgZWTe1W+u5RM0LiN/WWmVkUwgj0nYJww== X-Received: by 2002:a05:6000:ec3:b0:33d:b2f8:28fc with SMTP id ea3-20020a0560000ec300b0033db2f828fcmr421452wrb.55.1711672842280; Thu, 28 Mar 2024 17:40:42 -0700 (PDT) Received: from 13a4f82a8f12.v.cablecom.net (84-72-156-211.dclient.hispeed.ch. [84.72.156.211]) by smtp.gmail.com with ESMTPSA id h7-20020a0564020e0700b00568e3d3337bsm1391679edh.18.2024.03.28.17.40.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 17:40:42 -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, Krzysztof Kozlowski Subject: [PATCH v6 4/7] dt-bindings: iio: accel: adxl345: Add spi-3wire Date: Fri, 29 Mar 2024 00:40:27 +0000 Message-Id: <20240329004030.16153-5-l.rubusch@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240329004030.16153-1-l.rubusch@gmail.com> References: <20240329004030.16153-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 device allows to be configured for spi 3-wire communication. Signed-off-by: Lothar Rubusch Reviewed-by: Krzysztof Kozlowski --- 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 Fri Mar 29 00:40:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lothar Rubusch X-Patchwork-Id: 13609819 Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) (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 5D02B2030A; Fri, 29 Mar 2024 00:40:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711672846; cv=none; b=kirONW8wADtUzgYDGtsSA4fWRSe01vMm47Rn8w7dFsHxlKu+QZbcUnRuicTLlxwRdVn6BypeyXpaK/HuAUnnfGxonEARAq7uFdAjImLkxr30yCdmNQ82YjEHcSZcDaA9h2zMo/CGWE4JFmEj6FMUHRFD9EX/2TMWdFQNodz1IoU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711672846; c=relaxed/simple; bh=oe2RXd+B/kQL8oyi62iLzgDBkf6gznV4J0J+6lN30JQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fCmWCHLTPtjk8Itelfi8RBrr+XO+vx81Ob1NF723GnmtDeCsBOGda3YJ5vEDf2k/mRx//aDh1hIrjCehSrQM4KlIlsn7VS8ppg50yJO+USsrpyyh/X8EWKK7JCn2Q4nx8bvJxkdnwJenrM8bms549zlyQjtJRoZtvYrWASYco28= 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=SHuUY5si; arc=none smtp.client-ip=209.85.208.49 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="SHuUY5si" Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-56bf6591865so2320001a12.0; Thu, 28 Mar 2024 17:40:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711672844; x=1712277644; 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=25bHY0K50SUaaxuJWFWNToTcw1xP3p6yUVsyZaDNXuk=; b=SHuUY5sikOzR/voppv/Zdi8AzGHaQFqID2UI7JWJ+UOFBCHgx7htK91S1qb3FLH/zv LtgSpLEF39Dyrnjg4n7PSglJUZmgQfp+3hKshiuS/aNes7KD36GxHr5rLCPBIefWRysZ ROqTjElWxlrXaQYGMsgYKE0gmMlUTJv41oKVOJ31OCMk/3Pab11WWS5CCqCzzdhQueZp UBvXDmJH8W+Q/xRfk43klRlfdDvDfIiM2cS7XOtGb7dfFU23evXDiJna6ksQi5lFhk3r Muvd8h40y3oCDaJrGwOzrOGQzSOJexZneVUtbDRmFmQhlcmStQmFEmMSg9d2nEG1C7+d 7vOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711672844; x=1712277644; 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=25bHY0K50SUaaxuJWFWNToTcw1xP3p6yUVsyZaDNXuk=; b=E5q2vkLEAehkT18disADzGqWtHRuCo1UV0CLZD0s/6NOxwBSSBikmHDJxFJsufbIsz S4WBbsTWS9BLdsSLPS2/3XSOtRpu5GqzOOVeJBa1JwCN2hRRHE3+8tPmaEFGN5J+ZGaH 30sqhLcFOqJd+lEePFZxk7tmzcgq5w1xtjxRp+zjJVRFXrhba5Xdm21tFVSYyJQ/3kwq 9Fw3dd3/dvY4aue/bGE1Muui+IGHMvH9V/Z+n5kXUpS9KipJJy1p0z5kRbacF9EG/LB0 T4uSTG2fKx8W2HPZHC9VXwU61rVJ6GQmOnKMv3KumMkczp9JU7YdLsT5Soe1EUeyNH0T OL9w== X-Forwarded-Encrypted: i=1; AJvYcCW+SqgaiAwh94A8dh6zWJmVbXL4QH9vXHcYCeSmpIhM4pLPBZdpxQUDbzIL4+K7Fs6M2L2tcn7kI2xx1b9oYrJFmXbOVaYdC78OPSVKJSnjYzulXkRtkSKOHtRicfiNSEdi4CNuEDFijg== X-Gm-Message-State: AOJu0Yw4YSXOiloxx3wegoIiDUXJelvdPYesoL85NIDf6ppogaNqR5dP F2wRzqTnHwqmsTU1rweylpyQAOyXFs0Ym3d5yhszSBk4TJPEEGYP X-Google-Smtp-Source: AGHT+IHOzJY+LqCV0Q2eXYcdIO6pQJc1IX2G6da9ikb6LnpJkPyvSQEwMOY9zbqXY9Xjlx0MJ4FTXA== X-Received: by 2002:a05:6402:50cd:b0:568:9936:b2e with SMTP id h13-20020a05640250cd00b0056899360b2emr522221edb.24.1711672843837; Thu, 28 Mar 2024 17:40:43 -0700 (PDT) Received: from 13a4f82a8f12.v.cablecom.net (84-72-156-211.dclient.hispeed.ch. [84.72.156.211]) by smtp.gmail.com with ESMTPSA id h7-20020a0564020e0700b00568e3d3337bsm1391679edh.18.2024.03.28.17.40.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 17:40:43 -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 v6 5/7] iio: accel: adxl345: Pass function pointer to core Date: Fri, 29 Mar 2024 00:40:28 +0000 Message-Id: <20240329004030.16153-6-l.rubusch@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240329004030.16153-1-l.rubusch@gmail.com> References: <20240329004030.16153-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 Provide a way for bus specific pre-configuration by adding a function pointer argument to the driver core's probe() function, and keep the driver core implementation bus independent. 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 732820d34..e859c01d4 100644 --- a/drivers/iio/accel/adxl345.h +++ b/drivers/iio/accel/adxl345.h @@ -60,6 +60,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 2d229fa80..83d7e7d4e 100644 --- a/drivers/iio/accel/adxl345_core.c +++ b/drivers/iio/accel/adxl345_core.c @@ -168,7 +168,8 @@ 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; @@ -176,6 +177,13 @@ int adxl345_core_probe(struct device *dev, struct regmap *regmap) unsigned int data_format_mask; 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 Fri Mar 29 00:40:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lothar Rubusch X-Patchwork-Id: 13609820 Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) (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 A182624B33; Fri, 29 Mar 2024 00:40:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711672848; cv=none; b=DUjfjBECpgPHZByhL7DjMGBGQCdITb5UFPG7GxlJiwGOoo5jHQGRlQWEVa23YJNfuoMW9vTNERbdXLG4kLk3trEKsjC1SgvlSS6m2Yx+mO3pt6QF4amD39tElvbYZ0eyLQXXjAJkeRhC6vVb0POsBqGWsgeDNlXOkRBjz0W/LKw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711672848; c=relaxed/simple; bh=iOF5ooHVjmTm3e7N+9rAkLaE53H/GI+M+pLn/x/dElM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WhgzB0Q/7yCJVaWKKA35F0mzBbMIZlJ5kscAi6tWj8troNFaMsqjGwvYVRCVhvcVqAUfy31VIT7kUXMz6eNXVYtLW749JhEmTkr4ceRVLyx1/1fegOhHT389AlCyDojgtJbdNnxcyhQ9ZbUdSOq6EzBK9FS7w4y7pk57/yq9AeU= 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=Kphj1Rg0; arc=none smtp.client-ip=209.85.208.54 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="Kphj1Rg0" Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-56c0d1bddc1so1818538a12.3; Thu, 28 Mar 2024 17:40:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711672845; x=1712277645; 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=9/svIv2C9e15PTWNlhHZar/uQPSIv6vw8UjxI/6w5Ts=; b=Kphj1Rg0yfP5jrYzPIgdxZV8s+uvx+ezFeblQgPly0gODhT0hCseD/JwFt8umtH+ok TX5WYopagF826pTJpM+Gl87cKCJ/4jX3rdxElUMWpb5tqe8T+DDjz4pwjugAM1QbGH5N v4G3UqO2FEMaOkC1u+A58D/CYyAfUEwKdJA2sIYti1rsyE5K230qmhDpZVhukTQVo7wY ZcfF6MvKt5yfEtJISsbby1388WoHvRZ4GBj+Cm4AgebnLMmaPZd3V+2k1mwUa1SjmZ1K MmWH8bQ+QKfgUh+YgmqR91QA+1fzJV6cCM5yitaRfAqYjHsimGGQb5hhs+9SIUHjcntl vmvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711672845; x=1712277645; 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=9/svIv2C9e15PTWNlhHZar/uQPSIv6vw8UjxI/6w5Ts=; b=VohGOgweR+MMsDxfKUxhSH5ZI2qdMm75xVkU/U2NbWR0zRtLp2hRaFFhtpIepPgfAT a9H5l6qGk2kJUpzxAKZPlEKAEZIC1qgy9S2E96vjWowEsZVjvowhwbbPQQotR58QfLLd rblvCpSUxuZg4Bfb74GnmGGcNEB3BbKS5n4TjLk2hn7lNoW+wVHsaA7XV3cXJ02QPjHN mgXCncI0qNphu/MQSxLlJDtUENyRpJL076OKJizuN7HiHne4foKJ0cCPGFfZ17KxKqaA f25M1RnnV1KaNmnNXU0uNwk52g6m1oInYgeASz82+jIOU2QObqwGnD+7p8ncOEf8g3s8 rXRg== X-Forwarded-Encrypted: i=1; AJvYcCV5YpIMIH1m27iOdrYAqC/XIda1oebGtaNj3aXqKdH4hlDgIgTCamqgRl9lkWggqe3QZAb5aa417kEH7OoWzsUcCHlAYo3aIyLqPypsffILmLWOfjQ811fYgJqu3ph+gBHu8iQzboti1A== X-Gm-Message-State: AOJu0YyvmELRt0aPrGErk7oIDKKFiOWItwSsO0kju46Qa58OwPfD0/Su QTcreAldAm3l6XlDx27nvR0fc0JogLsIRL9qhd5H2BMDn4JplddvRxiCRpyjcpw= X-Google-Smtp-Source: AGHT+IFjJ3isLdm6BOegHgDg3syqe14nVS5fl3grTRapiWx4hSObTvmjEDblmElILTh4IvbUKm2vIw== X-Received: by 2002:a05:6402:35ca:b0:56b:b5a1:4685 with SMTP id z10-20020a05640235ca00b0056bb5a14685mr555668edc.27.1711672845138; Thu, 28 Mar 2024 17:40:45 -0700 (PDT) Received: from 13a4f82a8f12.v.cablecom.net (84-72-156-211.dclient.hispeed.ch. [84.72.156.211]) by smtp.gmail.com with ESMTPSA id h7-20020a0564020e0700b00568e3d3337bsm1391679edh.18.2024.03.28.17.40.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 17:40:44 -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 v6 6/7] iio: accel: adxl345: Add comment to probe Date: Fri, 29 Mar 2024 00:40:29 +0000 Message-Id: <20240329004030.16153-7-l.rubusch@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240329004030.16153-1-l.rubusch@gmail.com> References: <20240329004030.16153-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 argument 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 83d7e7d4e..511c27eb3 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 Fri Mar 29 00:40:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lothar Rubusch X-Patchwork-Id: 13609821 Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.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 629312E3E4; Fri, 29 Mar 2024 00:40:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711672850; cv=none; b=oZTUZAXGKHQkKAwmFnruFj4YerZjJdYSvHbiTmWXx7sk/ReM3TwaRecJ1br7HVijNNFcdJtOK2f0iqAfEly4l40xPycEl1o6k9c6YAXR8O/WxOuQx/g3h6WBhr1mI/HnC+D7bmm8qiKj0sujbXQSWREthVwdfkOEmjwyfRsQJZU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711672850; c=relaxed/simple; bh=NSe/liSARxHCFd61SUaS5BJlcIU6UF1iYHqxn3SBHPM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KJhQwF+ZfQLawU7Ut/t4c4J/cNSwY7yP9YOJwuoBNT5FbGvcUQXEzi0Lx27a0kt7rZ8KCxSFTGakEedY1xCqSeSyGNrbfNRkF33UmrzKV/9KwiBdXDRbxIZ9aZUVeGDMDM6BHrc16cgT2WNZeOqK4ushR67fQZLzuhNWI2jPeTQ= 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=GpE4F/GI; arc=none smtp.client-ip=209.85.167.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="GpE4F/GI" Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-51588f70d2dso1751713e87.3; Thu, 28 Mar 2024 17:40:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711672846; x=1712277646; 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=TWDCltR+Y0wCwsz+KfQOWGNlirk4O0tCkzhshtRNMtE=; b=GpE4F/GIVKVKT2AA1MhkrM27AhPnd9KPX1nb/C/GgBjsc84J+E9lbwmBNQ1MJGg8Y2 xQV7Ld+hOl0WhP5ozbG/MHmb9cZWKS3t/X7sNFzHZP4gP1s76dDxnnkA7v9DlHfRbzA1 +Z9woe4IkfXxJ3btnz3uYd/bwp6Exxi5Re8B7NnyZnWndr8EVYFTdQTgyrIHDLjRr2IU 7/JqeIlKjkS/Hf45LTm+YtgU2E9leLDjX8C0BsKZw5SviICyk7WYRaDBQ/CoyygLu2R9 4G2jKsL8G2e8q7F0iisZO4VhKWiHStp4xRc+OT2ehQ3cm1g9eg/o4Wtc8bNASgzzYBDp p3qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711672846; x=1712277646; 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=TWDCltR+Y0wCwsz+KfQOWGNlirk4O0tCkzhshtRNMtE=; b=JEkjHBYXyTuvzmCewOzljMtkvvUtzd08JkpxYha8cVQcjP5MK5Tq6D8aBgb28ttBXD OJA6QlS2BWlSaralPw5gpFcQkynEwr+OzcdAXD11/rC2Sip6ue/zWGYo0kPsT9qecPkA Bc9jm5TpLAPBeEXs0V2r1wVW4mwMEAeI1md7ceBBXr6T+ctTQVnQTbvi2/PqoRn3Xd12 m8yBaZY1yCLtsGTg9PY3sTxoG9UpGLrfV9mNGlRK9+6uChodBf2Zb4lAjuHuFVnmZt8l puXHFPGQzRmG8ryKnV+efyinaGDLNJOKTAZUK9faHDmJRns1j1gnw27Rw3OTixEMWvhz IoVw== X-Forwarded-Encrypted: i=1; AJvYcCVBMCE0mldLmmj4AbMz3HkEgtPg3vep/CW2IBndYA35zJWaKnneq5DhW3wAlpHc3NkFt83lU9X5x6FhoUHAXimwaYMctKlH+yxQDgHj/swSuLBpg2IZ+rJ2SkFq97XIXoqgPtkO7W5KyQ== X-Gm-Message-State: AOJu0YzErxVccGDOMPMVEKlyjHc2nDFQHUO+uQUcy5kGy6f0+SvBdQpU iAwuPIpTOV4WlSiY+0+08sGcusVz0L7uD9+ZA6ztYsodtAmWjhai X-Google-Smtp-Source: AGHT+IFfU522CAsPYJZupOVr0I9Lv9VQDy4tTJgSmd5P8rmRqKVKhe+9Ur+tEMAOoHAMG58D8qPMng== X-Received: by 2002:a05:6512:3e4:b0:515:ccd8:37c2 with SMTP id n4-20020a05651203e400b00515ccd837c2mr542083lfq.44.1711672846487; Thu, 28 Mar 2024 17:40:46 -0700 (PDT) Received: from 13a4f82a8f12.v.cablecom.net (84-72-156-211.dclient.hispeed.ch. [84.72.156.211]) by smtp.gmail.com with ESMTPSA id h7-20020a0564020e0700b00568e3d3337bsm1391679edh.18.2024.03.28.17.40.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 17:40:46 -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 v6 7/7] iio: accel: adxl345: Add spi-3wire option Date: Fri, 29 Mar 2024 00:40:30 +0000 Message-Id: <20240329004030.16153-8-l.rubusch@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240329004030.16153-1-l.rubusch@gmail.com> References: <20240329004030.16153-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 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 e859c01d4..3d5c8719d 100644 --- a/drivers/iio/accel/adxl345.h +++ b/drivers/iio/accel/adxl345.h @@ -31,6 +31,7 @@ #define ADXL345_DATA_FORMAT_RANGE GENMASK(1, 0) /* Set the g range */ #define ADXL345_DATA_FORMAT_JUSTIFY BIT(2) /* Left-justified (MSB) mode */ #define ADXL345_DATA_FORMAT_FULL_RES BIT(3) /* Up to 13-bits resolution */ +#define ADXL345_DATA_FORMAT_SPI_3WIRE BIT(6) /* 3-wire SPI mode */ #define ADXL345_DATA_FORMAT_SELF_TEST BIT(7) /* Enable a self test */ #define ADXL345_DATA_FORMAT_2G 0 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 = {