From patchwork Tue Sep 23 23:30:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 392701 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3D3711400B2 for ; Wed, 24 Sep 2014 09:31:30 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6ED0CA741B; Wed, 24 Sep 2014 01:31:25 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id aSlwYB38zgl8; Wed, 24 Sep 2014 01:31:25 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0799CA742F; Wed, 24 Sep 2014 01:30:50 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0F76DA73F8 for ; Wed, 24 Sep 2014 01:30:42 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AVkhL3wtTXi3 for ; Wed, 24 Sep 2014 01:30:37 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-ie0-f202.google.com (mail-ie0-f202.google.com [209.85.223.202]) by theia.denx.de (Postfix) with ESMTPS id 40A94A741C for ; Wed, 24 Sep 2014 01:30:27 +0200 (CEST) Received: by mail-ie0-f202.google.com with SMTP id tr6so1354326ieb.1 for ; Tue, 23 Sep 2014 16:30:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=W97wpt7/8DXzw48Yx8yoGHG/L+Cl8KN3yH+U+iY6Nfc=; b=TlTJd57eeO3w1RRDOAyiBAf8NIQi2GaBGrW0PM6ClRI9TXNKO974E96rbVPxAFn9LR zFYQKm1P1oLx1OBBYfVUbLrwDXdQcZk4S8cc+Tr46Ky7/grozWBDe7P6SUn7oj6Oi3Qz YWHxj8kcyLMqOhtxluWMqKp9JTyxkfK5xbd2YlIuFWKKLD+J8/x9A+sR1aFIGrJCED7t 7lSpWLb9sZtCCsB7nBa7n8Ku6DtF+/1lTuWtR4sv0gfTMqo2dRk5rt9mHAUrPlYGgjpO /F13xeKCnA9MHoWYfLfs069rwGX/mwwoGoQXpKSyOgsrNykcar4h37e+s4uEYFcIoJud QQZw== X-Gm-Message-State: ALoCoQknxTlQFM6agzPOR0iAI5B/lOvDVkTppAzx0IOdFbapOhkcBOZxbffLoPxK+lu6iyDqnzaa X-Received: by 10.182.28.10 with SMTP id x10mr2565723obg.13.1411515025703; Tue, 23 Sep 2014 16:30:25 -0700 (PDT) Received: from corpmail-nozzle1-2.hot.corp.google.com ([100.108.1.103]) by gmr-mx.google.com with ESMTPS id e24si727083yhe.3.2014.09.23.16.30.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Sep 2014 16:30:25 -0700 (PDT) Received: from kaki.bld.corp.google.com ([172.29.216.32]) by corpmail-nozzle1-2.hot.corp.google.com with ESMTP id SQTihCJB.1; Tue, 23 Sep 2014 16:30:25 -0700 Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id 98EA72210C9; Tue, 23 Sep 2014 17:30:24 -0600 (MDT) From: Simon Glass To: u-boot@lists.denx.de Date: Tue, 23 Sep 2014 17:30:06 -0600 Message-Id: <1411515008-4483-13-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 2.1.0.rc2.206.gedb03e5 In-Reply-To: <1411515008-4483-1-git-send-email-sjg@chromium.org> References: <1411515008-4483-1-git-send-email-sjg@chromium.org> Cc: Stephen Warren , Tom Warren Subject: [U-Boot] [RFC PATCH 12/14] dm: tegra: Don't used named GPIOs in SPL X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de There is little point in supporting this, and it bloats the code. (This may be moved into the uclass before final submission) Signed-off-by: Simon Glass --- drivers/gpio/tegra_gpio.c | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/drivers/gpio/tegra_gpio.c b/drivers/gpio/tegra_gpio.c index 1cc4abb..39852b2 100644 --- a/drivers/gpio/tegra_gpio.c +++ b/drivers/gpio/tegra_gpio.c @@ -37,9 +37,15 @@ struct tegra_gpio_platdata { int base_gpio; /* Port number for this port (0, 1,.., n-1) */ }; +#ifndef CONFIG_SPL_BUILD +#define NAMED_PORTS +#endif + /* Information about each port at run-time */ struct tegra_port_info { +#ifdef NAMED_PORTS char label[TEGRA_GPIOS_PER_PORT][GPIO_NAME_SIZE]; +#endif struct gpio_ctlr_bank *bank; int base_gpio; /* Port number for this port (0, 1,.., n-1) */ }; @@ -132,13 +138,29 @@ static void set_level(unsigned gpio, int high) writel(u, &bank->gpio_out[GPIO_PORT(gpio)]); } +/** + * gpio_is_requested() - check if a GPIO has been requested + * + * @state: Bank to check + * @offset: GPIO offset within bank to check + * @return true if marked as requested, false if not + */ +static inline bool gpio_is_requested(struct tegra_port_info *state, int offset) +{ +#ifdef NAMED_PORTS + return *state->label[offset] != '\0'; +#else + return true; +#endif +} + static int check_reserved(struct udevice *dev, unsigned offset, const char *func) { struct tegra_port_info *state = dev_get_priv(dev); struct gpio_dev_priv *uc_priv = dev->uclass_priv; - if (!*state->label[offset]) { + if (!gpio_is_requested(state, offset)) { printf("tegra_gpio: %s: error: gpio %s%d not reserved\n", func, uc_priv->bank_name, offset); return -EBUSY; @@ -171,12 +193,12 @@ static int tegra_gpio_request(struct udevice *dev, unsigned offset, { struct tegra_port_info *state = dev_get_priv(dev); - if (*state->label[offset]) +#ifdef NAMED_PORTS + if (gpio_is_requested(state, offset)) return -EBUSY; - strncpy(state->label[offset], label, GPIO_NAME_SIZE); state->label[offset][GPIO_NAME_SIZE - 1] = '\0'; - +#endif /* Configure as a GPIO */ set_config(state->base_gpio + offset, 1); @@ -185,13 +207,17 @@ static int tegra_gpio_request(struct udevice *dev, unsigned offset, static int tegra_gpio_free(struct udevice *dev, unsigned offset) { +#ifdef NAMED_PORTS struct tegra_port_info *state = dev_get_priv(dev); +#endif int ret; ret = check_reserved(dev, offset, __func__); if (ret) return ret; +#ifdef NAMED_PORTS state->label[offset][0] = '\0'; +#endif return 0; } @@ -314,7 +340,7 @@ static int tegra_gpio_get_function(struct udevice *dev, unsigned offset) struct tegra_port_info *state = dev_get_priv(dev); int gpio = state->base_gpio + offset; - if (!*state->label[offset]) + if (!gpio_is_requested(state, offset)) return GPIOF_UNUSED; if (!get_config(gpio)) return GPIOF_FUNC; @@ -335,7 +361,11 @@ static int tegra_gpio_get_state(struct udevice *dev, unsigned int offset, int is_gpio; int size; +#ifdef NAMED_PORTS label = state->label[offset]; +#else + label = "?"; +#endif is_gpio = get_config(gpio); /* GPIO, not SFPIO */ size = snprintf(buf, bufsize, "%s%d: ", uc_priv->bank_name ? uc_priv->bank_name : "", offset);