Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1947825pxf; Sat, 13 Mar 2021 02:53:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJzpAlse8oUFfqt7SoTGnZAUwctzXTaknap3qe+4Qi527rzk40JuMyltfURSMa+N3l1Kc5/E X-Received: by 2002:a17:906:7194:: with SMTP id h20mr13391763ejk.154.1615632825911; Sat, 13 Mar 2021 02:53:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615632825; cv=none; d=google.com; s=arc-20160816; b=dgVI4VsYMPOJd7Jtno3nk5U267aWvZ5mUCco62YhoyK3QK1Kudji1F/VW+1EAONFEp pjEie25PGQjhtcvm4O1+j7kVnvJYDq+jtCKiiVJwH6c9IbGRrlCchwapyGnlod3lrugi 3H7yH+Bi5fWNHrXh1KoGdUMiiYHae1DrQjqoCoX6siE17AZ2QA8n+arsot42CIAv+/hB LM9zZl7muRa+du6OCEqKfk9zZOvyyKM7fiSjo1zI9tpOGhs3cLJw+6vMsUPzFWRAEhZB 6CBM4a/cIxGyCZOmyPLfozMEqR9mhRVLNIFqOrQTxSoGZdpMgm4Fid5FID0HPSsLzdwZ en3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=gpKEqRXdI5yimusJbW3cQ5mfFI2pPCBeX2hVEl8mWdU=; b=EGhZ0O2FYOmH06UpDuwweLg+bIA7PA4+BxDdCgK1kZxys05ne1SBcUzN6E0X6lxoTM /EnLKFo4GLzNHRiPz4ho2onaoXnoUeEOmhZbqf0XS/bmoKw4LzKTXygV9WsybpUFw/3h ZCQ+A+mDjY36PD9Ch6h+Tu8ylFDSqVuAe+zw+3NDStBS0YEb1A+8rqZgt58uaghdqbO5 uht5Pu5jyjzTp3yldgAAa+ntzk6Ejjeg/NyK3j4ZfEwKiDHG6c0n4ldXHJNrDLi9q79r 4LA2zYX7u0pmYJc2gRNbUFGJABJRFnTpTssr0N9QXkqtvwXVyuScWCv9i/ton5KVw3Qw O4SQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kemnade.info header.s=20180802 header.b=Jk13R6qc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id pj10si6191882ejb.348.2021.03.13.02.53.23; Sat, 13 Mar 2021 02:53:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@kemnade.info header.s=20180802 header.b=Jk13R6qc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233715AbhCMKnl (ORCPT + 99 others); Sat, 13 Mar 2021 05:43:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232999AbhCMKnK (ORCPT ); Sat, 13 Mar 2021 05:43:10 -0500 Received: from mail.andi.de1.cc (mail.andi.de1.cc [IPv6:2a01:238:4321:8900:456f:ecd6:43e:202c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 987A9C061574 for ; Sat, 13 Mar 2021 02:43:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kemnade.info; s=20180802; h=Content-Transfer-Encoding:Content-Type: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=gpKEqRXdI5yimusJbW3cQ5mfFI2pPCBeX2hVEl8mWdU=; b=Jk13R6qcc+chAOd7LmRazr5mF8 f/HgLakyR0UMU2iUIs0D1qa7r4gim9DP7FGM23ChNDiwHuERTImnMKJ+N5hnvHkJIlyic7y/giJBI rI/aRybVDZuWidQ8AhRtneX87lAJ3VGurlDufHV/N3derlSYKVRpqzXKcuY5ZPLieEJY=; Received: from p200300ccff380e001a3da2fffebfd33a.dip0.t-ipconnect.de ([2003:cc:ff38:e00:1a3d:a2ff:febf:d33a] helo=aktux) by mail.andi.de1.cc with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1lL1jc-0008Pd-UM; Sat, 13 Mar 2021 11:43:05 +0100 Received: from andi by aktux with local (Exim 4.92) (envelope-from ) id 1lL1jb-0004TF-Ni; Sat, 13 Mar 2021 11:43:03 +0100 From: Andreas Kemnade To: j.neuschaefer@gmx.net, lee.jones@linaro.org, linux-kernel@vger.kernel.org Cc: Andreas Kemnade Subject: [PATCH v3] mfd: ntxec: Support for EC in Tolino Shine 2 HD Date: Sat, 13 Mar 2021 11:42:58 +0100 Message-Id: <20210313104258.17111-1-andreas@kemnade.info> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -1.0 (-) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add the version of the EC in the Tolino Shine 2 HD to the supported versions. It seems not to have an RTC and does not ack data written to it. The vendor kernel happily ignores write errors, using I2C via userspace i2c-set also shows the error. So add a quirk to ignore that error. PWM can be successfully configured despite of that error. Signed-off-by: Andreas Kemnade Reviewed-by: Jonathan Neuschäfer --- Changes in v3: - remove have_rtc variable - rename subdevices again Changes in v2: - more comments about stacking regmap construction - fix accidential line removal - better naming for subdevices drivers/mfd/ntxec.c | 55 ++++++++++++++++++++++++++++++++++++--- include/linux/mfd/ntxec.h | 1 + 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/drivers/mfd/ntxec.c b/drivers/mfd/ntxec.c index 957de2b03529..ab6860ef3e9a 100644 --- a/drivers/mfd/ntxec.c +++ b/drivers/mfd/ntxec.c @@ -96,6 +96,38 @@ static struct notifier_block ntxec_restart_handler = { .priority = 128, }; +static int regmap_ignore_write(void *context, + unsigned int reg, unsigned int val) + +{ + struct regmap *regmap = context; + + regmap_write(regmap, reg, val); + + return 0; +} + +static int regmap_wrap_read(void *context, unsigned int reg, + unsigned int *val) +{ + struct regmap *regmap = context; + + return regmap_read(regmap, reg, val); +} + +/* + * Some firmware versions do not ack written data, add a wrapper. It + * is used to stack another regmap on top. + */ +static const struct regmap_config regmap_config_noack = { + .name = "ntxec_noack", + .reg_bits = 8, + .val_bits = 16, + .cache_type = REGCACHE_NONE, + .reg_write = regmap_ignore_write, + .reg_read = regmap_wrap_read +}; + static const struct regmap_config regmap_config = { .name = "ntxec", .reg_bits = 8, @@ -104,16 +136,22 @@ static const struct regmap_config regmap_config = { .val_format_endian = REGMAP_ENDIAN_BIG, }; -static const struct mfd_cell ntxec_subdevices[] = { +static const struct mfd_cell ntxec_subdev[] = { { .name = "ntxec-rtc" }, { .name = "ntxec-pwm" }, }; +static const struct mfd_cell ntxec_subdev_no_rtc[] = { + { .name = "ntxec-pwm" }, +}; + static int ntxec_probe(struct i2c_client *client) { struct ntxec *ec; unsigned int version; int res; + const struct mfd_cell *subdevs = ntxec_subdev; + size_t n_subdevs = ARRAY_SIZE(ntxec_subdev); ec = devm_kmalloc(&client->dev, sizeof(*ec), GFP_KERNEL); if (!ec) @@ -138,6 +176,16 @@ static int ntxec_probe(struct i2c_client *client) switch (version) { case NTXEC_VERSION_KOBO_AURA: break; + case NTXEC_VERSION_TOLINO_SHINE2: + subdevs = ntxec_subdev_no_rtc; + n_subdevs = ARRAY_SIZE(ntxec_subdev_no_rtc); + /* Another regmap stacked on top of the other */ + ec->regmap = devm_regmap_init(ec->dev, NULL, + ec->regmap, + ®map_config_noack); + if (IS_ERR(ec->regmap)) + return PTR_ERR(ec->regmap); + break; default: dev_err(ec->dev, "Netronix embedded controller version %04x is not supported.\n", @@ -181,8 +229,9 @@ static int ntxec_probe(struct i2c_client *client) i2c_set_clientdata(client, ec); - res = devm_mfd_add_devices(ec->dev, PLATFORM_DEVID_NONE, ntxec_subdevices, - ARRAY_SIZE(ntxec_subdevices), NULL, 0, NULL); + res = devm_mfd_add_devices(ec->dev, PLATFORM_DEVID_NONE, + subdevs, n_subdevs, + NULL, 0, NULL); if (res) dev_err(ec->dev, "Failed to add subdevices: %d\n", res); diff --git a/include/linux/mfd/ntxec.h b/include/linux/mfd/ntxec.h index 361204d125f1..26ab3b8eb612 100644 --- a/include/linux/mfd/ntxec.h +++ b/include/linux/mfd/ntxec.h @@ -33,5 +33,6 @@ static inline __be16 ntxec_reg8(u8 value) /* Known firmware versions */ #define NTXEC_VERSION_KOBO_AURA 0xd726 /* found in Kobo Aura */ +#define NTXEC_VERSION_TOLINO_SHINE2 0xf110 /* found in Tolino Shine 2 HD */ #endif -- 2.29.2