Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp264412pxu; Thu, 22 Oct 2020 23:13:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTI3E1OH+9jg1smnYiFbu0Kc8gtgJk1Wj3vJIXfRqxqbCNzPFyABjq2cQCAb5T/cbAvWuM X-Received: by 2002:a17:906:3641:: with SMTP id r1mr488915ejb.391.1603433605586; Thu, 22 Oct 2020 23:13:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603433605; cv=none; d=google.com; s=arc-20160816; b=vCe5XTPcIj71XxylRK0zoGw2qFfRzn9d5KB/tKRRzDnCjZ4q3HuvVzmOeDVKATpmFu /zgm0JUowW6lC7VgUhKAO/9e85uIY05VATFb41YhePrmjRi4o0l8Wz86dsHCiyebHrpk hNmXcGvTZJbSRva9dgKrkQ6Eg+mHO2srsIvCkvpogviHkJMDPL8LiPFCv4dzOLlG+kch ebZWqqhCLOyPElu+2gxPt2FzBF4vSZEQcxEV9t6AWXFt8QuH2wcStr9MR0WP7U/igT2p G5haeMRPCWrHWgzsj0jO2QMWrstDBQKt2rNp0NWmQKCxi6zsw0bOCy4GrOy2TZeJVcwC Bf1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=u7+jSvOaLzAZNSC8eOCYdnSKtV5PrAVmtADjMlgsaF8=; b=FGqnLd31XKahhBkGdn0aH8Epgrniwc60a9WXhy2H/An30o71glH9UJ072L3qt4DpLC hH5rsEPWbtu4XwbT5SOYeusGRbW8Q1g4sLnxdfz8pkfsCxJKhT5YNjtkSDM/PxxEhB/C CnGRRUuhopC0KmM/qpT67viOWyejFRw50G6VacRWrbirSrSJmf702bAMUH4WfLRONtRz 2yC46FLW1FdO+9HxAcNS1ETwgVjdRF0GqYTj/ivVn8FTFYMASFvuMr9fxcQ3yucKJBdT jmZz+JK5X+C6B/t/e/tpxRl2Oh8raDd3q9UBLwk5iKz99Ac8J7plllfTedAiNE0Iz1z8 Khnw== ARC-Authentication-Results: i=1; mx.google.com; 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 a1si234388ejt.206.2020.10.22.23.13.02; Thu, 22 Oct 2020 23:13:25 -0700 (PDT) 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; 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 S372356AbgJVVfr (ORCPT + 99 others); Thu, 22 Oct 2020 17:35:47 -0400 Received: from alexa-out-sd-02.qualcomm.com ([199.106.114.39]:55827 "EHLO alexa-out-sd-02.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S372340AbgJVVfq (ORCPT ); Thu, 22 Oct 2020 17:35:46 -0400 Received: from unknown (HELO ironmsg01-sd.qualcomm.com) ([10.53.140.141]) by alexa-out-sd-02.qualcomm.com with ESMTP; 22 Oct 2020 14:35:45 -0700 X-QCInternal: smtphost Received: from gurus-linux.qualcomm.com ([10.46.162.81]) by ironmsg01-sd.qualcomm.com with ESMTP; 22 Oct 2020 14:35:45 -0700 Received: by gurus-linux.qualcomm.com (Postfix, from userid 383780) id 4D541193C; Thu, 22 Oct 2020 14:35:45 -0700 (PDT) From: Guru Das Srinagesh To: Mark Brown , Markus Elfring , Lee Jones , Rob Herring Cc: Bjorn Andersson , Greg KH , Guenter Roeck , Joe Perches , Subbaraman Narayanamurthy , David Collins , Anirudh Ghayal , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Guru Das Srinagesh Subject: [PATCH v2 0/3] Add support for Qualcomm MFD PMIC register layout Date: Thu, 22 Oct 2020 14:35:39 -0700 Message-Id: X-Mailer: git-send-email 2.7.4 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Changes from v1: - Fixed YAML errors in dt binding document. This is a follow-up as promised [1] to the earlier attempts [2] [3] to upstream the driver that has been hitherto used to handle IRQs for Qualcomm's PMICs that have multiple on-board peripherals when they are interfaced over the I2C interface. This series is a rewrite of that driver while making use of the regmap-irq framework, which needs some modifications to handle the register layout of Qualcomm's PMICs. This is an RFC because I would like to get feedback on my general approach before submitting as a patch per se. Upon inspection of the regmap-irq framework, it was observed that the downstream driver was essentially replicating the framework's IRQ handling logic (such as adding an IRQ domain, and the interrupt handler thread that reads sub-irqs from a main status register). It was also observed that the framework could not be used as-is because: - Qualcomm's PMIC peripheral register layout does not follow a fixed irq_reg_stride, and - The "IRQ TYPE" configuration register takes one bit per interrupt, which when set configures that interrupt as Edge triggered, and when cleared sets it to Level triggered. - There are two IRQ configuration registers in addition to "IRQ TYPE" that further configure the IRQ type as triggered by rising-edge/level high or alternatively, falling-edge/level low that have no support in the regmap-irq framework currently. This patch series has been tested on an internal platform using PM8008 as a test MFD PMIC chip. PM8008 is a PMIC that contains 7 LDOs, 2 GPIOs, temperature monitoring, and can be interfaced over I2C. Both the framework modifications as well as the chip driver have been submitted here for review. Some details about the specific differences between the framework and QCOM PMICs' register layout are provided below using PM8008 as an example. [PM8008 peripheral register layout] Of all the peripherals in PM8008, only a few need IRQ support. They are laid out at the following base addresses (only four are added at the moment for simplicity): 0x0900, 0x2400, 0xC000, 0xC100 Each peripheral is allocated a uniform size of 0x100 bytes and its IRQs are configured through a set of registers that are located at fixed offsets from the above base addresses, uniformly: Register name Addr regmap-irq equivalent Comment ----------------------------------------------------------------------- INT_RT_STS_OFFSET 0x10 (no equivalent) See #1 below INT_SET_TYPE_OFFSET 0x11 type_base See #2 below INT_POL_HIGH_OFFSET 0x12 (no equivalent) See #3 below INT_POL_LOW_OFFSET 0x13 (no equivalent) See #3 below INT_LATCHED_CLR_OFFSET 0x14 ack_base INT_EN_SET_OFFSET 0x15 unmask_base See #4 below INT_EN_CLR_OFFSET 0x16 mask_base See #4 below INT_LATCHED_STS_OFFSET 0x18 status_base Comments (all registers are one bit per interrupt): 1. INT_RT_STS_OFFSET is not used by the regmap-irq, so it may be ignored. 2. INT_SET_TYPE_OFFSET: 1 for edge trigger, 0 for level trigger. 3. Support needs to be added for writing to INT_POL_HIGH_OFFSET and INT_POL_LOW_OFFSET correctly in the framework. Set to 1 or 0 to enable or disable rising-edge/level high or falling-edge/level low. 4. Even though INT_EN_SET_OFFSET and INT_EN_CLR_OFFSET map to unmask_base and mask_base in the regmap-irq framework conceptually, they are swapped in the chip driver because `unmask_offset` in the framework expects unmask_base to be larger than mask_base numerically. This has to be kept in mind while reviewing the "mfd: Add PM8008 driver" patch below. [Summary of framework changes] The main thrust of the changes is to introduce an array of peripheral offset values, which are to be added to the *_base addresses in order to arrive at the correct register addresses per peripheral. In order to get at the first peripheral's addresses, the first element of this array must be zero. Since there are two new registers (INT_POL_HIGH_OFFSET and INT_POL_LOW_OFFSET), add support for storing the per-peripheral values and also writing to them. These will be used only if peripheral offsets are specified. [1] https://lore.kernel.org/lkml/20200519185757.GA13992@codeaurora.org/ [2] https://lore.kernel.org/lkml/cover.1588037638.git.gurus@codeaurora.org/ [3] https://lore.kernel.org/lkml/cover.1588115326.git.gurus@codeaurora.org/ Guru Das Srinagesh (3): regmap-irq: Add support for peripheral offsets dt-bindings: mfd: Add QCOM PM8008 MFD bindings mfd: Add PM8008 driver .../bindings/mfd/qcom,pm8008-irqchip.yaml | 102 +++++++++++ drivers/base/regmap/regmap-irq.c | 191 ++++++++++++++++---- drivers/mfd/Kconfig | 14 ++ drivers/mfd/Makefile | 1 + drivers/mfd/qcom-pm8008.c | 197 +++++++++++++++++++++ include/linux/regmap.h | 6 + 6 files changed, 477 insertions(+), 34 deletions(-) create mode 100644 Documentation/devicetree/bindings/mfd/qcom,pm8008-irqchip.yaml create mode 100644 drivers/mfd/qcom-pm8008.c -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project