Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp77444lqb; Tue, 16 Apr 2024 09:13:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX+yj/VSyEAesUtGRh1/dGfBAWZbx1hKoyQunxRk2rgS/ggnoZ9M1goDiaYmZx2YZLUOTa8BQGBlqVSdupp7rEv3IFD7In1YMAJFbf6kw== X-Google-Smtp-Source: AGHT+IETp7gd+29Nad9Tg2StxUJg/z9+nRayKUzcrvv7JtDT2SucEiWomfa0uIAwWZUWpcMJOIHu X-Received: by 2002:a50:8754:0:b0:56b:cecb:a4c8 with SMTP id 20-20020a508754000000b0056bcecba4c8mr12381401edv.39.1713284010410; Tue, 16 Apr 2024 09:13:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713284010; cv=pass; d=google.com; s=arc-20160816; b=XxuLr96XsCfwzs43nHm8ltGD3kWRgQlnU7a78M/vUhwYBIN9ehPcurxY7CBLkV+X7a KRd4hZ8WvEd69YIw/CI2sL5CoaMbpLsIeSgvFUqhWJvfdspVB+labmlbUPXdjjB+QS4a Y8ZHo53RJ1WmZqxfyYaIMVwGPwgviGunVa6OLRkCXUmkYAE1GqEtIau+7d8hZC+SguBu CCOGdoND64FYT/cj366j2/I5a6qd+hnxLbN6NqudQU1yuEDtnFTLrsh3OgnNbCZHkZlu KiM76HJwpBN20tfihPSKjB94CGwK/god8+p0O+ZGR5Nh/U+THbv7vpBzsYSZqiftKpxc oUeA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=aUiCR1svhxxRL5lsxc2pQcGa6DHnWjaA4pAZ506382o=; fh=3+93MoHb8RFCLeq9giP/opyIbqpY7kJA100NkS6lIIY=; b=BpsR5mjUBZlkv+ddVlrLAb43OK459mXDw0k2S8dsXIChRPBjHeDK74IWVbdCiHftPZ ptxImX1TNTbrJuR7lbo7xYBD8prOqQgLBFDY/A4RmnHBRISdHoLvYM6GI544fvlqRZjt YPOvWAiFQ+IFCuSEsdt0RUUzA/VKndAgN+n8Ghl74xFdaCrn54w9giO8hD1NnJONZm87 Acc+EeAZ6zi45pO+CjrQW52IXnZIs18XkKXotrYNwmbRFY4Q9dvQQed0RjfELLnMqAON 6+6mcb0eumTlOFlf8kQ+1DVsfp80iBP7REBjNJmYx54tLd/IqoB5ahSXrGsnjk/+wBdN rWnQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ESdD627B; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-147207-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-147207-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a27-20020a509b5b000000b0056715a786ffsi5655217edj.544.2024.04.16.09.13.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 09:13:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-147207-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ESdD627B; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-147207-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-147207-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 266721F22A3F for ; Tue, 16 Apr 2024 16:13:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3E28B133402; Tue, 16 Apr 2024 16:13:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ESdD627B" Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9BD3A131746; Tue, 16 Apr 2024 16:12:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713283979; cv=none; b=pJD8BNaMufP+nu73yuQSBUbaZ5md2x7HsVvFu6kbej+ltJJfqM+PazJIA9txMA4or2TixiOoKWeTfKgig0uVrArluUPY55BkzFiDecxxYd9r6OmdsDs+vmnoi/05Vik2jeNwC9pKqb7shm+VqPzkQMJ6F8CDmclxndkN/tsodeo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713283979; c=relaxed/simple; bh=iN1S4d4yj5HPZX9bvcI3GrCiM7vt6EdgyVF6SuvXuIk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cs0CdpMF5GPsrPf0bCapYqgd2LaEL28r8LTa5Rh8eQ7/DbAAJPv7ZnJ/VssaRVT87C5QEI52uCXOmKVVFTSoQIIxY3thKvCDJO1ATNmLEK/gdEaiSsKX9h0AxOhuhlut4CMmodlB/ntV6ay/o/H6zNeBWDvRSXej4xFuCuq5R+c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ESdD627B; arc=none smtp.client-ip=209.85.208.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2d87660d5c9so46194111fa.2; Tue, 16 Apr 2024 09:12:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713283976; x=1713888776; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aUiCR1svhxxRL5lsxc2pQcGa6DHnWjaA4pAZ506382o=; b=ESdD627BIA8iBfXnX05VgxN0D6lLJSpqGwAm+jbfgivzyZKiGqgxj7tW1YofeRoVpy IwW5DxFTc/GVpKUf7nHN6KYpflG73zpepvOdn1Aq5krSTcrbvZcZKOfKBj4tL/xuVFKy 8vFaajy5Z4ZndymLMPJGJQJUfbKFl3x/lzCUE4bTuR+qkMXkYjmoYWFWLFifNP5xaf3Z 7to/pLgFb5T8TEuG29R/0/N/odB+Sl106t5mLJ+UMYCq8DOF7AfRQD1zECX3tdVRsBeU Xarddcs4jbPB/iYCZfJbU34B7Tw0U72xyYfNzoq2ppvzfiALdVOE29CazrOUOch1b4pb Uu7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713283976; x=1713888776; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aUiCR1svhxxRL5lsxc2pQcGa6DHnWjaA4pAZ506382o=; b=LQlkSdcyR23runyHI14W3gtv1NX643k/qipo6W0Ofhc4yuZfxj+PIlzVKyATsRZshZ xIrq7ZnXGzuZaKtipUOupThxmUDlHVOO93mTKEbxxi0sARQ3ru3esKgVN/Yj90/jPLus EArLwKTP2k0gRRUZ90N+xv+5RlkRwjqvPPyUwGmlENpocGwek2XwLs1WoopTBYLIIhvb 6s+LeGejtC7JPIIFXwC0NWKLNyzwlZzTNJ/Uyzi65FGyFmxAcAdbPxdeewCcyOcw9F+8 mxE6iVzyO/3y8i1wXtKJXRMeQrtNMEk2WtvpUdqfkRmol2iwuY8hsTg21f37PIzR5OHy XF5A== X-Forwarded-Encrypted: i=1; AJvYcCV/fpq4s2vjnI4gxaL2UUKCSZI858o/xJusDY3/+rE6FwRj6UhFz5TggahBZyQOWQO5Qp10Om5b8dxEVCvVUjjsCFHuLAyCu5v5SxiBuQwekNi27sXj0AHaYMarwR64AUITz1aGlhyhpo1SSZa4DH5qj42N3n7lgMAfmElRbu8ieM4ASKU= X-Gm-Message-State: AOJu0Yw1eK+gl6o1kPWQijHxupYRQ668LpXfw0a1wQL//BcWcbPMIP/W M+FU0uRipzidvHd8TDfPlHYUlghZsK8q8FaCeB6UArHQDusPJM4= X-Received: by 2002:a2e:999a:0:b0:2d8:781c:7ba1 with SMTP id w26-20020a2e999a000000b002d8781c7ba1mr9244034lji.7.1713283975689; Tue, 16 Apr 2024 09:12:55 -0700 (PDT) Received: from U4.lan ([91.66.160.190]) by smtp.gmail.com with ESMTPSA id t7-20020adfe447000000b00343eac2acc4sm15350743wrm.111.2024.04.16.09.12.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 09:12:55 -0700 (PDT) From: Alex Bee To: Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heiko Stuebner , Linus Walleij , Liam Girdwood , Mark Brown , Sebastian Reichel Cc: Chris Zhong , Zhang Qing , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Alex Bee Subject: [PATCH v4 3/5] pinctrl: rk805: Add rk816 pinctrl support Date: Tue, 16 Apr 2024 18:12:35 +0200 Message-ID: <20240416161237.2500037-4-knaerzche@gmail.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240416161237.2500037-1-knaerzche@gmail.com> References: <20240416161237.2500037-1-knaerzche@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This adds support for RK816 to the exising rk805 pinctrl driver It has a single pin which can be configured as input from a thermistor (for instance in an attached battery) or as a gpio. Signed-off-by: Alex Bee --- changes since v1: - rename pin-function names according to the updated binding - added missing fun_reg for rk816_gpio_cfgs changes since v2: - aligned pin-function names with binding (dropped "pin_fun"-prefix) drivers/pinctrl/pinctrl-rk805.c | 69 +++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/drivers/pinctrl/pinctrl-rk805.c b/drivers/pinctrl/pinctrl-rk805.c index 56d916f2cee6..c42f1bf93404 100644 --- a/drivers/pinctrl/pinctrl-rk805.c +++ b/drivers/pinctrl/pinctrl-rk805.c @@ -93,6 +93,11 @@ enum rk806_pinmux_option { RK806_PINMUX_FUN5, }; +enum rk816_pinmux_option { + RK816_PINMUX_THERMISTOR, + RK816_PINMUX_GPIO, +}; + enum { RK805_GPIO0, RK805_GPIO1, @@ -104,6 +109,10 @@ enum { RK806_GPIO_DVS3 }; +enum { + RK816_GPIO0, +}; + static const char *const rk805_gpio_groups[] = { "gpio0", "gpio1", @@ -115,6 +124,10 @@ static const char *const rk806_gpio_groups[] = { "gpio_pwrctrl3", }; +static const char *const rk816_gpio_groups[] = { + "gpio0", +}; + /* RK805: 2 output only GPIOs */ static const struct pinctrl_pin_desc rk805_pins_desc[] = { PINCTRL_PIN(RK805_GPIO0, "gpio0"), @@ -128,6 +141,11 @@ static const struct pinctrl_pin_desc rk806_pins_desc[] = { PINCTRL_PIN(RK806_GPIO_DVS3, "gpio_pwrctrl3"), }; +/* RK816 */ +static const struct pinctrl_pin_desc rk816_pins_desc[] = { + PINCTRL_PIN(RK816_GPIO0, "gpio0"), +}; + static const struct rk805_pin_function rk805_pin_functions[] = { { .name = "gpio", @@ -176,6 +194,21 @@ static const struct rk805_pin_function rk806_pin_functions[] = { }, }; +static const struct rk805_pin_function rk816_pin_functions[] = { + { + .name = "gpio", + .groups = rk816_gpio_groups, + .ngroups = ARRAY_SIZE(rk816_gpio_groups), + .mux_option = RK816_PINMUX_GPIO, + }, + { + .name = "thermistor", + .groups = rk816_gpio_groups, + .ngroups = ARRAY_SIZE(rk816_gpio_groups), + .mux_option = RK816_PINMUX_THERMISTOR, + }, +}; + static const struct rk805_pin_group rk805_pin_groups[] = { { .name = "gpio0", @@ -207,6 +240,14 @@ static const struct rk805_pin_group rk806_pin_groups[] = { } }; +static const struct rk805_pin_group rk816_pin_groups[] = { + { + .name = "gpio0", + .pins = { RK816_GPIO0 }, + .npins = 1, + }, +}; + #define RK805_GPIO0_VAL_MSK BIT(0) #define RK805_GPIO1_VAL_MSK BIT(1) @@ -255,6 +296,20 @@ static struct rk805_pin_config rk806_gpio_cfgs[] = { } }; +#define RK816_FUN_MASK BIT(2) +#define RK816_VAL_MASK BIT(3) +#define RK816_DIR_MASK BIT(4) + +static struct rk805_pin_config rk816_gpio_cfgs[] = { + { + .fun_reg = RK818_IO_POL_REG, + .fun_msk = RK816_FUN_MASK, + .reg = RK818_IO_POL_REG, + .val_msk = RK816_VAL_MASK, + .dir_msk = RK816_DIR_MASK, + }, +}; + /* generic gpio chip */ static int rk805_gpio_get(struct gpio_chip *chip, unsigned int offset) { @@ -439,6 +494,8 @@ static int rk805_pinctrl_gpio_request_enable(struct pinctrl_dev *pctldev, return _rk805_pinctrl_set_mux(pctldev, offset, RK805_PINMUX_GPIO); case RK806_ID: return _rk805_pinctrl_set_mux(pctldev, offset, RK806_PINMUX_FUN5); + case RK816_ID: + return _rk805_pinctrl_set_mux(pctldev, offset, RK816_PINMUX_GPIO); } return -ENOTSUPP; @@ -588,6 +645,18 @@ static int rk805_pinctrl_probe(struct platform_device *pdev) pci->pin_cfg = rk806_gpio_cfgs; pci->gpio_chip.ngpio = ARRAY_SIZE(rk806_gpio_cfgs); break; + case RK816_ID: + pci->pins = rk816_pins_desc; + pci->num_pins = ARRAY_SIZE(rk816_pins_desc); + pci->functions = rk816_pin_functions; + pci->num_functions = ARRAY_SIZE(rk816_pin_functions); + pci->groups = rk816_pin_groups; + pci->num_pin_groups = ARRAY_SIZE(rk816_pin_groups); + pci->pinctrl_desc.pins = rk816_pins_desc; + pci->pinctrl_desc.npins = ARRAY_SIZE(rk816_pins_desc); + pci->pin_cfg = rk816_gpio_cfgs; + pci->gpio_chip.ngpio = ARRAY_SIZE(rk816_gpio_cfgs); + break; default: dev_err(&pdev->dev, "unsupported RK805 ID %lu\n", pci->rk808->variant); -- 2.43.2