From patchwork Thu Jul 12 11:36:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 942951 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=monstr-eu.20150623.gappssmtp.com header.i=@monstr-eu.20150623.gappssmtp.com header.b="A9EyFH4l"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41RDS12kRvz9s1R for ; Thu, 12 Jul 2018 21:37:05 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 1E6A3C21FA0; Thu, 12 Jul 2018 11:37:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 42431C21D4A; Thu, 12 Jul 2018 11:36:57 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id B4E82C21D4A; Thu, 12 Jul 2018 11:36:56 +0000 (UTC) Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by lists.denx.de (Postfix) with ESMTPS id 54B7AC21BE5 for ; Thu, 12 Jul 2018 11:36:56 +0000 (UTC) Received: by mail-wr1-f68.google.com with SMTP id c4-v6so8687069wrs.12 for ; Thu, 12 Jul 2018 04:36:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id; bh=x2rNfnpBH6nNY/zmwGCUN4BX5w2Nmzkh0RBD6g6ZD5A=; b=A9EyFH4l8xjJHfXANTtaLiqsR3g+bLGYsPwmAaC0eEwco65dO7qqlPu0LIOCAtgp45 EBRYtz+eWai+RDkHm2KhT6cTlceYWwfO2z230CUp4bGAlR2fOxqvfQKzN7z1he/yfNdw lP00ldJDObc3Kiuy47mhnrVk6J3PRIWwtCOrSZLv+uiUfaTWzJ90gbugBboebIb6p314 Sv145uEsxJVP/IzwkcsFk1tAljiw4FbWtMUSnyZSqUu+4QLHHBCR4zoRuiCbOE2QjBP1 fuLSCYOtlVpewF5ynLNj22HETDkBm1+la2mWbWx/1zQAqv0ewf5794zNS45nj4NJM1/j g0Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=x2rNfnpBH6nNY/zmwGCUN4BX5w2Nmzkh0RBD6g6ZD5A=; b=kXkTwlx/0pBRaKEhFI+b6TMDWv5MVGNEaZB+F7d/tXuwO/ZU6W6Xjs8lpHeiO+wVKF TdWAbiOQGLeIns+dGGRj16/9j0C3O4DJMPrXAg1Z/R6hln403i11s/RmronaxTD532JH i9jODiaIQWDKZZ0Xy86PQYlE+WuJpBVNvp3JT/RDgDyEaS3djMsYnnwQ37wmg+Npu658 +ikB6tldjquSqx2SxHAXi+E5idJPAi48a/cxGZ5dp11dS3PEjg8tAlELbgqHlG/1pO9x IbSCN5XhaUcTngQYB12earD8SiX45BXbDzSSWzicI5ewI46QEFY4NGxLQXCaSywdYbcN dbBw== X-Gm-Message-State: AOUpUlGxNW3nz1vwFeRgmlh3NEnBcKbN9evPCtTtjYQA3N3tZpVot691 LfpsgZurnZv2xWuIANkfsP298E7C X-Google-Smtp-Source: AAOMgpfJwXu60Wrshk6U+vQBnznYY5JzubJUAaUQBuYnUtKf/Cf6PWeiFxW+UpUdDh8hiY9hXGUUjg== X-Received: by 2002:adf:bc92:: with SMTP id g18-v6mr1489702wrh.266.1531395415830; Thu, 12 Jul 2018 04:36:55 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id z14-v6sm4526741wma.11.2018.07.12.04.36.55 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 12 Jul 2018 04:36:55 -0700 (PDT) From: Michal Simek To: u-boot@lists.denx.de, Simon Glass Date: Thu, 12 Jul 2018 13:36:54 +0200 Message-Id: X-Mailer: git-send-email 1.9.1 Subject: [U-Boot] [PATCH] gpio: dm: Support manual relocation for gpio X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" Relocate gpio ops as was done by: "dm: Add support for all targets which requires MANUAL_RELOC" (sha1: 484fdf5ba058b07be5ca82763aa2b72063540ef3) Signed-off-by: Michal Simek Reviewed-by: Simon Glass --- drivers/gpio/gpio-uclass.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c index e9d08e2ebc25..da5e9ba6e524 100644 --- a/drivers/gpio/gpio-uclass.c +++ b/drivers/gpio/gpio-uclass.c @@ -854,11 +854,46 @@ static int gpio_pre_remove(struct udevice *dev) return gpio_renumber(dev); } +static int gpio_post_bind(struct udevice *dev) +{ +#if defined(CONFIG_NEEDS_MANUAL_RELOC) + struct dm_gpio_ops *ops = (struct dm_gpio_ops *)device_get_ops(dev); + static int reloc_done; + + if (!reloc_done) { + if (ops->request) + ops->request += gd->reloc_off; + if (ops->free) + ops->free += gd->reloc_off; + if (ops->direction_input) + ops->direction_input += gd->reloc_off; + if (ops->direction_output) + ops->direction_output += gd->reloc_off; + if (ops->get_value) + ops->get_value += gd->reloc_off; + if (ops->set_value) + ops->set_value += gd->reloc_off; + if (ops->get_open_drain) + ops->get_open_drain += gd->reloc_off; + if (ops->set_open_drain) + ops->set_open_drain += gd->reloc_off; + if (ops->get_function) + ops->get_function += gd->reloc_off; + if (ops->xlate) + ops->xlate += gd->reloc_off; + + reloc_done++; + } +#endif + return 0; +} + UCLASS_DRIVER(gpio) = { .id = UCLASS_GPIO, .name = "gpio", .flags = DM_UC_FLAG_SEQ_ALIAS, .post_probe = gpio_post_probe, + .post_bind = gpio_post_bind, .pre_remove = gpio_pre_remove, .per_device_auto_alloc_size = sizeof(struct gpio_dev_priv), };