From patchwork Thu Aug 13 02:09:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 506817 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 E15D71401B5 for ; Thu, 13 Aug 2015 12:11:23 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b=FL5Q84L5; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B559A4B6A9; Thu, 13 Aug 2015 04:11:04 +0200 (CEST) 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 K9V30NlqdrIz; Thu, 13 Aug 2015 04:11:04 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id ED65E4B698; Thu, 13 Aug 2015 04:10:30 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2F7F34B65D for ; Thu, 13 Aug 2015 04:10:12 +0200 (CEST) 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 YPuo9tgljNIB for ; Thu, 13 Aug 2015 04:10:12 +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-ig0-f169.google.com (mail-ig0-f169.google.com [209.85.213.169]) by theia.denx.de (Postfix) with ESMTPS id 41EDB4B676 for ; Thu, 13 Aug 2015 04:10:10 +0200 (CEST) Received: by igbjg10 with SMTP id jg10so55041847igb.0 for ; Wed, 12 Aug 2015 19:10:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=ntM/U8h5JRy9ep//sPykHWL9PSo8SDQV61moJJGkgn4=; b=FL5Q84L5thgJ/rgVMNdya55hZJ7OjmUzOKYr/7dzlK3HdUbQ2JVYdBUzngKJxh+mgU aaHNbm+Z9CtFSEcNJAB1N/nmeU1a5XvzHOPMF/6w/H1jV6lR3JpwsJBK4Vvx0zYZ4AdQ guPEALtdNk+R+V9KFriqyMi5uyqOdrkdBvxBZ7ws+y3UZwGNnuxnFUxHWzwOsrPm4rhf EPjSR8J/BEuy9ZlKhbhAIydlBHHgXFswCqCxwVct5gSKEIU+mSGIzE+WUeS0BVzhRw8Q hugv2eEzN8oQytWivrWbOdP3Tuw5SxcXMGfsXm9EAMF6PNDSIg3b0hW+Jmf5GDsisCka gmMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=ntM/U8h5JRy9ep//sPykHWL9PSo8SDQV61moJJGkgn4=; b=ULKduEPjhEgoTR5S5AD94kPghEtfgDBvWbK4wt0+0RM7eZiQvfUB6bTcOQA5glbEhC QQApAch+gk0iFi97K2Jq6s/23iKjyKtpGN8w7K765ViuV45XabqSHXZZZ8eEWy3D9OZF bTiL4+JnUaLRPGJQyKJDnTH5CB+5WYgL77hUcj8lnLz9nKAvfkN/7bA46vbeCs6e/tzF QaDQ9m8cq2ft7nPqqu8dEGRyw93au1coQsSKUpyrtGln0DyJi4vYUz4OuAMsCSe4PPsO Ts2+CmWb53FakB6AIp5beWiR6zZ1PMjgfMpID9kyQL7A7WV2UT27KxtdovqGhkC+wRko yDfA== X-Gm-Message-State: ALoCoQmj7dVXpS733D4jSfF+GjRGc5h+kch+qVCDXC8J3cLyEYKRx4tKmoCj38tErmtTZJUZFX7F X-Received: by 10.50.117.98 with SMTP id kd2mr775459igb.78.1439431809198; Wed, 12 Aug 2015 19:10:09 -0700 (PDT) Received: from kaki.bld.corp.google.com ([172.29.216.32]) by smtp.gmail.com with ESMTPSA id z6sm558577ign.12.2015.08.12.19.10.05 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Aug 2015 19:10:06 -0700 (PDT) Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id F2D872211E2; Wed, 12 Aug 2015 20:10:03 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Wed, 12 Aug 2015 20:09:39 -0600 Message-Id: <1439431779-16857-11-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 2.5.0.276.gf5e568e In-Reply-To: <1439431779-16857-1-git-send-email-sjg@chromium.org> References: <1439431779-16857-1-git-send-email-sjg@chromium.org> Cc: Tom Rini , Axel Lin , Graeme Russ , Gabriel Huau , Andrew Bradford Subject: [U-Boot] [PATCH 10/10] WIP: x86: gpio: Make sure that output GPIOs can be read X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The datasheet suggests that the state of an output pin can be read. In fact this does not seem to work, perhaps because we are also accessing the GPIO state through I/O instead of just memory-mapped. Not to apply. Signed-off-by: Simon Glass --- drivers/gpio/intel_ich6_gpio.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/intel_ich6_gpio.c b/drivers/gpio/intel_ich6_gpio.c index 5cc86d7..204a4b4 100644 --- a/drivers/gpio/intel_ich6_gpio.c +++ b/drivers/gpio/intel_ich6_gpio.c @@ -49,6 +49,8 @@ struct ich6_bank_priv { #define GPIO_USESEL_OFFSET(x) (x) #define GPIO_IOSEL_OFFSET(x) (x + 4) #define GPIO_LVL_OFFSET(x) (x + 8) +#define IOPAD_VAL_OFFSET(x) (x + 8) +#define IINENB_SHIFT 2 #define IOPAD_MODE_MASK 0x7 #define IOPAD_PULL_ASSIGN_SHIFT 7 @@ -210,6 +212,7 @@ static int _gpio_ich6_pinctrl_cfg_pin(s32 gpiobase, s32 iobase, int pin_node) int val; int ret; const void *prop; + bool mode_gpio = false; /* * GPIO node is not mandatory, so we only do the @@ -221,11 +224,13 @@ static int _gpio_ich6_pinctrl_cfg_pin(s32 gpiobase, s32 iobase, int pin_node) /* Do we want to force the GPIO mode? */ prop = fdt_getprop(gd->fdt_blob, pin_node, "mode-gpio", NULL); - if (prop) + if (prop) { _ich6_gpio_set_function(GPIO_USESEL_OFFSET (gpiobase) + gpio_offset[0], gpio_offset[1], 1); + mode_gpio = true; + } val = fdtdec_get_int(gd->fdt_blob, pin_node, "direction", -1); @@ -270,8 +275,12 @@ static int _gpio_ich6_pinctrl_cfg_pin(s32 gpiobase, s32 iobase, int pin_node) * be just ignored by the controller */ val = fdtdec_get_int(gd->fdt_blob, pin_node, "mode-func", -1); - if (val != -1) + if (val != -1) { clrsetbits_le32(iobase_addr, IOPAD_MODE_MASK, val); + } else if (mode_gpio) { + clrbits_le32(IOPAD_VAL_OFFSET(iobase_addr), + 1 << IINENB_SHIFT); + } /* Configure the pull-up/down if needed */ val = fdtdec_get_int(gd->fdt_blob, pin_node, "pull-assign", -1);