From nobody Wed Jul 1 11:03:03 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB072C433F5 for ; Wed, 22 Dec 2021 18:43:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344843AbhLVSn5 (ORCPT ); Wed, 22 Dec 2021 13:43:57 -0500 Received: from whuk3.redbackinternet.net ([109.203.107.222]:44140 "EHLO whuk3.redbackinternet.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233997AbhLVSn4 (ORCPT ); Wed, 22 Dec 2021 13:43:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=fbautosys.co.uk; s=default; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=oyGWZaDZ/BO5KPkkZ+U0vp6/yJS+5/S7UTBXeEc+Mck=; b=HAxyz79Ly70tfpC7k2fnnBa08T FQiFdOndLjkXHxkHy5LPBuF7eH0hRoq3hm2eT9HtkO7wcskJDnVDWOlD1kO92/XHIcs9WeHtt2s1c RrnTgi+DapdSe65C/10FA8pTf8a3xwYCUaIEI/t/RYYmpcYJXXZHQrnU3BaXM84RkgtvMswWtVWdX 9LD1TMjriof7pQlhltw1IuI8l1EvVdsb73dZ5jQfJX0tnER7NLNzEBpFfqDc3keVIP9VgvUv7E9fq hOVf6W+1w/tkBjycAHkZnlcZ8HayLVhsJDUDEEJFGdVob9nUhpQBWj7NVWXk5/qqiW13Du9Nr0wky lo5K2i1Q==; Received: from 24.54.187.81.in-addr.arpa ([81.187.54.24]:44088 helo=kernelcomp.corp.firebladeautomationsystems.co.uk) by whuk3.redbackinternet.net with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1n06af-000CmX-Bg; Wed, 22 Dec 2021 18:43:55 +0000 From: linuxkernel@fbautosys.co.uk To: linux-kernel@vger.kernel.org Cc: broonie@kernel.org Subject: [RFC PATCH v2 1/5] Add Parity bit Calculation to regmaps Date: Wed, 22 Dec 2021 18:43:36 +0000 Message-Id: <20211222184340.1907240-2-linuxkernel@fbautosys.co.uk> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211222184340.1907240-1-linuxkernel@fbautosys.co.uk> References: <20211222184340.1907240-1-linuxkernel@fbautosys.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - whuk3.redbackinternet.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - fbautosys.co.uk X-Get-Message-Sender-Via: whuk3.redbackinternet.net: authenticated_id: linuxkernel@fbautosys.co.uk X-Authenticated-Sender: whuk3.redbackinternet.net: linuxkernel@fbautosys.co.uk X-Source: X-Source-Args: X-Source-Dir: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Christopher Tyerman regmap.h Added bitmasks "parity_read_mask" and "parity_write_mask" for read and write operations to regmap_config bit mask defines location of the parity bit. Added optional callback "parity_calc" to regmap_config to calculate parity bit value Added regmap_parity_calc_even() and regmap_parity_calc_odd() functions to regmap_config for standard parity calculations. internal.h Added bitmasks "parity_read_mask" and "parity_write_mask" for read and write operations to regmap bit mask defines location of the parity bit. Added optional callback "parity_calc" to regmap to calculate parity bit value Added regmap_parity_calc_even() and regmap_parity_calc_odd() functions to regmap to for standard parity calculations. regmap.c Added parity8(), parity16(), parity32() and parity64() bitwise parity bit calculation functions for different unsigned integer sizes. Added parity_even() parity calculation for unsigned int that uses appropriate parityX fixed size function Added regmap_parity_calc_even() that calculate bool value of even parity bit from read/write mask, reg and val using appropriate combinations of parityX functions Added regmap_parity_calc_odd() that just boolean complement of regmap_parity_calc_even() Altered *__regmap_init to copy parity_read_mask, parity_write_mask and parity_calc to from config to map and assign default regmap_parity_calc_even() to map->parity_calc if map->parity_calc() undefined. Added regmap_set_work_buf_parity_mask() that sets the parity bit in provided workbuf to calculated parity value using assigned map->parity_calc() using rwmask, reg and val for calculation and mask for bit location Altered _regmap_raw_write_impl() to calculate parity by adding call to regmap_set_work_buf_parity_mask() Altered _regmap_raw_read() to calculate parity by adding call to regmap_set_work_buf_parity_mask() modified: drivers/base/regmap/internal.h modified: drivers/base/regmap/regmap.c modified: include/linux/regmap.h Signed-off-by: Christopher Tyerman --- drivers/base/regmap/internal.h | 6 ++ drivers/base/regmap/regmap.c | 168 ++++++++++++++++++++++++++++++++- include/linux/regmap.h | 32 +++++++ 3 files changed, 204 insertions(+), 2 deletions(-) diff --git a/drivers/base/regmap/internal.h b/drivers/base/regmap/internal.h index b1905916f7af..78df50694cf4 100644 --- a/drivers/base/regmap/internal.h +++ b/drivers/base/regmap/internal.h @@ -168,6 +168,12 @@ struct regmap { =20 /* if set, the regmap core can sleep */ bool can_sleep; + + unsigned long parity_write_mask; + unsigned long parity_read_mask; + + bool (*parity_calc)(unsigned long rwmask, unsigned int reg, + const void *val, size_t val_len); }; =20 struct regcache_ops { diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 2d74f9f82aa9..05c104659381 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -57,6 +57,13 @@ static int _regmap_bus_reg_write(void *context, unsigned= int reg, static int _regmap_bus_raw_write(void *context, unsigned int reg, unsigned int val); =20 +static bool parity_even(uint v); + +static bool parity8_even(u8 v); +static bool parity16_even(u16 v); +static bool parity32_even(u32 v); +static bool parity64_even(u64 v); + bool regmap_reg_in_ranges(unsigned int reg, const struct regmap_range *ranges, unsigned int nranges) @@ -892,6 +899,14 @@ struct regmap *__regmap_init(struct device *dev, map->reg_update_bits =3D bus->reg_update_bits; } =20 + map->parity_write_mask =3D config->parity_write_mask; + map->parity_read_mask =3D config->parity_read_mask; + + if (config->parity_calc) + map->parity_calc =3D config->parity_calc; + else + map->parity_calc =3D regmap_parity_calc_even; + reg_endian =3D regmap_get_reg_endian(bus, config); val_endian =3D regmap_get_val_endian(dev, bus, config); =20 @@ -1655,6 +1670,31 @@ static void regmap_set_work_buf_flag_mask(struct reg= map *map, int max_bytes, buf[i] |=3D (mask >> (8 * i)) & 0xff; } =20 +static void regmap_set_work_buf_parity_mask(struct regmap *map, int max_by= tes, + unsigned long mask, unsigned long rwmask, + unsigned int reg, const void *val, size_t val_len) +{ + + bool paritybit; + u8 *buf; + int i; + + if (!mask || !map->work_buf) + return; + + paritybit =3D map->parity_calc(rwmask, reg, val, val_len); + + + if (paritybit) { + buf =3D map->work_buf; + + for (i =3D 0; i < max_bytes; i++) + buf[i] |=3D (mask >> (8 * i)) & 0xff; + } +} + + + static int _regmap_raw_write_impl(struct regmap *map, unsigned int reg, const void *val, size_t val_len, bool noinc) { @@ -1736,7 +1776,12 @@ static int _regmap_raw_write_impl(struct regmap *map= , unsigned int reg, =20 map->format.format_reg(map->work_buf, reg, map->reg_shift); regmap_set_work_buf_flag_mask(map, map->format.reg_bytes, - map->write_flag_mask); + map->write_flag_mask); + + + regmap_set_work_buf_parity_mask(map, map->format.reg_bytes, + map->parity_write_mask, map->write_flag_mask, reg, val, val_len); + =20 /* * Essentially all I/O mechanisms will be faster with a single @@ -1748,6 +1793,9 @@ static int _regmap_raw_write_impl(struct regmap *map,= unsigned int reg, val =3D work_val; } =20 + + + if (map->async && map->bus->async_write) { struct regmap_async *async; =20 @@ -2674,7 +2722,12 @@ static int _regmap_raw_read(struct regmap *map, unsi= gned int reg, void *val, =20 map->format.format_reg(map->work_buf, reg, map->reg_shift); regmap_set_work_buf_flag_mask(map, map->format.reg_bytes, - map->read_flag_mask); + map->read_flag_mask); + + regmap_set_work_buf_parity_mask(map, map->format.reg_bytes, + map->parity_read_mask, map->read_flag_mask, reg, + val, val_len); + trace_regmap_hw_read_start(map, reg, val_len / map->format.val_bytes); =20 ret =3D map->bus->read(map->bus_context, map->work_buf, @@ -3340,3 +3393,114 @@ static int __init regmap_initcall(void) return 0; } postcore_initcall(regmap_initcall); + + +/** + * regmap_parity_calc_even() - calculates Value of parity bit for even par= ity + * + * @rwmask: value of the read/write mask + * @reg: value of register + * @val: pointer to value of data + * @val_len: size of val + * + * Calculate the value of the parity bit for even parity + */ +bool regmap_parity_calc_even(unsigned long rwmask, unsigned int reg, + const void *val, size_t val_len) +{ + bool paritybuf =3D 0; + uint count =3D 0; + + while (count < val_len) { + if (val_len - count >=3D 8) { + paritybuf ^=3D parity64_even(*(u64 *)val+count); + count +=3D 8; + } else if (val_len - count >=3D 4) { + paritybuf ^=3D parity32_even(*(u32 *)val+count); + count +=3D 4; + } else if (val_len - count >=3D 2) { + paritybuf ^=3D parity16_even(*(u16 *)val+count); + count +=3D 2; + } else if (val_len - count >=3D 1) { + paritybuf ^=3D parity8_even(*(u8 *)val+count); + count +=3D 1; + } + } + + return (parity_even(rwmask) ^ parity_even(reg) ^ paritybuf); +} +EXPORT_SYMBOL_GPL(regmap_parity_calc_even); + +/** + * regmap_parity_calc_odd() - calculates Value of parity bit for odd parity + * + * @rwmask: value of the read/write mask + * @reg: value of register + * @val: pointer to value of data + * @val_len: size of val + * + * Calculate the value of the parity bit for odd parity + */ + +bool regmap_parity_calc_odd(unsigned long rwmask, unsigned int reg, + const void *val, size_t val_len) +{ + return !(regmap_parity_calc_even(rwmask, reg, val, val_len)); + + +} +EXPORT_SYMBOL_GPL(regmap_parity_calc_odd); + +static bool parity_even(uint v) +{ + switch (sizeof(v)) { + case 1: + return parity8_even((u8)v); + case 2: + return parity16_even((u16)v); + case 4: + return parity32_even((u32)v); + case 8: + default: + return parity64_even((u64)v); + + } +} +static bool parity8_even(u8 v) +{ + v ^=3D v >> 4; + v ^=3D v >> 2; + v ^=3D v >> 1; + return v & 1; +} + + +static bool parity16_even(u16 v) +{ + v ^=3D v >> 8; + v ^=3D v >> 4; + v ^=3D v >> 2; + v ^=3D v >> 1; + return v & 1; +} + +static bool parity32_even(u32 v) +{ + v ^=3D v >> 16; + v ^=3D v >> 8; + v ^=3D v >> 4; + v ^=3D v >> 2; + v ^=3D v >> 1; + return v & 1; +} + +static bool parity64_even(u64 v) +{ + v ^=3D v >> 32; + v ^=3D v >> 16; + v ^=3D v >> 8; + v ^=3D v >> 4; + v ^=3D v >> 2; + v ^=3D v >> 1; + return v & 1; +} diff --git a/include/linux/regmap.h b/include/linux/regmap.h index 22652e5fbc38..511fc9228e1d 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h @@ -354,6 +354,10 @@ typedef void (*regmap_unlock)(void *); * @hwlock_mode: The hardware spinlock mode, should be HWLOCK_IRQSTATE, * HWLOCK_IRQ or 0. * @can_sleep: Optional, specifies whether regmap operations can sleep. + * + * @parity_read_mask: bit mask of location of parity bit for reads + * @parity_write_mask: bit mask of location of parity bit for writes + * @parity_calc: Optional callback to calculate parity, defaults to even p= arity */ struct regmap_config { const char *name; @@ -416,6 +420,12 @@ struct regmap_config { unsigned int hwlock_mode; =20 bool can_sleep; + + unsigned long parity_read_mask; + unsigned long parity_write_mask; + bool (*parity_calc)(unsigned long rwmask, unsigned int reg, + const void *val, size_t val_len); + }; =20 /** @@ -1237,6 +1247,11 @@ static inline int regmap_clear_bits(struct regmap *m= ap, =20 int regmap_test_bits(struct regmap *map, unsigned int reg, unsigned int bi= ts); =20 +bool regmap_parity_calc_even(unsigned long rwmask, unsigned int reg, + const void *val, size_t val_len); +bool regmap_parity_calc_odd(unsigned long rwmask, unsigned int reg, + const void *val, size_t val_len); + /** * struct reg_field - Description of an register field * @@ -1866,6 +1881,23 @@ static inline struct device *regmap_get_device(struc= t regmap *map) return NULL; } =20 +static inline bool regmap_parity_calc_even(unsigned long rwmask, unsigned = int reg, + const void *val, size_t val_len) +{ + WARN_ONCE(1, "regmap API is disabled"); + return NULL; +} + +static inline bool regmap_parity_calc_odd(unsigned long rwmask, unsigned i= nt reg, + const void *val, size_t val_len) +{ + WARN_ONCE(1, "regmap API is disabled"); + return NULL; +} + + #endif =20 + + #endif --=20 2.25.1 From nobody Wed Jul 1 11:03:03 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4FA23C433EF for ; Wed, 22 Dec 2021 18:44:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344855AbhLVSoA (ORCPT ); Wed, 22 Dec 2021 13:44:00 -0500 Received: from whuk3.redbackinternet.net ([109.203.107.222]:44154 "EHLO whuk3.redbackinternet.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344842AbhLVSn6 (ORCPT ); Wed, 22 Dec 2021 13:43:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=fbautosys.co.uk; s=default; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=uh3/03ZY2B6VFhogjxuEJz3khwd9oGCZ4nLQPSXcWj0=; b=PvW3MfHJRoUYxgH6+ExBrR2VmX VAnC6mD/CfT1WA54WDiWESNe0CbZhQbOAmT06z5F7Mp/CEVtvOsB/dDgkTbxh8GE/mx31M6TU/FLF +hk+ib0B3zdLW86YjoY9dqrRvQHOuu9n9cArJ8W6902kf7Ho9yvdCioSQBTgaluUzfSoRzX8+12wP QutC+SNf//riEybWkyXtgr6/Pzlu/+DhkOrE1oQI6EXWYZ7KE/o1+MOeB5kRroHBZL4QocAukh0My LPw5suYT6xUVmBNPdxV6p1jcupAkH5chLCxZaPdTg0IoRw71YCkiXTp+wGr1hTd4ZCI6Frpdb28qq wvIoktpg==; Received: from 24.54.187.81.in-addr.arpa ([81.187.54.24]:44088 helo=kernelcomp.corp.firebladeautomationsystems.co.uk) by whuk3.redbackinternet.net with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1n06ah-000CmX-8Y; Wed, 22 Dec 2021 18:43:56 +0000 From: linuxkernel@fbautosys.co.uk To: linux-kernel@vger.kernel.org Cc: broonie@kernel.org Subject: [RFC PATCH v2 2/5] Altered regmap_format_X_X_write functions to account for padding bits Date: Wed, 22 Dec 2021 18:43:37 +0000 Message-Id: <20211222184340.1907240-3-linuxkernel@fbautosys.co.uk> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211222184340.1907240-1-linuxkernel@fbautosys.co.uk> References: <20211222184340.1907240-1-linuxkernel@fbautosys.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - whuk3.redbackinternet.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - fbautosys.co.uk X-Get-Message-Sender-Via: whuk3.redbackinternet.net: authenticated_id: linuxkernel@fbautosys.co.uk X-Authenticated-Sender: whuk3.redbackinternet.net: linuxkernel@fbautosys.co.uk X-Source: X-Source-Args: X-Source-Dir: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Christopher Tyerman Altered regmap_format_X_X_write functions to account for padding bits by adjusting reg position shifts by value of map->reg_shift as map->format.format_write is selected based on (config->reg_bits + map->reg_shift) each regmap_format_X_X_write needs to account for map->reg_shift or will be misaligned if padding bits greater than zero modified: drivers/base/regmap/regmap.c Signed-off-by: Christopher Tyerman --- drivers/base/regmap/regmap.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 05c104659381..05c65312a9b3 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -220,9 +220,14 @@ static void regmap_format_12_20_write(struct regmap *m= ap, unsigned int reg, unsigned int val) { u8 *out =3D map->work_buf; + u8 shift =3D map->reg_shift; =20 - out[0] =3D reg >> 4; - out[1] =3D (reg << 4) | (val >> 16); + if (shift <=3D 4) + out[0] =3D reg >> (4 - shift); + else + out[0] =3D reg << (shift - 4); + + out[1] =3D (reg << 4 + shift) | (val >> 16); out[2] =3D val >> 8; out[3] =3D val; } @@ -232,42 +237,52 @@ static void regmap_format_2_6_write(struct regmap *ma= p, unsigned int reg, unsigned int val) { u8 *out =3D map->work_buf; + u8 shift =3D map->reg_shift; =20 - *out =3D (reg << 6) | val; + *out =3D (reg << (6 + shift) | val); } =20 static void regmap_format_4_12_write(struct regmap *map, unsigned int reg, unsigned int val) { + u8 shift =3D map->reg_shift; __be16 *out =3D map->work_buf; - *out =3D cpu_to_be16((reg << 12) | val); + + *out =3D cpu_to_be16((reg << (12 + shift)) | val); } =20 static void regmap_format_7_9_write(struct regmap *map, unsigned int reg, unsigned int val) { + u8 shift =3D map->reg_shift; __be16 *out =3D map->work_buf; - *out =3D cpu_to_be16((reg << 9) | val); + + *out =3D cpu_to_be16((reg << (9 + shift)) | val); } =20 static void regmap_format_7_17_write(struct regmap *map, unsigned int reg, unsigned int val) { + u8 shift =3D map->reg_shift; u8 *out =3D map->work_buf; =20 out[2] =3D val; out[1] =3D val >> 8; - out[0] =3D (val >> 16) | (reg << 1); + out[0] =3D (val >> 16) | (reg << (1 + shift)); } =20 static void regmap_format_10_14_write(struct regmap *map, unsigned int reg, unsigned int val) { + u8 shift =3D map->reg_shift; u8 *out =3D map->work_buf; =20 out[2] =3D val; - out[1] =3D (val >> 8) | (reg << 6); - out[0] =3D reg >> 2; + out[1] =3D (val >> 8) | (reg << (6 + shift)); + if (shift <=3D 2) + out[0] =3D reg >> (2 - shift); + else + out[0] =3D reg << (shift - 2); } =20 static void regmap_format_8(void *buf, unsigned int val, unsigned int shif= t) --=20 2.25.1 From nobody Wed Jul 1 11:03:03 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 009B9C433FE for ; Wed, 22 Dec 2021 18:44:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344865AbhLVSoC (ORCPT ); Wed, 22 Dec 2021 13:44:02 -0500 Received: from whuk3.redbackinternet.net ([109.203.107.222]:44170 "EHLO whuk3.redbackinternet.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344845AbhLVSoA (ORCPT ); Wed, 22 Dec 2021 13:44:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=fbautosys.co.uk; s=default; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=y8vS4bG/Og/65YSvsw5yKNZApWbt4g5SqGst58r76js=; b=go2D0T4j7FSuoscFMthbG+EWWE FKHmxFTTxNawO/FSEoLMU6dx5Qfx2z2c/PeA5LvLbFKv1TFmjcAyLQeLdWjjwoB1Iyb5aLXmeaVMD 3CL6SaS8C4GarC+xYNrMUB6lpKXQf1wvBe7eFfhPzCuQkSIbKW2PPH7+SwltfG4Up78Y+hT3JKWjg JaWxM6hLBRqsKK02FOtzICsvyHtZgIyYX/tzW9pJt9e2THBhVVVJZx8gtOrdLpEq2uQSvk/tYccrC bBEeCz6Du3Xtbf3esOW4iZTdEu0BavkReHnGQX/TeeaDxBnJ6MqwQjRsWGItUuwhCldyH7oaUlz3M u7S2izSQ==; Received: from 24.54.187.81.in-addr.arpa ([81.187.54.24]:44088 helo=kernelcomp.corp.firebladeautomationsystems.co.uk) by whuk3.redbackinternet.net with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1n06ai-000CmX-V0; Wed, 22 Dec 2021 18:43:58 +0000 From: linuxkernel@fbautosys.co.uk To: linux-kernel@vger.kernel.org Cc: broonie@kernel.org Subject: [RFC PATCH v2 3/5] Added setting of writemap to formatted write Date: Wed, 22 Dec 2021 18:43:38 +0000 Message-Id: <20211222184340.1907240-4-linuxkernel@fbautosys.co.uk> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211222184340.1907240-1-linuxkernel@fbautosys.co.uk> References: <20211222184340.1907240-1-linuxkernel@fbautosys.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - whuk3.redbackinternet.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - fbautosys.co.uk X-Get-Message-Sender-Via: whuk3.redbackinternet.net: authenticated_id: linuxkernel@fbautosys.co.uk X-Authenticated-Sender: whuk3.redbackinternet.net: linuxkernel@fbautosys.co.uk X-Source: X-Source-Args: X-Source-Dir: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Christopher Tyerman Added regmap_set_work_buf_flag_mask to _regmap_bus_formatted_write to ensure correct write bit value set when writemask defined modified: drivers/base/regmap/regmap.c Signed-off-by: Christopher Tyerman --- drivers/base/regmap/regmap.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 05c65312a9b3..0761c854ae3b 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -1969,6 +1969,9 @@ static int _regmap_bus_formatted_write(void *context,= unsigned int reg, =20 map->format.format_write(map, reg, val); =20 + regmap_set_work_buf_flag_mask(map, map->format.reg_bytes, + map->write_flag_mask); + trace_regmap_hw_write_start(map, reg, 1); =20 ret =3D map->bus->write(map->bus_context, map->work_buf, --=20 2.25.1 From nobody Wed Jul 1 11:03:03 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E7D4C433F5 for ; Wed, 22 Dec 2021 18:44:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344879AbhLVSoH (ORCPT ); Wed, 22 Dec 2021 13:44:07 -0500 Received: from whuk3.redbackinternet.net ([109.203.107.222]:44186 "EHLO whuk3.redbackinternet.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344859AbhLVSoB (ORCPT ); Wed, 22 Dec 2021 13:44:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=fbautosys.co.uk; s=default; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=x09xcYis5r8NviIr0QhdgLWx6YJAJf8SoqsFoFuULR4=; b=Nn0W0ADty1g9GV97plIyhHc0UJ Z0LhJTtPQrXZod9cEdFj1ROxNwCY+r70X2t1EQS/1Nnuugdo3Tb0xBUOfhgzybo1KMKU1unfwLHOg VG5YRbdm/t89YUTmIRgJo+flfmASpVCnuBUhSuNtXGLGOoKAULCdjjT8A0LOGp+BxDE0oJp0VBUwx wb/LUrtDxRODmv6F/6N/kD3KyzErwSWNuOYJpf/UhAOMavAt4IemcGpetWbY4y35CfOTl+ObM1IRl dINNbXSbVeaMsEG0A/UJf4lqLWN/BP09fxHDkRg3GJq4xgC6um+MSaqKR07oVfUYEofeY8RcLVQbK ApuGmD9A==; Received: from 24.54.187.81.in-addr.arpa ([81.187.54.24]:44088 helo=kernelcomp.corp.firebladeautomationsystems.co.uk) by whuk3.redbackinternet.net with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1n06ak-000CmX-Jc; Wed, 22 Dec 2021 18:44:00 +0000 From: linuxkernel@fbautosys.co.uk To: linux-kernel@vger.kernel.org Cc: broonie@kernel.org Subject: [RFC PATCH v2 4/5] Add Parity Calculation to formatted write Date: Wed, 22 Dec 2021 18:43:39 +0000 Message-Id: <20211222184340.1907240-5-linuxkernel@fbautosys.co.uk> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211222184340.1907240-1-linuxkernel@fbautosys.co.uk> References: <20211222184340.1907240-1-linuxkernel@fbautosys.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - whuk3.redbackinternet.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - fbautosys.co.uk X-Get-Message-Sender-Via: whuk3.redbackinternet.net: authenticated_id: linuxkernel@fbautosys.co.uk X-Authenticated-Sender: whuk3.redbackinternet.net: linuxkernel@fbautosys.co.uk X-Source: X-Source-Args: X-Source-Dir: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Christopher Tyerman Altered formated write to set parity bit according to parity_write_mask modified: drivers/base/regmap/regmap.c Signed-off-by: Christopher Tyerman --- drivers/base/regmap/regmap.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 0761c854ae3b..177f2010a490 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -1972,6 +1972,10 @@ static int _regmap_bus_formatted_write(void *context= , unsigned int reg, regmap_set_work_buf_flag_mask(map, map->format.reg_bytes, map->write_flag_mask); =20 + regmap_set_work_buf_parity_mask(map, map->format.reg_bytes, + map->parity_write_mask, map->write_flag_mask, reg, + &val, sizeof(val)); + trace_regmap_hw_write_start(map, reg, 1); =20 ret =3D map->bus->write(map->bus_context, map->work_buf, --=20 2.25.1 From nobody Wed Jul 1 11:03:03 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1EA8C433F5 for ; Wed, 22 Dec 2021 18:44:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344882AbhLVSoJ (ORCPT ); Wed, 22 Dec 2021 13:44:09 -0500 Received: from whuk3.redbackinternet.net ([109.203.107.222]:44206 "EHLO whuk3.redbackinternet.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344868AbhLVSoD (ORCPT ); Wed, 22 Dec 2021 13:44:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=fbautosys.co.uk; s=default; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=N/tjh8yplC+ohuJ64Uxf0ilzaTYxBP/RdfxkuRoN980=; b=aw5EhYmrdJ02XSGWcp6w9G5dZf d2fkiuCnLCDKdMLtzc7lLjNJ74mfUfMzF7QS6BUB+qrMBkMSD6osWk7pLipBlZPNP6U6RpSqrSEsm 67LaHxHhviuvUCXaEbHDrW9wowV0dKMNvfin+Gs2LpNrrWeseVy88JjzXXZAkPwzFn+EubxcczU66 IR6MhZu9TF+ZQ3Twlv3jTjOaJ9Fmts/Q/tlfx8lDjVihD6UV45C+zCl8hQM2tG8YkqAT0TzHtdt4Q wk1Kqge9wNIPcQvvyeFYJIubE5Bi2WLHKDmDgh5pG8ANmfU3Z7YpE95aMw/+FEkU3q2oeRqw+kxp1 POVpiUww==; Received: from 24.54.187.81.in-addr.arpa ([81.187.54.24]:44088 helo=kernelcomp.corp.firebladeautomationsystems.co.uk) by whuk3.redbackinternet.net with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1n06am-000CmX-8x; Wed, 22 Dec 2021 18:44:01 +0000 From: linuxkernel@fbautosys.co.uk To: linux-kernel@vger.kernel.org Cc: broonie@kernel.org Subject: [RFC PATCH v2 5/5] Add parser for X_9 formats Date: Wed, 22 Dec 2021 18:43:40 +0000 Message-Id: <20211222184340.1907240-6-linuxkernel@fbautosys.co.uk> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211222184340.1907240-1-linuxkernel@fbautosys.co.uk> References: <20211222184340.1907240-1-linuxkernel@fbautosys.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - whuk3.redbackinternet.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - fbautosys.co.uk X-Get-Message-Sender-Via: whuk3.redbackinternet.net: authenticated_id: linuxkernel@fbautosys.co.uk X-Authenticated-Sender: whuk3.redbackinternet.net: linuxkernel@fbautosys.co.uk X-Source: X-Source-Args: X-Source-Dir: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Christopher Tyerman added 9 bit Parser functions these operate in same way as 16 bit parsers but mask out higher bits regmap_parse_9_be() regmap_parse_9_be_inplace() regmap_parse_9_le() regmap_parse_9_le_inplace() regmap_parse_9_native() modified: drivers/base/regmap/regmap.c Signed-off-by: Christopher Tyerman --- drivers/base/regmap/regmap.c | 53 ++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 177f2010a490..40579975209a 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -370,6 +370,39 @@ static unsigned int regmap_parse_8(const void *buf) return b[0]; } =20 +static unsigned int regmap_parse_9_be(const void *buf) +{ + return get_unaligned_be16(buf) & 0x1FF; +} + +static unsigned int regmap_parse_9_le(const void *buf) +{ + + return get_unaligned_le16(buf) & 0x1FF; +} + +static void regmap_parse_9_be_inplace(void *buf) +{ + u16 v =3D get_unaligned_be16(buf) & 0x1FF; + + memcpy(buf, &v, sizeof(v)); +} + +static void regmap_parse_9_le_inplace(void *buf) +{ + u16 v =3D get_unaligned_le16(buf) & 0x1FF; + + memcpy(buf, &v, sizeof(v)); +} + +static unsigned int regmap_parse_9_native(const void *buf) +{ + u16 v; + + memcpy(&v, buf, sizeof(v)); + return v & 0x1FF; +} + static unsigned int regmap_parse_16_be(const void *buf) { return get_unaligned_be16(buf); @@ -1052,6 +1085,26 @@ struct regmap *__regmap_init(struct device *dev, map->format.parse_val =3D regmap_parse_8; map->format.parse_inplace =3D regmap_parse_inplace_noop; break; + case 9: + switch (val_endian) { + case REGMAP_ENDIAN_BIG: + //map->format.format_val =3D regmap_format_9_be; + map->format.parse_val =3D regmap_parse_9_be; + map->format.parse_inplace =3D regmap_parse_9_be_inplace; + break; + case REGMAP_ENDIAN_LITTLE: + //map->format.format_val =3D regmap_format_9_le; + map->format.parse_val =3D regmap_parse_9_le; + map->format.parse_inplace =3D regmap_parse_9_le_inplace; + break; + case REGMAP_ENDIAN_NATIVE: + //map->format.format_val =3D regmap_format_9_native; + map->format.parse_val =3D regmap_parse_9_native; + break; + default: + goto err_hwlock; + } + break; case 16: switch (val_endian) { case REGMAP_ENDIAN_BIG: --=20 2.25.1