From patchwork Fri Oct 11 14:48:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Renner Berthing X-Patchwork-Id: 834985 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B9DC6184 for ; Fri, 11 Oct 2024 14:48:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.188.122 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728658119; cv=none; b=qPf5TDDCydfUdl2lI1kiijxsUhJcBYxaok1CN0eTfB378eXWZIMpvcw1DX3pnnDwItdbLOLfsY0NXD9h73pVXsaWngTmXEWr6c5XtfBpnRLJIIYrkKSZzkXN2Q2bhoKFEc/E4wB14XxUw4Za42bNQGdyelezhBDMzYa2kD9Pn2Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728658119; c=relaxed/simple; bh=TdKbIqcsYdFeh9DZu1CQupvONBITLkldWhskZ+GPwA4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PvBYWofTbofG0mnETPaoDAhvEZX1bT5JiMh8Tx6k23cZtdwVN3daIA3WGZE8cskmnC1HOsRRU07uqobq+q0EDjLX+aVZbUBrB0660p2yS27xK6uku8sSiL19yFDeDnMmvyq9e6lY4zDQCxIifnWGAyENqVLNB/UG5KQNx3UH3UI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com; spf=pass smtp.mailfrom=canonical.com; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b=a7Cfs+61; arc=none smtp.client-ip=185.125.188.122 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=canonical.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b="a7Cfs+61" Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 92B133FA4F for ; Fri, 11 Oct 2024 14:48:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1728658109; bh=y7+YQmnss41fm/ukNbmPDdCc/cnUksMm9Me8dFSJczY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=a7Cfs+61OriM3ZbHncu3clYO3W6aOzVyobUCobuQwJG69joGspODINDbaXIF5fjPZ J0vpejTUXpXohFE+WmQ1nBf4Q1VCY38Ke3e47xLN3uXHDVWJDKMF62hAcvFIRU+mzc OlrJSouZNE2zIeFBZIekvo30QuldBqVP74HnZMrz8xQ1IGHikMaFskQriWUt1INEce BBKZ9Tjywjf6E8mTqH9tW70jmaZXWO+NiTeiBBx9oIhp1ZEp//bZmZpAvWvRMatY1S 1+Eqa9micvSHrorOVpuzcnknaFCrMsX65/sy7FeP6oIEcwSJhdzTdOyN8NGQ7Kub/V NfiRYNO43UBaQ== Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a99d1730c26so18697766b.0 for ; Fri, 11 Oct 2024 07:48:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728658109; x=1729262909; 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=y7+YQmnss41fm/ukNbmPDdCc/cnUksMm9Me8dFSJczY=; b=RWvul7aqN/E0tZWH/j8bPpeBctNjkpZ5pJfT2VDvPHWsTEpg2njRrrlRQQUBqs211c J0JDQm003FHp1/m5A5aggPDoNsCa/ZFR5HtgdeJBaauLkSGvst5d2ePxHy05sEab0Bls ptJr/pozwO4a7JDuMDnNEGb/V/nxL0qAbESOBnhDK6cJONkJ8OnQZXoQ3hBCRHZg/1pm PStHTOws+1I8ftB3U1IXiseCOYbbgEol/RZ+WWwM0erv/n6C4Ts17PxvcdImRbznMoz5 CQAslcYJe7jrUsxQRMDCbea4v8JEUaeZTW4WT7hutW+MtWdEeKtmVz1US9NLxdDj4gMT tlpQ== X-Forwarded-Encrypted: i=1; AJvYcCVTPXAgjwK+1h2JotpQHd8LKmEkNZ9yJSdEcoRvZg/B3TEnK0RO93VqpPcBAs4y+RkeJylNediHy6Jv@vger.kernel.org X-Gm-Message-State: AOJu0Ywy8gKCNasMnfkkpZBJVV/VC57cAXGPucaJI0cPkePetoO3cT+c mEZCdybdMv/sfKzmTDSzjEjEfRF2PGUqZkdfaKav4XVYc8l2Nj20Tms7mot0BtvYDM5q7/NIX9F vEfNfnOTSJgQzyMyG4P/uZua82RC5ZxoCH7SRE2pDMbPozzS7jm78kULJ7MZw2CLlKh/E6JaDEw A= X-Received: by 2002:a17:907:f796:b0:a99:5cb5:6175 with SMTP id a640c23a62f3a-a99b9436b1dmr254243966b.35.1728658109127; Fri, 11 Oct 2024 07:48:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE1I4NMn4gYPdo3MbVQwrz/uYAefwMxC5m+RAElwaCH4bD85EDqoY9JLmmWjwDhkrc8lxHdRw== X-Received: by 2002:a17:907:f796:b0:a99:5cb5:6175 with SMTP id a640c23a62f3a-a99b9436b1dmr254242066b.35.1728658108783; Fri, 11 Oct 2024 07:48:28 -0700 (PDT) Received: from stitch.. ([194.62.169.86]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a99c0c89bfasm54134666b.162.2024.10.11.07.48.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2024 07:48:28 -0700 (PDT) From: Emil Renner Berthing To: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org Cc: Linus Walleij , Jisheng Zhang , Guo Ren , Fu Wei , Paul Walmsley , Palmer Dabbelt , Thomas Bonnefille Subject: [PATCH v1 1/3] pinctrl: th1520: Fix pinconf return values Date: Fri, 11 Oct 2024 16:48:23 +0200 Message-ID: <20241011144826.381104-2-emil.renner.berthing@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241011144826.381104-1-emil.renner.berthing@canonical.com> References: <20241011144826.381104-1-emil.renner.berthing@canonical.com> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When Drew took over the pinctrl driver he must have changed all the -ENOTSUPP returns into -EOPNOTSUPP. This subtle change was most likely not spotted because it was never mentioned in the changelog of the patchset, but it breaks all the places in the pin control and GPIO frameworks where -ENOTSUPP is expected. Fixes: bed5cd6f8a98 ("pinctrl: Add driver for the T-Head TH1520 SoC") Signed-off-by: Emil Renner Berthing --- drivers/pinctrl/pinctrl-th1520.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/pinctrl/pinctrl-th1520.c b/drivers/pinctrl/pinctrl-th1520.c index c8d2ee6defa7..03326df69668 100644 --- a/drivers/pinctrl/pinctrl-th1520.c +++ b/drivers/pinctrl/pinctrl-th1520.c @@ -591,7 +591,7 @@ static int th1520_pinconf_get(struct pinctrl_dev *pctldev, u32 arg; if ((uintptr_t)desc->drv_data & TH1520_PAD_NO_PADCFG) - return -EOPNOTSUPP; + return -ENOTSUPP; value = readl_relaxed(th1520_padcfg(thp, pin)); value = (value >> th1520_padcfg_shift(pin)) & GENMASK(9, 0); @@ -636,7 +636,7 @@ static int th1520_pinconf_get(struct pinctrl_dev *pctldev, arg = enabled ? 1 : 0; break; default: - return -EOPNOTSUPP; + return -ENOTSUPP; } *config = pinconf_to_config_packed(param, arg); @@ -661,7 +661,7 @@ static int th1520_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin, u16 mask, value; if ((uintptr_t)desc->drv_data & TH1520_PAD_NO_PADCFG) - return -EOPNOTSUPP; + return -ENOTSUPP; mask = 0; value = 0; @@ -676,14 +676,14 @@ static int th1520_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin, break; case PIN_CONFIG_BIAS_PULL_DOWN: if (arg == 0) - return -EOPNOTSUPP; + return -ENOTSUPP; mask |= TH1520_PADCFG_BIAS; value &= ~TH1520_PADCFG_BIAS; value |= TH1520_PADCFG_PE; break; case PIN_CONFIG_BIAS_PULL_UP: if (arg == 0) - return -EOPNOTSUPP; + return -ENOTSUPP; mask |= TH1520_PADCFG_BIAS; value &= ~TH1520_PADCFG_BIAS; if (arg == TH1520_PULL_STRONG_OHM) @@ -718,7 +718,7 @@ static int th1520_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin, value &= ~TH1520_PADCFG_SL; break; default: - return -EOPNOTSUPP; + return -ENOTSUPP; } } From patchwork Fri Oct 11 14:48:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Renner Berthing X-Patchwork-Id: 834984 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A00A4130A7D for ; Fri, 11 Oct 2024 14:48:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.188.123 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728658120; cv=none; b=YDT4IIDkhs1gNFCo7GqQhyemIWT/YJw4epyV0f5cpbN7MPF76NrATYn1CQdlqba6W1lYoRGqUMbKXRU1h5edNCmiDk0hr3qZMj2hSDD9wfnQPZVO4fyYJm0/GppwDBMnGKNF49wlvJCOJWGzeqoR7S8b2ksWh0euai9ykBzxDaI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728658120; c=relaxed/simple; bh=X6LexBBB6VtOhRGYx7Cp48bkQnr5/XCFE+samWsctSk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O8HzJXzsdrvKKEOCkIxMOwQEgGMggJHrHukeYvT9cRI5lh7O92ntD1xGEJ3bpMdYXPIryKrOI4ig4S2cCzuZZDT0FEaZsN7tREHmbhoPGjN2v482035S+9owosLICzPdLSwnwQ/WqO7MRV7g/Y2X4Rj2FfvYX1rRdG3GMW4cCEY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com; spf=pass smtp.mailfrom=canonical.com; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b=n+EEY74D; arc=none smtp.client-ip=185.125.188.123 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=canonical.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b="n+EEY74D" Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 7D83D3F371 for ; Fri, 11 Oct 2024 14:48:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1728658111; bh=edTlAYc3Etm4OL8N3s7LjWMKxX64MYHgvFT+kJvdV7k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=n+EEY74DTohVzCbCXPye0HnxB89O5QvFYUhE8YXNFd0ABpJ991oktURPDIj7otQoK Y9Jf8J8TPkbL5wiUJg21VwvwX2Q22WVl7W+DV8arIQlxiYHAzJpvs1P3s5xM9Z78WY R1o8Tixv0fmgvZ54ftLlexeR/Bu+eNn0uXBbCEUa8WHZHDmgbIssv+S01JOyQhDMqv ghDQrLLFeVIOWjYwdetAmtdZ4COlsnB6SmMPrGf8oxtwzSTy7UevSbUN1H2e7eX0MB eAtqXoJ2ODlOwTCkygJh9YL2WazckRho3HgdZWFDfa8RkPWGt5fsVRVsVOFAC5jdnH ESr0my6fSL6bA== Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a99527bfb14so163807666b.1 for ; Fri, 11 Oct 2024 07:48:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728658111; x=1729262911; 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=edTlAYc3Etm4OL8N3s7LjWMKxX64MYHgvFT+kJvdV7k=; b=NW9jvgzO+Mow8KQ23RJ6S+xUS6gFfWdgQMDL64jy0d2ZITSBCqxeMLVmQAvkcLHfaU mbKLye5zOY1nXh/UkOyWmEFY0zu2aWTXMOV44nxIgp8D9ZPjDzazWs8/SXLHkt3fVg6C 1Ul1J1wZrf/ySvj70tJeEG5DFRZLrudJmoEg3pvfWN+2tTJuXnIOis1sfDqlTv7CFY+v q456FBDlSlDLM3Mbe8Zb03no2JbNn//9T4SBwbgNkDkfRJD41C6mbJiWG/pi9773hvrO pcZ6LxOrJdGMecdUn6go6rjbLnYaQfiC5mrJVvLIWYyMwQCG8WVXo5sS7KftxujxVYzt zdAA== X-Forwarded-Encrypted: i=1; AJvYcCWIDOHX2VhvF1evs+hfGTViO8snZ2IAUD3KDFMznTs76hvZt6R4GK+1uoovZU+a4C9Fsq/2V3gVd26T@vger.kernel.org X-Gm-Message-State: AOJu0YxYw/5mSSQ35QdqDI2Tn+xWPk1w5BNh3bZeMKSSpup4KbH5pIWj 7c+ToNmvr9e7yMyaaZvfftrFmRfUeqHrSlsDFCTv19m5R47/sG9dtXMLJZXntyUeXA4H7UfvNuX HTK0gX9J208SJUveA2J1m8ck+6pFCWBFeZio5TNDdNYMkehbIUPn5y0ksYvaYOWZGYgMuk9yGVx A= X-Received: by 2002:a17:907:e287:b0:a77:b01b:f949 with SMTP id a640c23a62f3a-a99b9583aa5mr263419766b.35.1728658111057; Fri, 11 Oct 2024 07:48:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHkuB7p0e37v0WSrhn4e56VJqCLcOD3kU94S7P3YLvQ43FyUGl3Ul06zTz/mWY0Fzz4R0bA2g== X-Received: by 2002:a17:907:e287:b0:a77:b01b:f949 with SMTP id a640c23a62f3a-a99b9583aa5mr263417766b.35.1728658110680; Fri, 11 Oct 2024 07:48:30 -0700 (PDT) Received: from stitch.. ([194.62.169.86]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a99c0c89bfasm54134666b.162.2024.10.11.07.48.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2024 07:48:30 -0700 (PDT) From: Emil Renner Berthing To: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org Cc: Linus Walleij , Jisheng Zhang , Guo Ren , Fu Wei , Paul Walmsley , Palmer Dabbelt , Thomas Bonnefille Subject: [PATCH v1 2/3] pinctrl: th1520: Update pinmux tables Date: Fri, 11 Oct 2024 16:48:24 +0200 Message-ID: <20241011144826.381104-3-emil.renner.berthing@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241011144826.381104-1-emil.renner.berthing@canonical.com> References: <20241011144826.381104-1-emil.renner.berthing@canonical.com> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When Drew took over the pinctrl driver it seems like he didn't use the git tree I pointed him at and thus missed some important fixes to the tables describing valid pinmux settings. The documentation has a nice overview table of these settings but unfortunately it doesn't fully match the register descriptions, which seem to be the correct version. Fixes: bed5cd6f8a98 ("pinctrl: Add driver for the T-Head TH1520 SoC") Signed-off-by: Emil Renner Berthing --- drivers/pinctrl/pinctrl-th1520.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/pinctrl/pinctrl-th1520.c b/drivers/pinctrl/pinctrl-th1520.c index 03326df69668..8bd40cb2f013 100644 --- a/drivers/pinctrl/pinctrl-th1520.c +++ b/drivers/pinctrl/pinctrl-th1520.c @@ -221,9 +221,9 @@ static const struct pinctrl_pin_desc th1520_group2_pins[] = { TH1520_PAD(15, UART4_RTSN, UART, ____, ____, GPIO, ____, ____, 0), TH1520_PAD(16, UART3_TXD, DBG, UART, ____, GPIO, ____, ____, 0), TH1520_PAD(17, UART3_RXD, DBG, UART, ____, GPIO, ____, ____, 0), - TH1520_PAD(18, GPIO0_18, GPIO, I2C, ____, ____, ____, ____, 0), - TH1520_PAD(19, GPIO0_19, GPIO, I2C, ____, ____, ____, ____, 0), - TH1520_PAD(20, GPIO0_20, GPIO, UART, IR, ____, ____, ____, 0), + TH1520_PAD(18, GPIO0_18, GPIO, I2C, ____, ____, DPU0, DPU1, 0), + TH1520_PAD(19, GPIO0_19, GPIO, I2C, ____, ____, DPU0, DPU1, 0), + TH1520_PAD(20, GPIO0_20, GPIO, UART, IR, ____, DPU0, DPU1, 0), TH1520_PAD(21, GPIO0_21, GPIO, UART, IR, ____, DPU0, DPU1, 0), TH1520_PAD(22, GPIO0_22, GPIO, JTAG, I2C, ____, DPU0, DPU1, 0), TH1520_PAD(23, GPIO0_23, GPIO, JTAG, I2C, ____, DPU0, DPU1, 0), @@ -241,7 +241,7 @@ static const struct pinctrl_pin_desc th1520_group2_pins[] = { TH1520_PAD(35, GPIO1_3, GPIO, JTAG, ____, ____, DPU0, DPU1, 0), TH1520_PAD(36, GPIO1_4, GPIO, JTAG, ____, ____, DPU0, DPU1, 0), TH1520_PAD(37, GPIO1_5, GPIO, ____, ____, ____, DPU0, DPU1, 0), - TH1520_PAD(38, GPIO1_6, GPIO, ____, ____, ____, DPU0, DPU1, 0), + TH1520_PAD(38, GPIO1_6, GPIO, QSPI, ____, ____, DPU0, DPU1, 0), TH1520_PAD(39, GPIO1_7, GPIO, QSPI, ____, ____, DPU0, DPU1, 0), TH1520_PAD(40, GPIO1_8, GPIO, QSPI, ____, ____, DPU0, DPU1, 0), TH1520_PAD(41, GPIO1_9, GPIO, QSPI, ____, ____, DPU0, DPU1, 0), @@ -256,11 +256,11 @@ static const struct pinctrl_pin_desc th1520_group2_pins[] = { TH1520_PAD(50, CLK_OUT_1, BSEL, CLK, ____, GPIO, ____, ____, 0), TH1520_PAD(51, CLK_OUT_2, BSEL, CLK, ____, GPIO, ____, ____, 0), TH1520_PAD(52, CLK_OUT_3, BSEL, CLK, ____, GPIO, ____, ____, 0), - TH1520_PAD(53, GPIO1_21, GPIO, ____, ISP, ____, ____, ____, 0), - TH1520_PAD(54, GPIO1_22, GPIO, ____, ISP, ____, ____, ____, 0), - TH1520_PAD(55, GPIO1_23, GPIO, ____, ISP, ____, ____, ____, 0), - TH1520_PAD(56, GPIO1_24, GPIO, ____, ISP, ____, ____, ____, 0), - TH1520_PAD(57, GPIO1_25, GPIO, ____, ISP, ____, ____, ____, 0), + TH1520_PAD(53, GPIO1_21, JTAG, ____, ISP, GPIO, ____, ____, 0), + TH1520_PAD(54, GPIO1_22, JTAG, ____, ISP, GPIO, ____, ____, 0), + TH1520_PAD(55, GPIO1_23, JTAG, ____, ISP, GPIO, ____, ____, 0), + TH1520_PAD(56, GPIO1_24, JTAG, ____, ISP, GPIO, ____, ____, 0), + TH1520_PAD(57, GPIO1_25, JTAG, ____, ISP, GPIO, ____, ____, 0), TH1520_PAD(58, GPIO1_26, GPIO, ____, ISP, ____, ____, ____, 0), TH1520_PAD(59, GPIO1_27, GPIO, ____, ISP, ____, ____, ____, 0), TH1520_PAD(60, GPIO1_28, GPIO, ____, ISP, ____, ____, ____, 0), From patchwork Fri Oct 11 14:48:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Renner Berthing X-Patchwork-Id: 834730 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2783B18E02D for ; Fri, 11 Oct 2024 14:48:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.188.123 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728658121; cv=none; b=o+zxpBxBRDLOzFm0JKelgiwn7ecW2JT5Q2ODAxzCLnqr0Uxl7X6xQ1q5iPGlYz0qpS8HdtPumtkYRHMTDWzpZ5YQtx2y5xq9WvSuOyauM26ZVuczxT7MdrZI3rhfzf5QEWVB03+WZkwAIDCh89G1yubU+MtyRPvuZU93j86F5SU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728658121; c=relaxed/simple; bh=vCAthdAHVhbrVJ4dzxNhL9OQ38Q3l8lgUPnhH8VC4F0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GK6hifn/C8riU+f5Rq4xBpKU8ioMz/Yy08bTriUNyr9m9T0IF8TkMbFXNKLIcM1EmTih26IuuA9nCwu2JckX61GcgUQxAqkipXn82ZpBLquToSJKg+cYH1CeL0asdm9S2neiWokcfU+iI15sG7seysErcMVIeFfRoN5DnDwo02A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com; spf=pass smtp.mailfrom=canonical.com; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b=efParbGW; arc=none smtp.client-ip=185.125.188.123 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=canonical.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b="efParbGW" Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 63A8F3F741 for ; Fri, 11 Oct 2024 14:48:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1728658113; bh=iqBh7nzoh4RgidcVzY4detvGARn0I3+5VA/OmJU1Iu8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=efParbGWB01VrjoKWpz/zHaR/jKQjfxq8jGGzHc+H2nPhNGpic6Xuk/vzmYkk3qJb xNY0B/ytkO1bePO/rg/gtfE2+yog5n//h0QjeFgtpAovHErreu4MwlD5AyuBRQ+z6O NieG3BSYGXd2+YP7b9UhC5btzNtQ75wbI8AGVPiy8nZM1HgUD1yLs+jNlOgJv+1UW+ wHYPU/UHRw5JsVTaR0plpXBP7+uHhMHRe3EQYFLkl17jcmr1XFRQPNEAh+cC05cB9l D6dMRCveDiTdEOkAWQkFSYL8D9MCPx5Z5IKarXZ8EzudWue6ANhlm65iiWozTqEyCL MDKJanLrW67WQ== Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a99592b5f27so329516966b.1 for ; Fri, 11 Oct 2024 07:48:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728658112; x=1729262912; 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=iqBh7nzoh4RgidcVzY4detvGARn0I3+5VA/OmJU1Iu8=; b=ogZoQpUyevTXtr9N6faVDMwgP2ME2FBaCqcuOi5hXS08gC1rg43LL67lucWa9GS9Ve ayft5pM1GTyZxiMEBzDuH3Gt3STnhELPzAG3pUYCmmfcSdhbFQg2WnUEiL6JGXseJSR/ g32Jl5l2o8a+nJKe2bLDfBCBY1y4NLCI6mA39AzcWZ2SZx5HhnGRNZWMrxyqhvua48P9 8KEKfNvoCfsZK555Frd8vfEDfpViTfMV8Yj6YDYRlxMLJjAxxS/BLEMBO9XItWM1dCjl 1zk1xdKRC6jHj/KwOHr3+g7Vfa8N/bOIca/tDCyBP6I80+lSqGn8MIUEfpX4GxtbfGUG 8QlQ== X-Forwarded-Encrypted: i=1; AJvYcCV2D7zwbapjNbBKwDaOGPEFT+5OGpou7zHXguZ4me2Acj6Tpk2bpXZkXNXk1iPKoyh79zyUTSAPe5ie@vger.kernel.org X-Gm-Message-State: AOJu0Yw+rFHu+LrBL74EJAzdfFDTpeGdaTT8THwQ90SkV8s78xuWbMi1 Rs7YgFk/ItzQclMbcH0OoPpHtrhIPq468vt+hZvQyC/BMmnfDQeWWNVhixFN/l2QRuohUfvbXMZ oGjFjFrBvz6srJ9byRfxKrXfxq34nFBp3TCaHOPoY1MqCqq1vIOTCkKZ5pvoS9IJHVmITdK7gKn hwQ/9tYkA= X-Received: by 2002:a17:906:dc8e:b0:a8a:6bd8:b671 with SMTP id a640c23a62f3a-a99a0eb825dmr782896766b.5.1728658112564; Fri, 11 Oct 2024 07:48:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGjQsLbc6u+mCW6UAgHzZ7I5ogU9vr//qu3BpEYvisyFo1ZiWCcvFSN+KbnXtVt+gsG6NG3Rw== X-Received: by 2002:a17:906:dc8e:b0:a8a:6bd8:b671 with SMTP id a640c23a62f3a-a99a0eb825dmr782893866b.5.1728658112081; Fri, 11 Oct 2024 07:48:32 -0700 (PDT) Received: from stitch.. ([194.62.169.86]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a99c0c89bfasm54134666b.162.2024.10.11.07.48.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2024 07:48:31 -0700 (PDT) From: Emil Renner Berthing To: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org Cc: Linus Walleij , Jisheng Zhang , Guo Ren , Fu Wei , Paul Walmsley , Palmer Dabbelt , Thomas Bonnefille Subject: [PATCH v1 3/3] pinctrl: th1520: Factor out casts Date: Fri, 11 Oct 2024 16:48:25 +0200 Message-ID: <20241011144826.381104-4-emil.renner.berthing@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241011144826.381104-1-emil.renner.berthing@canonical.com> References: <20241011144826.381104-1-emil.renner.berthing@canonical.com> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Limit the casts to get the mux data and flags from the driver data pointer with each pin to two inline functions as requested by Andy during review. Signed-off-by: Emil Renner Berthing Reviewed-by: Drew Fustini --- drivers/pinctrl/pinctrl-th1520.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/drivers/pinctrl/pinctrl-th1520.c b/drivers/pinctrl/pinctrl-th1520.c index 8bd40cb2f013..7474d8da32f9 100644 --- a/drivers/pinctrl/pinctrl-th1520.c +++ b/drivers/pinctrl/pinctrl-th1520.c @@ -152,6 +152,16 @@ static enum th1520_muxtype th1520_muxtype_get(const char *str) (TH1520_MUX_##m0 << 0) | (TH1520_MUX_##m1 << 5) | (TH1520_MUX_##m2 << 10) | \ (TH1520_MUX_##m3 << 15) | (TH1520_MUX_##m4 << 20) | (TH1520_MUX_##m5 << 25)) } +static unsigned long th1520_pad_muxdata(void *drv_data) +{ + return (uintptr_t)drv_data & TH1520_PAD_MUXDATA; +} + +static bool th1520_pad_no_padcfg(void *drv_data) +{ + return (uintptr_t)drv_data & TH1520_PAD_NO_PADCFG; +} + static const struct pinctrl_pin_desc th1520_group1_pins[] = { TH1520_PAD(0, OSC_CLK_IN, ____, ____, ____, ____, ____, ____, TH1520_PAD_NO_PADCFG), TH1520_PAD(1, OSC_CLK_OUT, ____, ____, ____, ____, ____, ____, TH1520_PAD_NO_PADCFG), @@ -590,7 +600,7 @@ static int th1520_pinconf_get(struct pinctrl_dev *pctldev, u32 value; u32 arg; - if ((uintptr_t)desc->drv_data & TH1520_PAD_NO_PADCFG) + if (th1520_pad_no_padcfg(desc->drv_data)) return -ENOTSUPP; value = readl_relaxed(th1520_padcfg(thp, pin)); @@ -660,7 +670,7 @@ static int th1520_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin, unsigned int i; u16 mask, value; - if ((uintptr_t)desc->drv_data & TH1520_PAD_NO_PADCFG) + if (th1520_pad_no_padcfg(desc->drv_data)) return -ENOTSUPP; mask = 0; @@ -793,12 +803,14 @@ static int th1520_pinmux_set_mux(struct pinctrl_dev *pctldev, { struct th1520_pinctrl *thp = pinctrl_dev_get_drvdata(pctldev); const struct function_desc *func = pinmux_generic_get_function(pctldev, fsel); + enum th1520_muxtype muxtype = (uintptr_t)func->data; if (!func) return -EINVAL; + return th1520_pinmux_set(thp, thp->desc.pins[gsel].number, - (uintptr_t)thp->desc.pins[gsel].drv_data & TH1520_PAD_MUXDATA, - (uintptr_t)func->data); + th1520_pad_muxdata(thp->desc.pins[gsel].drv_data), + muxtype); } static int th1520_gpio_request_enable(struct pinctrl_dev *pctldev, @@ -809,7 +821,7 @@ static int th1520_gpio_request_enable(struct pinctrl_dev *pctldev, const struct pin_desc *desc = pin_desc_get(pctldev, offset); return th1520_pinmux_set(thp, offset, - (uintptr_t)desc->drv_data & TH1520_PAD_MUXDATA, + th1520_pad_muxdata(desc->drv_data), TH1520_MUX_GPIO); }