From patchwork Tue Apr 16 16:12:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Bee X-Patchwork-Id: 13632204 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CF2E1C04FFF for ; Tue, 16 Apr 2024 16:13:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=aR1W/kcKoJfv4m/ILMYKA/fKM+l4cbBy7o08GK369hg=; b=DbyILtvkk0LHGH +rBkfJk22f+4CF9JV0PnS0gTCdO1bTbmUUVlZyIASTxKjlmW3ICvr+EXW7NCvXlaHZcCJ/YanQlew 51KPeTfkDS+i8iCziUpBkoTds3FT/eHLoxSMEVeK18MQ54jaICKagqkz6TDmjGv3uSdbbVn8sqhgX puFHVAr2RIrcFJMGzt7yidAMX2962bAPIfUkzHapolAmYgJ9l2d55CgxDQFl7mE2yB2MXKZ1IH3lt 8oU1sA7/AJKqYauQA6devExKai4e5jGqeTtxb+5BT9vdZtFcZYxx3biIi03w4sAbi1Qn/f1l9jh4b 6R0uxYg9cAuaB4NovZTg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwlQh-0000000Cwju-3kcF; Tue, 16 Apr 2024 16:13:08 +0000 Received: from mail-lj1-x22b.google.com ([2a00:1450:4864:20::22b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwlQY-0000000CwcN-0u39; Tue, 16 Apr 2024 16:12:59 +0000 Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2d87660d5c9so46194101fa.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=lists.infradead.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=Ly2BZWYm0IELjGWfIJmr+b2h0+EZw2VQ+3uVv04ZThDm56c1KBFf2yPkV4ixzJ6H9S 4uV+GU6laF2F/mkg43MtjA+2JjHWyitOl55BJq5XD8OeLKbzILZ0J7+3mdd6Lkdz8C71 JkSYUKCeYEzosx1raT/T/x/9tCR7zXrqtUFBsHJw0hzzWERgR7lImro2Qg2bToaKZte0 +jZZg8XcBQaXd9//r1COt4tunOPAJq+86tIP7pY6olVQVCw8RD05s7G7yNOK0uNfC3aS to0V/wdZ4flbUqVSvBJ/xBb/tbu/t5tJJHfE2Fb71W8WkoSbJSuFthh1zfmuG/kiMSG2 WQTw== 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=vciUAqEfWMU7eVT8dpDxlg2sNiBxfL8U2X7lWGjG8wnrWrj+i2qk+VXVpxzo7GB+yI ZSgVJkuT+t53vwhZWUGSolwU97DtNXl0kap7H+VQvjrh+o6ACdEjZ9JHnXHdUcVT0PQ6 tBuzIJf9Ydui4z5Yam9C5cLInHJ3Dm6iShFbWbx5GRTYGcAvsDy29DtOEoWjgSODhSxr /j6dwBAhOdlXCx8TCxVrK4I4Htghx1dtroCsYOQzWDpdZiSYMCz0gnTA0InSXp7HPMhk sKiuolZSosyc5NmF4RatRQQVXm9S5vW0jy++iB3RL6hRODE3nVVqHQDMqCuY1VVITNPM 2Avg== X-Forwarded-Encrypted: i=1; AJvYcCWmMlmoARyJS7jQrA121hbGZhM2DS6a2kqN4596W/FPp0rm5CPg6DIrDIlnR4ttRdLUFHncsP+M982RHNTbqZsV/AytWd8/+3gHPA6HwMg9CMwTP+7cqVv7n/A4Sielbfeq+iYfwFRnnG9ULUasZNExNDiEGdsnD6A= X-Gm-Message-State: AOJu0YzYRuNblCsDWC8ClKYkEF17CLbZYt0z/IrFAV8Ug+zktn+WLz57 3iu3ZwlR5MgCxx//3diPggQn2TqHx16yYZ6+9K1LYn/BW7Owb0A= X-Google-Smtp-Source: AGHT+IGL0AAzW6gi5FMaOnf2+t1zcD1sVS1LK3XSrI0v4R9xqr0sQMPNnWO6PLsnDB2l3FxArGL2wA== 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240416_091258_366903_80C1F796 X-CRM114-Status: GOOD ( 16.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Reviewed-by: Linus Walleij --- 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);