Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp1644392ioo; Sun, 22 May 2022 22:47:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzyGbAJ1mUj1Uzu+e2aMDSjxASMGJlV6DRTWrV/k1/QwWFSxtmaelTLLNPQ1a6X/PlxeuE X-Received: by 2002:a17:90b:1613:b0:1df:23d0:cf75 with SMTP id la19-20020a17090b161300b001df23d0cf75mr24752797pjb.88.1653284859572; Sun, 22 May 2022 22:47:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653284859; cv=none; d=google.com; s=arc-20160816; b=qCWsgx8dj5V7g8LFDidbWKP9rC6kmSr0AXqVpvcPsV5/f1j1FkfXKPuF3Mlrf5N/QL //R260aPykGCHniBBYnHpbHs2e38jUA7KKgFLjpDqH2uCgGcLOQLqAaQwqERlBsA46wn 6zntY2ChqJ6z1wqIK7Xcpw3hcI7E+uhKN2A7GM4/WOK5hS3PkE5z2bQBgeWEH3nfIb7Y FRx8SdR/PbopkLMsGge4cNB6Es9e3whKcSrAJwPSKotGHlacOPLqdv1dZM/TLebDStE3 Rp4CyiVZxhPhppA/vUPIf80I9rQc+F7Y91dBeQNGJ6rB0e7s5Lc7u5Rh8hjcuA3gX0ir fk1A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=eGxcFia+56uzVoruJ6OmLxji9P6kTMXtUnj8BikXIyE=; b=OXfqau4lvxH2I9WGfRd3A/vsiEiYKsjdP3urP8j/c4ZfrbsVbnZcpZpk0C/ngWzKR9 UvHFXehyNlSxaWRhA/yRYX7wZ88kDX4SV4pQUagWPfeaOtDcG3MS7wUt7CUDTiKqh2nR obBx+uxhlmhSYRyhj31JPsUv0lr9UNe9ygpzKrCzVUw9v6s/PQUhzZSfk98RlbWagrPD 7IK29Da3PhCIG3el5PBQPTfahIrK97xlvEXrM19FbdMTR7eOQSU9vLSoW6KDJa/NxKfH fv+liCCKfwjiyNzur4a7GWnikV581kcz3HxA/VFZt75QeOjg8xc1I7b8ACAP+aspudfz B6gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=khSf+r1F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id ng4-20020a17090b1a8400b001e02916daccsi8686818pjb.32.2022.05.22.22.47.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 May 2022 22:47:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=khSf+r1F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 82CACDF99; Sun, 22 May 2022 22:46:20 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352719AbiETSbX (ORCPT + 99 others); Fri, 20 May 2022 14:31:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352678AbiETSa6 (ORCPT ); Fri, 20 May 2022 14:30:58 -0400 Received: from mail-oa1-x32.google.com (mail-oa1-x32.google.com [IPv6:2001:4860:4864:20::32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C662F6339; Fri, 20 May 2022 11:30:55 -0700 (PDT) Received: by mail-oa1-x32.google.com with SMTP id 586e51a60fabf-d39f741ba0so11186025fac.13; Fri, 20 May 2022 11:30:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eGxcFia+56uzVoruJ6OmLxji9P6kTMXtUnj8BikXIyE=; b=khSf+r1Fkqxo8gglY2M/PhmMoJy5KBDJIogypEi7/BHI82vQ6fH58w1bO1V0n26U5j /eySZly75d1mGk1EAA+nInGv5Yvz1NGSqpcdiBOiHyRFXHuznj5Fjk92Tr5t+WlCukcb nXJRFooDU9fLk009z13xqPfRyz88F9hdws3CWctomBk8TGeotImRYAkHFh0Tqa5aeELa 7Sj+HiAiMTU5IW6YoTs9VH1WGAQelTyJpmMAjXlhBjMh3R23ENFL0R2feJy/X0nJDCgC YOiqLt1iKuJzSp8Fr1CtH5qPt2fzNzGNoaF5RibDxVwno3dyVns6W4CXiMAB4to98TMn VMMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eGxcFia+56uzVoruJ6OmLxji9P6kTMXtUnj8BikXIyE=; b=k6B/cLX6e0urXPg4mxzUZURJ1dZLLJb/stX/mEXt/5+/iu0QysxDr9bw9Ge8E4Pwxz YyHrTDn9occhKC4vDrHPZU5lsZoDdkUmLiXeMCyDDJvAqs/tULAdZcqeoQLKhrM+Spqm v1P1WHcRXw5cD3YrKGuRNeNUTnxgAkEek1JJN5bk2hcOo2uX0Ky/awjDeKrIFoec+0jp Y8NI2sdvomfwiLnIp5rrjUowm2URAafh1maICVVLnSx8d5W6pN/KCiQkstAZFXXDaIEi 19TTKFniDOjBciz5MwLx4kXmJSyxU4p03RGddPk6X3ui6TM59gWlpvdVgoVWaFDtCVGL GvSQ== X-Gm-Message-State: AOAM532Lv+rIAAJAC0kvbVJTReKKdVHXZYEZpFktNjZKI0J51TbJolz4 v65BEyatPZfYNq74Qhw78XEDKJ79kqAUEw== X-Received: by 2002:a05:6870:2103:b0:e9:6d65:4abb with SMTP id f3-20020a056870210300b000e96d654abbmr7173626oae.261.1653071454048; Fri, 20 May 2022 11:30:54 -0700 (PDT) Received: from wintermute.localdomain (cpe-76-183-134-35.tx.res.rr.com. [76.183.134.35]) by smtp.gmail.com with ESMTPSA id w12-20020a4ab6cc000000b0035eb4e5a6d0sm1339467ooo.38.2022.05.20.11.30.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 May 2022 11:30:53 -0700 (PDT) From: Chris Morgan To: linux-pm@vger.kernel.org Cc: linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, lee.jones@linaro.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, heiko@sntech.de, sre@kernel.org, jon.lin@rock-chips.com, zyw@rock-chips.com, zhangqing@rock-chips.com, Chris Morgan , Maya Matuszczyk Subject: [RESEND 2/4 v7] mfd: Add Rockchip rk817 battery charger support Date: Fri, 20 May 2022 13:30:35 -0500 Message-Id: <20220520183037.2566-3-macroalpha82@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220520183037.2566-1-macroalpha82@gmail.com> References: <20220520183037.2566-1-macroalpha82@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chris Morgan Add rk817 charger support cell to rk808 mfd driver. Acked-for-mfd-by: Lee Jones Signed-off-by: Chris Morgan Signed-off-by: Maya Matuszczyk --- drivers/mfd/rk808.c | 16 ++++++- include/linux/mfd/rk808.h | 91 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+), 1 deletion(-) diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c index 4142b638e5fa..283a65b64d2c 100644 --- a/drivers/mfd/rk808.c +++ b/drivers/mfd/rk808.c @@ -67,6 +67,10 @@ static bool rk817_is_volatile_reg(struct device *dev, unsigned int reg) case RK817_SECONDS_REG ... RK817_WEEKS_REG: case RK817_RTC_STATUS_REG: case RK817_CODEC_DTOP_LPT_SRST: + case RK817_GAS_GAUGE_ADC_CONFIG0 ... RK817_GAS_GAUGE_CUR_ADC_K0: + case RK817_PMIC_CHRG_STS: + case RK817_PMIC_CHRG_OUT: + case RK817_PMIC_CHRG_IN: case RK817_INT_STS_REG0: case RK817_INT_STS_REG1: case RK817_INT_STS_REG2: @@ -74,7 +78,7 @@ static bool rk817_is_volatile_reg(struct device *dev, unsigned int reg) return true; } - return true; + return false; } static const struct regmap_config rk818_regmap_config = { @@ -127,6 +131,11 @@ static const struct resource rk817_pwrkey_resources[] = { DEFINE_RES_IRQ(RK817_IRQ_PWRON_FALL), }; +static const struct resource rk817_charger_resources[] = { + DEFINE_RES_IRQ(RK817_IRQ_PLUG_IN), + DEFINE_RES_IRQ(RK817_IRQ_PLUG_OUT), +}; + static const struct mfd_cell rk805s[] = { { .name = "rk808-clkout", }, { .name = "rk808-regulator", }, @@ -166,6 +175,11 @@ static const struct mfd_cell rk817s[] = { .resources = &rk817_rtc_resources[0], }, { .name = "rk817-codec",}, + { + .name = "rk817-charger", + .num_resources = ARRAY_SIZE(rk817_charger_resources), + .resources = &rk817_charger_resources[0], + }, }; static const struct mfd_cell rk818s[] = { diff --git a/include/linux/mfd/rk808.h b/include/linux/mfd/rk808.h index 58602032e642..9af1f3105f80 100644 --- a/include/linux/mfd/rk808.h +++ b/include/linux/mfd/rk808.h @@ -519,6 +519,77 @@ enum rk809_reg_id { #define MIC_DIFF_DIS (0x0 << 7) #define MIC_DIFF_EN (0x1 << 7) +/* RK817 Battery Registers */ +#define RK817_GAS_GAUGE_ADC_CONFIG0 0x50 +#define RK817_GG_EN (0x1 << 7) +#define RK817_SYS_VOL_ADC_EN (0x1 << 6) +#define RK817_TS_ADC_EN (0x1 << 5) +#define RK817_USB_VOL_ADC_EN (0x1 << 4) +#define RK817_BAT_VOL_ADC_EN (0x1 << 3) +#define RK817_BAT_CUR_ADC_EN (0x1 << 2) + +#define RK817_GAS_GAUGE_ADC_CONFIG1 0x55 + +#define RK817_VOL_CUR_CALIB_UPD BIT(7) + +#define RK817_GAS_GAUGE_GG_CON 0x56 +#define RK817_GAS_GAUGE_GG_STS 0x57 + +#define RK817_BAT_CON (0x1 << 4) +#define RK817_RELAX_VOL_UPD (0x3 << 2) +#define RK817_RELAX_STS (0x1 << 1) + +#define RK817_GAS_GAUGE_RELAX_THRE_H 0x58 +#define RK817_GAS_GAUGE_RELAX_THRE_L 0x59 +#define RK817_GAS_GAUGE_OCV_THRE_VOL 0x62 +#define RK817_GAS_GAUGE_OCV_VOL_H 0x63 +#define RK817_GAS_GAUGE_OCV_VOL_L 0x64 +#define RK817_GAS_GAUGE_PWRON_VOL_H 0x6b +#define RK817_GAS_GAUGE_PWRON_VOL_L 0x6c +#define RK817_GAS_GAUGE_PWRON_CUR_H 0x6d +#define RK817_GAS_GAUGE_PWRON_CUR_L 0x6e +#define RK817_GAS_GAUGE_OFF_CNT 0x6f +#define RK817_GAS_GAUGE_Q_INIT_H3 0x70 +#define RK817_GAS_GAUGE_Q_INIT_H2 0x71 +#define RK817_GAS_GAUGE_Q_INIT_L1 0x72 +#define RK817_GAS_GAUGE_Q_INIT_L0 0x73 +#define RK817_GAS_GAUGE_Q_PRES_H3 0x74 +#define RK817_GAS_GAUGE_Q_PRES_H2 0x75 +#define RK817_GAS_GAUGE_Q_PRES_L1 0x76 +#define RK817_GAS_GAUGE_Q_PRES_L0 0x77 +#define RK817_GAS_GAUGE_BAT_VOL_H 0x78 +#define RK817_GAS_GAUGE_BAT_VOL_L 0x79 +#define RK817_GAS_GAUGE_BAT_CUR_H 0x7a +#define RK817_GAS_GAUGE_BAT_CUR_L 0x7b +#define RK817_GAS_GAUGE_USB_VOL_H 0x7e +#define RK817_GAS_GAUGE_USB_VOL_L 0x7f +#define RK817_GAS_GAUGE_SYS_VOL_H 0x80 +#define RK817_GAS_GAUGE_SYS_VOL_L 0x81 +#define RK817_GAS_GAUGE_Q_MAX_H3 0x82 +#define RK817_GAS_GAUGE_Q_MAX_H2 0x83 +#define RK817_GAS_GAUGE_Q_MAX_L1 0x84 +#define RK817_GAS_GAUGE_Q_MAX_L0 0x85 +#define RK817_GAS_GAUGE_SLEEP_CON_SAMP_CUR_H 0x8f +#define RK817_GAS_GAUGE_SLEEP_CON_SAMP_CUR_L 0x90 +#define RK817_GAS_GAUGE_CAL_OFFSET_H 0x91 +#define RK817_GAS_GAUGE_CAL_OFFSET_L 0x92 +#define RK817_GAS_GAUGE_VCALIB0_H 0x93 +#define RK817_GAS_GAUGE_VCALIB0_L 0x94 +#define RK817_GAS_GAUGE_VCALIB1_H 0x95 +#define RK817_GAS_GAUGE_VCALIB1_L 0x96 +#define RK817_GAS_GAUGE_IOFFSET_H 0x97 +#define RK817_GAS_GAUGE_IOFFSET_L 0x98 +#define RK817_GAS_GAUGE_BAT_R1 0x9a +#define RK817_GAS_GAUGE_BAT_R2 0x9b +#define RK817_GAS_GAUGE_BAT_R3 0x9c +#define RK817_GAS_GAUGE_DATA0 0x9d +#define RK817_GAS_GAUGE_DATA1 0x9e +#define RK817_GAS_GAUGE_DATA2 0x9f +#define RK817_GAS_GAUGE_DATA3 0xa0 +#define RK817_GAS_GAUGE_DATA4 0xa1 +#define RK817_GAS_GAUGE_DATA5 0xa2 +#define RK817_GAS_GAUGE_CUR_ADC_K0 0xb0 + #define RK817_POWER_EN_REG(i) (0xb1 + (i)) #define RK817_POWER_SLP_EN_REG(i) (0xb5 + (i)) @@ -544,10 +615,30 @@ enum rk809_reg_id { #define RK817_LDO_ON_VSEL_REG(idx) (0xcc + (idx) * 2) #define RK817_BOOST_OTG_CFG (0xde) +#define RK817_PMIC_CHRG_OUT 0xe4 +#define RK817_CHRG_VOL_SEL (0x07 << 4) +#define RK817_CHRG_CUR_SEL (0x07 << 0) + +#define RK817_PMIC_CHRG_IN 0xe5 +#define RK817_USB_VLIM_EN (0x01 << 7) +#define RK817_USB_VLIM_SEL (0x07 << 4) +#define RK817_USB_ILIM_EN (0x01 << 3) +#define RK817_USB_ILIM_SEL (0x07 << 0) +#define RK817_PMIC_CHRG_TERM 0xe6 +#define RK817_CHRG_TERM_ANA_DIG (0x01 << 2) +#define RK817_CHRG_TERM_ANA_SEL (0x03 << 0) +#define RK817_CHRG_EN (0x01 << 6) + +#define RK817_PMIC_CHRG_STS 0xeb +#define RK817_BAT_EXS BIT(7) +#define RK817_CHG_STS (0x07 << 4) + #define RK817_ID_MSB 0xed #define RK817_ID_LSB 0xee #define RK817_SYS_STS 0xf0 +#define RK817_PLUG_IN_STS (0x1 << 6) + #define RK817_SYS_CFG(i) (0xf1 + (i)) #define RK817_ON_SOURCE_REG 0xf5 -- 2.25.1