Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3593069pxb; Mon, 25 Jan 2021 22:42:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJwB1pTWdEWLSO64rCcZP8+/2AkwG1FJ7mg0D1xv6xCL/WEzwioL+lSgco7Khbk7uldzcCJL X-Received: by 2002:a17:906:8410:: with SMTP id n16mr2599074ejx.551.1611643356627; Mon, 25 Jan 2021 22:42:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611643356; cv=none; d=google.com; s=arc-20160816; b=qc96eVUlOaFkryrpfFhOB+aaHM4dJcHqlQmfvI2l6WhCg5/xaZPfwQhawY1PfUSfIU CF/VK/Kzr109vxPBWfH4KLaTe0yvR9A39h3x8f6hpNe1OlRRIpXuOdnUMSgvJ6SFtk8d 4XnukPOgRaFkqlcYvX9SGVoU0Wr+FjB9zf85SabMB2CkfzqITNHCoZU8//6M51p6WySJ MZQPgegjayEfqo5zVLYH0kTab118zyUaqhXTKWM/vrv36JJYgcs91eUBbeXqy46DdDdh TF42aU7bX0zuXIXkcUYiwR9GIMr2ZydIEjTzYzo+enscTP5oQukt4HV8O8TBmN17BTI8 BV/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Vji1Tx5QRSQNLp89Gs6e8lzkkwhzHlemOJyNOLZx/Vs=; b=bWToOxs1sMkO0fl98x/c+YKpylxBen51tzrwgMol6h8FmWZZ1MWcbFgp24fsFx01n3 4Gtdwii78F/955nY6ZLY2cDd5/Ggq715B5KTeaESMbvV7o4CtrexkACHt2wqQpPU0z3z N9pjj4Tvvo+96UQ+CQx1rsc+YO+h0WlURmJ2Jig1TVgPpH5YrXB4zYomyZHKd39C5SEK MtY0WCxa7ajIxG9dzPj1RwB2gjoCIZralOrVz4gwlLcwKWeuLzGaUpXYJXMF2CPx8IU1 /oCrGeZKXZ8DUicVAz6klF8PyUBZuEwgcsGf594mnjwiiDZRAs+RUy0UB1Ow+jG6LBe8 T01w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=C7OKxxXb; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a21si8040356edn.168.2021.01.25.22.42.13; Mon, 25 Jan 2021 22:42:36 -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=pass header.i=@linaro.org header.s=google header.b=C7OKxxXb; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732174AbhAZGi6 (ORCPT + 99 others); Tue, 26 Jan 2021 01:38:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729561AbhAYOfc (ORCPT ); Mon, 25 Jan 2021 09:35:32 -0500 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 231CDC06174A for ; Mon, 25 Jan 2021 06:26:02 -0800 (PST) Received: by mail-wr1-x431.google.com with SMTP id p15so6099796wrq.8 for ; Mon, 25 Jan 2021 06:26:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=Vji1Tx5QRSQNLp89Gs6e8lzkkwhzHlemOJyNOLZx/Vs=; b=C7OKxxXbzwcriXVOqt/vHbQNBqSMpqwjmlk7grSPzIT+mfxg/TvYC8aScaDUGk9ACp gzWErcI9AFx59YsvnMYwSFfJ54l8HWaKF4dBUDNv4WMe8eAPx1q2TLruc8ABW8gF7VcZ kFLUhRkp+NtHywqLT75AhPZOlXonh8UqhAnJAFV/ZHGRkOOb2hnPTZV2NbHg+XjWsxrX sIcgMjZlS4WJrYyTqBMC77lRyI/MEVCqczskgg79ZbERtAuP5kWXsw4BuGs5BhjSiw01 cN8J8ba13f09b7WdFnqjNtXFF3ITRVAlsoVX+OrOWyQCD0uNQ6RI3XK4VuWKeDIvaKn+ Gh+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=Vji1Tx5QRSQNLp89Gs6e8lzkkwhzHlemOJyNOLZx/Vs=; b=CM7SXnEjhF4uQ/VLje89xapKO7H9/yGhHdnv3x/4SKkLR1ac8RLQsOnjmPOdRD0jrG EGC4cv3KM4iPlTl+heedOt/mVyUCqy5LRRjtjzJMpTb3atGkWmN/PG//K8F/HcSpwTn8 dWym+Byv+3CJHF6duCwwEl/6e2Jte0krhqECw1zYNYDY7Ik8IkdklbhKNMKZ8WL5ON3A EhuKtLZtz5fc2KYn6+eQ3DkhneIqgEURgKDKxIRaUyO7FdqfUiwKZNaCp7/C3aD5Wkvq WejDWff9Ar4PXOypGf9x0pAEOUa7JHyHg5hG/J2Ht8xnvFJiBz6td5Sam8MK4E4cpmtE LYoA== X-Gm-Message-State: AOAM533tlAY/hLiKnhR8SHdkGs7TihUz5oH0T4mRj1aqTHwE1c176LZT bJWnbiwX31ZN/8oNmByG/hHivTsxsLH6+eF0 X-Received: by 2002:adf:d206:: with SMTP id j6mr1184505wrh.427.1611584760873; Mon, 25 Jan 2021 06:26:00 -0800 (PST) Received: from dell ([91.110.221.194]) by smtp.gmail.com with ESMTPSA id r15sm23355806wrq.1.2021.01.25.06.25.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Jan 2021 06:26:00 -0800 (PST) Date: Mon, 25 Jan 2021 14:25:58 +0000 From: Lee Jones To: Cristian Ciocaltea Cc: Mark Brown , Rob Herring , Dmitry Torokhov , Sebastian Reichel , Manivannan Sadhasivam , Liam Girdwood , Andreas =?iso-8859-1?Q?F=E4rber?= , Linus Walleij , linux-actions@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-pm@vger.kernel.org Subject: Re: [PATCH v6 3/7] mfd: Add MFD driver for ATC260x PMICs Message-ID: <20210125142558.GA4903@dell> References: <4bc76f9e3dc7204d7f407af6ee61c9f193a789d3.1611165200.git.cristian.ciocaltea@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4bc76f9e3dc7204d7f407af6ee61c9f193a789d3.1611165200.git.cristian.ciocaltea@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 20 Jan 2021, Cristian Ciocaltea wrote: > Add initial support for the Actions Semi ATC260x PMICs which integrates > Audio Codec, Power management, Clock generation and GPIO controller > blocks. > > For the moment this driver only supports Regulator, Poweroff and Onkey > functionalities for the ATC2603C and ATC2609A chip variants. > > Since the PMICs can be accessed using both I2C and SPI buses, the > following driver structure has been adopted: > > -----> atc260x-core.c (Implements core functionalities) > / > ATC260x --------> atc260x-i2c.c (Implements I2C interface) > \ > -----> atc260x-spi.c (Implements SPI interface - TODO) > > Co-developed-by: Manivannan Sadhasivam > Signed-off-by: Manivannan Sadhasivam > Signed-off-by: Cristian Ciocaltea > --- > Changes in v6 - per Lee's feedback: > - Added ATC260X_CHIP_REV_MAX magic number > - Fixed code formattting arround atc260x_i2c_driver initialization > - Replaced dev_init() callback in struct atc260x with a pointer to a new struct > atc260x_init_regs to hold hardware specific registry information > - Added a generic atc260x_dev_init() function and instantiated atc2603c_init_regs > and atc2609a_init_regs > > Changes in v5: > - None > > Changes in v4 - according to Lee's review: > - Replaced 'regmap_add_irq_chip()' with 'devm' counterpart and dropped > 'atc260x_device_remove()' and 'atc260x_i2c_remove()' functions > - Moved kerneldoc sections from prototypes to real functions > - Placed single line entries on one line for mfd_cells[] > - Several other minor changes > > Changes in v3: > - Fixed the issues reported by Lee's kernel test robot: > WARNING: modpost: missing MODULE_LICENSE() in drivers/mfd/atc260x-core.o > >> FATAL: modpost: drivers/mfd/atc260x-i2c: sizeof(struct i2c_device_id)=24 is > not a modulo of the size of section __mod_i2c___device_table=588. > >> Fix definition of struct i2c_device_id in mod_devicetable.h > - Dropped the usage of '.of_compatible' fields in {atc2603c,atc2609a}_mfd_cells[] > - Added 'Co-developed-by' tag in commit message and dropped [cristian: ...] line > > drivers/mfd/Kconfig | 18 ++ > drivers/mfd/Makefile | 3 + > drivers/mfd/atc260x-core.c | 310 +++++++++++++++++++++++++++ > drivers/mfd/atc260x-i2c.c | 64 ++++++ > include/linux/mfd/atc260x/atc2603c.h | 281 ++++++++++++++++++++++++ > include/linux/mfd/atc260x/atc2609a.h | 308 ++++++++++++++++++++++++++ > include/linux/mfd/atc260x/core.h | 58 +++++ > 7 files changed, 1042 insertions(+) > create mode 100644 drivers/mfd/atc260x-core.c > create mode 100644 drivers/mfd/atc260x-i2c.c > create mode 100644 include/linux/mfd/atc260x/atc2603c.h > create mode 100644 include/linux/mfd/atc260x/atc2609a.h > create mode 100644 include/linux/mfd/atc260x/core.h > > diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig > index bdfce7b15621..a27ff2e83e7a 100644 > --- a/drivers/mfd/Kconfig > +++ b/drivers/mfd/Kconfig > @@ -2064,6 +2064,24 @@ config MFD_WCD934X > This driver provides common support WCD934x audio codec and its > associated Pin Controller, Soundwire Controller and Audio codec. > > +config MFD_ATC260X > + tristate > + select MFD_CORE > + select REGMAP > + select REGMAP_IRQ > + > +config MFD_ATC260X_I2C > + tristate "Actions Semi ATC260x PMICs with I2C" > + select MFD_ATC260X > + select REGMAP_I2C > + depends on I2C > + help > + Support for the Actions Semi ATC260x PMICs controlled via I2C. > + > + This driver provides common support for accessing the ATC2603C > + and ATC2609A chip variants, additional drivers must be enabled > + in order to use the functionality of the device. > + > config MFD_KHADAS_MCU > tristate "Support for Khadas System control Microcontroller" > depends on I2C > diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile > index 14fdb188af02..1ea88d2c83b4 100644 > --- a/drivers/mfd/Makefile > +++ b/drivers/mfd/Makefile > @@ -268,3 +268,6 @@ obj-$(CONFIG_MFD_KHADAS_MCU) += khadas-mcu.o > obj-$(CONFIG_SGI_MFD_IOC3) += ioc3.o > obj-$(CONFIG_MFD_SIMPLE_MFD_I2C) += simple-mfd-i2c.o > obj-$(CONFIG_MFD_INTEL_M10_BMC) += intel-m10-bmc.o > + > +obj-$(CONFIG_MFD_ATC260X) += atc260x-core.o > +obj-$(CONFIG_MFD_ATC260X_I2C) += atc260x-i2c.o > diff --git a/drivers/mfd/atc260x-core.c b/drivers/mfd/atc260x-core.c > new file mode 100644 > index 000000000000..7148ff5b05b1 > --- /dev/null > +++ b/drivers/mfd/atc260x-core.c > @@ -0,0 +1,310 @@ > +// SPDX-License-Identifier: GPL-2.0+ > +/* > + * Core support for ATC260x PMICs > + * > + * Copyright (C) 2019 Manivannan Sadhasivam > + * Copyright (C) 2020 Cristian Ciocaltea > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#define ATC260X_CHIP_REV_MAX 31 > + > +struct atc260x_init_regs { > + unsigned int cmu_devrst; > + unsigned int cmu_devrst_ints; > + unsigned int ints_msk; > + unsigned int pad_en; > + unsigned int pad_en_extirq; > +}; > + > +static void regmap_lock_mutex(void *__mutex) > +{ > + struct mutex *mutex = __mutex; > + > + /* > + * Using regmap within an atomic context (e.g. accessing a PMIC when > + * powering system down) is normally allowed only if the regmap type > + * is MMIO and the regcache type is either REGCACHE_NONE or > + * REGCACHE_FLAT. For slow buses like I2C and SPI, the regmap is > + * internally protected by a mutex which is acquired non-atomically. > + * > + * Let's improve this by using a customized locking scheme inspired > + * from I2C atomic transfer. See i2c_in_atomic_xfer_mode() for a > + * starting point. > + */ > + if (system_state > SYSTEM_RUNNING && irqs_disabled()) > + mutex_trylock(mutex); > + else > + mutex_lock(mutex); > +} Would this be useful to anyone else? For my own reference (apply this as-is to your sign-off block): Acked-for-MFD-by: Lee Jones -- Lee Jones [李琼斯] Senior Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog