From patchwork Thu Nov 30 20:13:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 748506 Delivered-To: patch@linaro.org Received: by 2002:adf:e9c2:0:b0:32d:baff:b0ca with SMTP id l2csp1099469wrn; Thu, 30 Nov 2023 12:14:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IHMRiW1NN2qpiPZMe+9bLRKY5WkeVexC8Nc8sSDYp8WVdyQ7gdp1LTBYzzlrGycq9ihBzKg X-Received: by 2002:a17:90b:1c8a:b0:281:5550:ce3d with SMTP id oo10-20020a17090b1c8a00b002815550ce3dmr23483083pjb.31.1701375285981; Thu, 30 Nov 2023 12:14:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701375285; cv=none; d=google.com; s=arc-20160816; b=aHqAbwB1I2VwkGOTDxeJUkFNpYsv2FIAU2tOGpOGht4mhBXtheNM8OoUT45/kc00lG yqrEHp/9tlmTpcIL5JLm5pKR1rW+ATcsllZ60+0VXEXpkegXt7fSNOHCB8qM+G/p1v4z x96Xp8PKLIK4Jk3YwfiHWPA9SNUVQs/tn07qAsm5+s0EGuT8MEKp3C7m6OJi7Aj9fLIf cFZwGocqlpt/hkjvRKQv5ixJTFQ+lHhHKwg/hpp2TgSIW146+P0Gn+w/YQwhgJxO6cnM dYyFNmEGf+KVBq10mjtQ2/+PAeTzfPrkGuDBiKQT5lb9KD/FzJ0e5JMzgo6+hOwrauOc 2ITg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1dQ+OJ+v+4GaZBrUVXfZxpg4MaQ0769sAE8M5OwE8rI=; fh=249O9ROWnprHO+UayzBfuXR6OIgDvHdlAHTtO8OnZEM=; b=izItwmiNKXy7gOXWcU0/1yn1KqZWHLNxwkDOmEKczK5ll/lM1E6wUIOqtWIkcjf6WN haDtS+o9C175tfiOuXKknSuGWcCIqZ6pqDRKCn0j/XY5sB8o98HvP198K76Uk4NI8u1v mUvFnOiSnVppNGceEBG8VMRn1ATm33RyyP9tggT65+CjtwRYHWhbEnCFrAA5WR1oVqic uDsKajU7TBpdOsPBM6ZfNuiccOFZOY9zXpg+laeH/7S9sUpF3d4ozKBH2EGmeFM8y+S1 TeVnD17nQmCGm3jFFvhFdXqEX77HnzFV6hni+XPMB83M12M585L81RHcVXYZc5DT7do/ vCkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=akJOvQpM; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id s8-20020a17090aad8800b0028573fb25c5si1977085pjq.132.2023.11.30.12.14.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:14:45 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=akJOvQpM; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A88F5876C7; Thu, 30 Nov 2023 21:14:00 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="akJOvQpM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BA22087660; Thu, 30 Nov 2023 21:13:58 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ot1-x32f.google.com (mail-ot1-x32f.google.com [IPv6:2607:f8b0:4864:20::32f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 89959875FE for ; Thu, 30 Nov 2023 21:13:56 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=semen.protsenko@linaro.org Received: by mail-ot1-x32f.google.com with SMTP id 46e09a7af769-6d8029dae41so809658a34.0 for ; Thu, 30 Nov 2023 12:13:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701375235; x=1701980035; darn=lists.denx.de; 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=1dQ+OJ+v+4GaZBrUVXfZxpg4MaQ0769sAE8M5OwE8rI=; b=akJOvQpMIyPRdCtafpQfhfYITQlsi/FLO9hDR9ulXeXn7tRPJYu0QlMRhlAW4pRqLp vnSZct+FNorh68VOleU6zCEYiftk2iF9VV4k5I1Jf9cmBRHMmuWxW13RrDK3vQ25sPPk 6bwNTUmLt4ybXqhIjP3aKhbXRGEzmRboZXCSMjZ+rlwirENDgpXkR73TgQVoJdqcx00K 46+3tb9keIKCTb4C4QW+3o4Uy0q/Y28wfD7CFk0+0QFHEaSdtol6nq7cPdxE4I+EoXTA SccZRHq7FzNActZhbFiVqKQF/1M2QJ4OrrChHQXTItjODgEArG53PAz1Hw+kZ/oLu6aq e5/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701375235; x=1701980035; 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=1dQ+OJ+v+4GaZBrUVXfZxpg4MaQ0769sAE8M5OwE8rI=; b=Rf3CkXgNly6LVdJjCV+3BrIFyK1UNJsFByCSdaeNQIqqvh67mQcDCTp/+MvQfsF09s bbJ0QObAbG+LKP7luF+qHkkPdAtCNwfOjeXafQCEGtpGq4VvghAUoFZZjOOkDiCIyJIy KWWOMDhI2c552tl4szCSBVLmGYcrxXv0QcSCT2rKJJE2Mb/PgiIt2y/jCOB+EFnuCWiM QmieKKyo1l2JwZJ2YlSYT+Q0sghY+KafIwClwFmoM+FW2YuQqqz5Bx/pJPl8WjM6dkC1 wHf59FNGm7+zubeyXHo9/csWO9fMVc28svJtppEz8RT+SgBDEmFWJeGhq/hPEo2w0X3n 9xCw== X-Gm-Message-State: AOJu0Yx4r9X6t/sIpOcpxX8hvTRaDrh619Oyy7nD+XSTDqYGR3rbf/YQ b+knJSENz4lz4aoW2DwncWIWeg== X-Received: by 2002:a05:6808:c3:b0:3b8:4021:2b51 with SMTP id t3-20020a05680800c300b003b840212b51mr668590oic.17.1701375235218; Thu, 30 Nov 2023 12:13:55 -0800 (PST) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id dj16-20020a056808419000b003b2e7231faasm289822oib.28.2023.11.30.12.13.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:13:54 -0800 (PST) From: Sam Protsenko To: Minkyu Kang , Tom Rini Cc: Andre Przywara , Simon Glass , u-boot@lists.denx.de Subject: [PATCH 3/7] pinctrl: exynos: Rework pin_to_bank_base() to obtain data by name Date: Thu, 30 Nov 2023 14:13:48 -0600 Message-Id: <20231130201352.6379-4-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231130201352.6379-1-semen.protsenko@linaro.org> References: <20231130201352.6379-1-semen.protsenko@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Rework pin_to_bank_base() function to obtain bank data structure by bank name instead of getting bank base address by pin name, and rename it to get_bank() to reflect this change. This in turn leads to the extraction of parse_pin(), so the caller has to use it before calling get_bank(). No functional change. This is a refactoring commit which prepares pinctrl driver code for handling different sizes of register fields, which will be added next. Signed-off-by: Sam Protsenko --- drivers/pinctrl/exynos/pinctrl-exynos.c | 27 +++++++++++++------------ 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/pinctrl/exynos/pinctrl-exynos.c b/drivers/pinctrl/exynos/pinctrl-exynos.c index 2d194ba0a4b5..d908927135b6 100644 --- a/drivers/pinctrl/exynos/pinctrl-exynos.c +++ b/drivers/pinctrl/exynos/pinctrl-exynos.c @@ -50,17 +50,14 @@ static void parse_pin(const char *pin_name, u32 *pin, char *bank_name) *pin = pin_name[++idx] - '0'; } -/* given a pin-name, return the address of pin config registers */ -static unsigned long pin_to_bank_base(struct udevice *dev, const char *pin_name, - u32 *pin) +/* given a bank name, find out the pin bank structure */ +static const struct samsung_pin_bank_data *get_bank(struct udevice *dev, + const char *bank_name) { struct exynos_pinctrl_priv *priv = dev_get_priv(dev); const struct samsung_pin_ctrl *pin_ctrl_array = priv->pin_ctrl; const struct samsung_pin_bank_data *bank_data; - u32 nr_banks, pin_ctrl_idx = 0, idx = 0, bank_base; - char bank[10]; - - parse_pin(pin_name, pin, bank); + u32 nr_banks, pin_ctrl_idx = 0, idx = 0; /* lookup the pin bank data using the pin bank name */ while (true) { @@ -75,15 +72,13 @@ static unsigned long pin_to_bank_base(struct udevice *dev, const char *pin_name, for (idx = 0; idx < nr_banks; idx++) { debug("pinctrl[%d] bank_data[%d] name is: %s\n", pin_ctrl_idx, idx, bank_data[idx].name); - if (!strcmp(bank, bank_data[idx].name)) { - bank_base = priv->base + bank_data[idx].offset; - break; - } + if (!strcmp(bank_name, bank_data[idx].name)) + return &bank_data[idx]; } pin_ctrl_idx++; } - return bank_base; + return NULL; } /** @@ -93,6 +88,7 @@ static unsigned long pin_to_bank_base(struct udevice *dev, const char *pin_name, */ int exynos_pinctrl_set_state(struct udevice *dev, struct udevice *config) { + struct exynos_pinctrl_priv *priv = dev_get_priv(dev); const void *fdt = gd->fdt_blob; int node = dev_of_offset(config); unsigned int count, idx, pin_num; @@ -113,10 +109,15 @@ int exynos_pinctrl_set_state(struct udevice *dev, struct udevice *config) pindrv = fdtdec_get_int(fdt, node, "samsung,pin-drv", -1); for (idx = 0; idx < count; idx++) { + const struct samsung_pin_bank_data *bank; + char bank_name[10]; + name = fdt_stringlist_get(fdt, node, "samsung,pins", idx, NULL); if (!name) continue; - reg = pin_to_bank_base(dev, name, &pin_num); + parse_pin(name, &pin_num, bank_name); + bank = get_bank(dev, bank_name); + reg = priv->base + bank->offset; if (pinfunc != -1) { value = readl(reg + PIN_CON);