From patchwork Mon Jun 18 07:45:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 138857 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp3643852lji; Mon, 18 Jun 2018 00:46:14 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKYDUjnyrgWKKlqVu3HWzdZkDOg0QQAKW5JNIrCPxbFHduHj8bgR93sxr6OA2AUWkPoh6nq X-Received: by 2002:a63:b812:: with SMTP id p18-v6mr10355001pge.11.1529307974449; Mon, 18 Jun 2018 00:46:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529307974; cv=none; d=google.com; s=arc-20160816; b=cbGje8PluukESKTN+iOGShRPjwmU9dG/QQPg3ADGGXIvgDr34uqVzl/OC7pMxG75ZV DYrBcS/lJB4YI9cjduazEeI4uoJH2C3r60BMh3MH9eUtjYsOnjcn4bAQvlPTQXaqPbci 0dRt0W7Mm3oNxLzRyVuIr8WF9aqQICnQ6doI9HGb69h7xxjKM6WRVYNexrObQ9xMsdpY YPjj7HbUl/NXoB/F5yLqQyIVp2NlIKbTdi49uwRXSUcz9vt+D5zrNT6VCL5XoEr7KxAc ECCyvIxGXy/X7ZDmZ5e4XklEB3ELuu3RKelaw2lH7DGEMnPLRl6nvqmUW9WVva0HOSdn bDpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=moOR63IXflDCWenxZdMutWzlSayR6HX5M/EswNi22T4=; b=K6TLQO6AGCtc6EZAF8E0DJ7DZYcQPd/QVT+e9GWjepUbTjPvmjbO+pyMOvl7dTq1o7 81mouFQ9N1QHCDW7VOT2fkTTCSFfPgNdfNrAa9Q11Mu1mkYRYko+qdFg5Hc2rNXExwnd hxTXdIhrckXV6nE6fmVBosn1tCM3TXc8XRTQjaSV8bYltYYQlkSuuOCryDLiBjBKs+P5 GMkO7DZwf/l7h6BppVan34HWaX5d45M/oh0OPM3sWFdLPpq3+KGO/fu6nDqoPQhpeoJ/ beunWr9tnLMWIj235oV4X/t9MC7OmXK9sRi2Fdo7NMbcIKvQv0W+M0IfjJv8RvrVeAST Z3mA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=FavQqBj5; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w2-v6si11655956pgs.59.2018.06.18.00.46.14; Mon, 18 Jun 2018 00:46:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=FavQqBj5; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755005AbeFRHqN (ORCPT + 5 others); Mon, 18 Jun 2018 03:46:13 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:39859 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754982AbeFRHqN (ORCPT ); Mon, 18 Jun 2018 03:46:13 -0400 Received: by mail-lf0-f65.google.com with SMTP id t2-v6so16724369lfd.6 for ; Mon, 18 Jun 2018 00:46:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mdTg14MkbiErOIsb9qzdOdJ3w+dtrWJ7tFqOCDf8yKo=; b=FavQqBj5yGA77wtxRMAsIp4hTgLLF8xQTiF8lZeq6dN3xjKcOdPmnlH80nNENZ0+um bH0y2+fBRHYTId40zUpffjlRfg9hxZ6frb0mpftxqObJG6SLO0MkqbUh7oeWkZ9gSU6D dkrpiCqTS6lj6Wk3JLPtU/1t7YPXBo8xCWpwk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mdTg14MkbiErOIsb9qzdOdJ3w+dtrWJ7tFqOCDf8yKo=; b=pfourhT0Rj0gNe+ymwDC/x+w7LnrhyGuDoOk4NLOZvEWTw2Tc1XbCSGeXjIaWYGuoo S2wPPU5/+WjG7CS4vc27g7yJNyEf/jIop5hcI2rUeWjs86a/aKL0TJ7hGnmBk+qiTaC6 beM2h/gHw/+g79A39a48iItBnitSZY1TqiMDp15or0ViydTYmV1T9MwbrwIZ430YFFNb hJi7qw37xM+A0KLaZhevAaCgXuBZsGpLponcFszTs+nd1VM/WCeIM6wI2u5OalT0e9Zg +hOkOWehlUrtk7VSxdEa0N1225wT0oIdgLxn9ObYcajDAvOIt2ZXQtXdeWU9CAtGlOWl kkzA== X-Gm-Message-State: APt69E3kvLMRsc82+VG1EW1JaDLQdcKyLm08wP4w05HEx00YiJwZTrrz GYrK/A9TjTNlKy46PHta8W0bCg== X-Received: by 2002:a2e:4149:: with SMTP id o70-v6mr7742171lja.3.1529307971741; Mon, 18 Jun 2018 00:46:11 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id x18-v6sm2616390ljh.63.2018.06.18.00.46.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 00:46:10 -0700 (PDT) From: Linus Walleij To: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, dev@lists.96boards.org Cc: John Stultz , Manivannan Sadhasivam , Rob Herring , Mark Rutland , Frank Rowand , Mark Brown , Michal Simek , Andy Shevchenko , Mika Westerberg , Arnd Bergmann , Linus Walleij Subject: [PATCH 1/5] RFC: gpio: Add API to explicitly name a consumer Date: Mon, 18 Jun 2018 09:45:52 +0200 Message-Id: <20180618074556.6944-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180618074556.6944-1-linus.walleij@linaro.org> References: <20180618074556.6944-1-linus.walleij@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The GPIO (descriptor) API registers a "label" naming what is currently using the GPIO line. Typically this is taken from things like the device tree node, so "reset-gpios" will result in he line being labeled "reset". The technical effect is pretty much zero: the use is for debug and introspection, such as "lsgpio" and debugfs files. However sometimes the user want this cuddly feeling of listing all GPIO lines and seeing exactly what they are for and it gives a very fulfilling sense of control. Especially in the cases when the device tree node doesn't provide a good name, or anonymous GPIO lines assigned just to "gpios" in the device tree because the usage is implicit. For these cases it may be nice to be able to label the line directly and explicitly. Signed-off-by: Linus Walleij --- drivers/gpio/gpiolib.c | 13 +++++++++++++ include/linux/gpio/consumer.h | 7 +++++++ 2 files changed, 20 insertions(+) -- 2.17.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index e11a3bb03820..c6f77e806cb8 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -3193,6 +3193,19 @@ int gpiod_cansleep(const struct gpio_desc *desc) } EXPORT_SYMBOL_GPL(gpiod_cansleep); +/** + * gpiod_set_consumer_name() - set the consumer name for the descriptor + * @desc: gpio to set the consumer name on + * @name: the new consumer name + */ +void gpiod_set_consumer_name(struct gpio_desc *desc, const char *name) +{ + VALIDATE_DESC_VOID(desc); + /* Just overwrite whatever the previous name was */ + desc->label = name; +} +EXPORT_SYMBOL_GPL(gpiod_set_consumer_name); + /** * gpiod_to_irq() - return the IRQ corresponding to a GPIO * @desc: gpio whose IRQ will be returned (already requested) diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h index 243112c7fa7d..e8aaf34dd65d 100644 --- a/include/linux/gpio/consumer.h +++ b/include/linux/gpio/consumer.h @@ -145,6 +145,7 @@ int gpiod_is_active_low(const struct gpio_desc *desc); int gpiod_cansleep(const struct gpio_desc *desc); int gpiod_to_irq(const struct gpio_desc *desc); +void gpiod_set_consumer_name(struct gpio_desc *desc, const char *name); /* Convert between the old gpio_ and new gpiod_ interfaces */ struct gpio_desc *gpio_to_desc(unsigned gpio); @@ -467,6 +468,12 @@ static inline int gpiod_to_irq(const struct gpio_desc *desc) return -EINVAL; } +static inline void gpiod_set_consumer_name(struct gpio_desc *desc, const char *name) +{ + /* GPIO can never have been requested */ + WARN_ON(1); +} + static inline struct gpio_desc *gpio_to_desc(unsigned gpio) { return ERR_PTR(-EINVAL); From patchwork Mon Jun 18 07:45:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 138858 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp3643890lji; Mon, 18 Jun 2018 00:46:17 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLsed1WMgi83eqG1WWGRLpCxcXPSsxl+2pFqVfM6gVvzCQU3aZOqP39dqprQZc9k1warQ3D X-Received: by 2002:a65:4042:: with SMTP id h2-v6mr9808803pgp.78.1529307977249; Mon, 18 Jun 2018 00:46:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529307977; cv=none; d=google.com; s=arc-20160816; b=BtDwSLxq0JCusDx4Uk+Ny2+xS+Cn6FepJlZhP+b04cINqLoERTJw2Yhj2OV9yUnRDx ZY9J88i3mret3ZyxnNeUQL9cLQXFWlE3nqqe4Z6Szeth7CrEIspGh1slWpqiumJ/Ecgz PnSQB6XlWq0gy41h6ugLu1aqFQWZE3D4MXJ4KSUVb0hYrFBUF6aeJTBTP9dUATV82H8J A8gDfB/vygkjAi/+WOwiTZJq3zgs5cq5A9c7gpYNAdCS5BpqsgRiSOC1hDtLakkHoz6e 03KN61g0iEBlNbfITjyGNnKH0Dc1ohOwzQtD8Y/duGZSmc7kt+OHBVvn9stHDmWE/6qW lKGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=gvsGev3u9e1hEWqHZHqWYO1Z2wqWK1c8tfca0ATMOEg=; b=LbexaraxfnBsatlpWtWkMImtLCDpHai5Z0rGWI06DeDOt8WIfYRsvqSUGc+Nr3S7K2 vR2XENX4Fh04AwYhYFAodD9Dwyj6zkfwRMgygLbw047/qawereXQzOWrQviawwar8WL5 /bc4OxgBObPnA9r/KNYLz+xGPb4nSHDeyQTgqT3zvaIDz+YlzKYaGFqa/3dQP8p6Qfu4 c+XqpOJfmOc7rKWdSKz11+PDXEmCwT+HmjAND/z6/OGwo44AkaPMmow7/w/FLQaVRMyI BqLyQm0oypo8vxMfITSQ93Jwhp4O0e+jq6yNAr0WC6j29A4sI5cnm3otL547GHLRXe7T lQbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ZgCJ2MTm; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w2-v6si11655956pgs.59.2018.06.18.00.46.16; Mon, 18 Jun 2018 00:46:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ZgCJ2MTm; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754908AbeFRHqQ (ORCPT + 5 others); Mon, 18 Jun 2018 03:46:16 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:37438 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754655AbeFRHqP (ORCPT ); Mon, 18 Jun 2018 03:46:15 -0400 Received: by mail-lf0-f67.google.com with SMTP id g21-v6so23138317lfb.4 for ; Mon, 18 Jun 2018 00:46:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=f5/ByYi5LPGeYwNpayKevBwrrBY79aGtPsGnxBORLEQ=; b=ZgCJ2MTmsgNAkZTec1fe/rIjAgB1hVh/UQ0NJibybhCOcvel+b7GSNfaLdKMVGjgtn OQVefsjhMKIyZOVUiMbScCaZPSKKE/1zKwV+zcCgYmZCyH1QZbEcpDEj0a4FtlwOQVIs NGIoIDkfgdt9cZXu6tT4m0LRpA+2bRYO6j8xo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=f5/ByYi5LPGeYwNpayKevBwrrBY79aGtPsGnxBORLEQ=; b=anzi/him3epIs7seS8qzY4P+vRSRLFwv/D3bznZ7ZnDs/uoNSg9WoayAvRyEjOJS4p 17+cSymKQExdmMimR6Lbu7QlY5gAmAY6AOxMkgss4EHpiTe07JFQAUFtflsa1+b3Z/Ks iCVXpZBQsiPKK+h0+XQzjdLB4kpqFh33oF5zgR8DMhLAebOpcPmqk6YPoaSf+yD1gsiP sHl0No9Y94KRvhz2OlRlXxdxmmMFz+VvyR0XWE5aXkXwTKBqubLXx4IOK1PS18/BS8O0 LPoPUV0Dh1yhi06PuOB1Zc3z5AEHehddvi29Grod11HQzuke7X02rz2IFqmURo8amYR0 cRBw== X-Gm-Message-State: APt69E3L8GJ1hPkA9+vtuKRMXCJ8ABWURs+wlg6ly3PaOuGh7myiWgCq V41u/1+3NOJ8CxOzUQqNyKGNIHnFEc8= X-Received: by 2002:a19:9844:: with SMTP id a65-v6mr2633692lfe.29.1529307974346; Mon, 18 Jun 2018 00:46:14 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id x18-v6sm2616390ljh.63.2018.06.18.00.46.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 00:46:13 -0700 (PDT) From: Linus Walleij To: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, dev@lists.96boards.org Cc: John Stultz , Manivannan Sadhasivam , Rob Herring , Mark Rutland , Frank Rowand , Mark Brown , Michal Simek , Andy Shevchenko , Mika Westerberg , Arnd Bergmann , Linus Walleij Subject: [PATCH 2/5] RFC: eeprom: at24: Allow passing gpiodesc from pdata Date: Mon, 18 Jun 2018 09:45:53 +0200 Message-Id: <20180618074556.6944-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180618074556.6944-1-linus.walleij@linaro.org> References: <20180618074556.6944-1-linus.walleij@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org This makes it possible to pass an initialized GPIO descriptor to the driver through platform data. This is useful when we are dealing with EEPROMs on expansion boards where the GPIO has to be looked up indirectly using a connector abstraction (several systems using the same connector) so the machine descriptor tables cannot be used to associate the descriptor with the device and we then want to pass this descriptor on to the EEPROM driver this way instead. Signed-off-by: Linus Walleij --- drivers/misc/eeprom/at24.c | 6 +++++- include/linux/platform_data/at24.h | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) -- 2.17.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c index f5cc517d1131..d577cdbe221e 100644 --- a/drivers/misc/eeprom/at24.c +++ b/drivers/misc/eeprom/at24.c @@ -662,7 +662,11 @@ static int at24_probe(struct i2c_client *client) at24->client[0].client = client; at24->client[0].regmap = regmap; - at24->wp_gpio = devm_gpiod_get_optional(dev, "wp", GPIOD_OUT_HIGH); + if (pdata.wp_gpiod) + at24->wp_gpio = pdata.wp_gpiod; + else + at24->wp_gpio = + devm_gpiod_get_optional(dev, "wp", GPIOD_OUT_HIGH); if (IS_ERR(at24->wp_gpio)) return PTR_ERR(at24->wp_gpio); diff --git a/include/linux/platform_data/at24.h b/include/linux/platform_data/at24.h index 63507ff464ee..5606fb2ef76c 100644 --- a/include/linux/platform_data/at24.h +++ b/include/linux/platform_data/at24.h @@ -11,6 +11,7 @@ #include #include #include +#include /** * struct at24_platform_data - data to set up at24 (generic eeprom) driver @@ -55,6 +56,7 @@ struct at24_platform_data { void (*setup)(struct nvmem_device *nvmem, void *context); void *context; + struct gpio_desc *wp_gpiod; }; #endif /* _LINUX_AT24_H */ From patchwork Mon Jun 18 07:45:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 138859 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp3643915lji; Mon, 18 Jun 2018 00:46:19 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJtfpWwPaNWWKR6z4RQ2JXBwgJiOzRQsrMO3acb+/sO7kebf9MESaV9S8wk6DI1nIDMLLIQ X-Received: by 2002:a63:b812:: with SMTP id p18-v6mr10355211pge.11.1529307979819; Mon, 18 Jun 2018 00:46:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529307979; cv=none; d=google.com; s=arc-20160816; b=KW5jdUl5o4NXzTgQoxRM/wsDferiCTE3eu8z7qhhZQchQFZEK+rGc99aJLJeV9w99L wiJzCu+HftuDGUnY1WRyUKT8KZmS55hy4HkrZ+bRRsVx2/1cvqr83r7YdoNYQJDiDXID Tl5tB5mezSsgnCgRPwh9ib2lglmX/06SQyEqNtl+gKQDisSsFbtglqBcETAJjKxppNF4 bRTBR9+ImQc12ahT7LAkj+XusDEenteryg7N18PKT4S/NsiMvI5p5ZeamYeAakDC26mT Dmk9xo9vzYmMCaOJuYIalZQKkywrL7HlT+rdcfIJm/wGXs9ewxtnimOnHZh0iGhT2lhX 1pXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=I64qpXXBPr0KxjmB57F0kqcVuaa8E0tycPhFE0T39Mc=; b=XLTXldcEOl4pUW//LkFPJjl98GJW5c6ELWi9svLYkCtf04WVTmLFNVbJEMkJvJGVw7 c1EzryqWw0p5/LK6OrbB30f4aZ2OS4LS1PAS2ft/ng0FnKxaAWerMuY/kCPB8jFoqBeg N4vyHapktsz84yVNd7pjvaqPHXOV1sxMK4MwEyAsg4Jtif/6wg3NQWXLKVfAKnQyDnbX vm9u04Kphh5Ygr8Q5X/7E5b84OUsw6fLsbukNK8nW9Bbg4aiYmua5pEVcgTHtUFsw9ro 36T8mIEqpdLtG2T1Yixm60jgCMM1+Ac3rMySWAy6C7skG+0Fd/BDfVdSpuPA1KRDV9y5 LRZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=S+yvVAzr; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w2-v6si11655956pgs.59.2018.06.18.00.46.19; Mon, 18 Jun 2018 00:46:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=S+yvVAzr; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755188AbeFRHqT (ORCPT + 5 others); Mon, 18 Jun 2018 03:46:19 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:40784 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754983AbeFRHqS (ORCPT ); Mon, 18 Jun 2018 03:46:18 -0400 Received: by mail-lf0-f65.google.com with SMTP id q11-v6so23120420lfc.7 for ; Mon, 18 Jun 2018 00:46:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qMxxS4Flb5C1krxYYrdSlGB/4puq1cJ1JbMAz74PBPA=; b=S+yvVAzri6GVSl869nKYsd/igxKprWuhOCzMKqHSkRCq2Oan8UL3ZuZnbktmEUR0R0 pXYFGsIFFPxQJt2iSB4Inrlvh5hqkhMqK/On7l8ZpiEUeFgVqG0UjaUK8n15R3KM/iZX bSpp8VCPsGfZ02+ZVayHgIPqIDz+dg8PCoe50= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=qMxxS4Flb5C1krxYYrdSlGB/4puq1cJ1JbMAz74PBPA=; b=O+gLM8OQ0iFWnJmnPMQs5LA5oX8g6OXX6yJzPwm6C8UG9VJ3H7jVylFDzMxSayOLIG 7P9JOUyBzHy2e4eXWm2JWfecsN7ZwQCp87f37QP+k5hn3sZTnfgbdkuBYEqD8lUknak7 pnG8xw9TCZ1F01KAVT84ZFipOnks5HgXLt5W8mvQuqjJbMmB4nOGD2udepQrzPjDRmgy /zjTeHOhuoyen3+7YVMTiiGa/0G0KC58CYEsgpUycDpEoXAwC0l9bOkESppWzklliny8 IUUmWcERn2BG/I86t/ITck8z26u3YIlEMq64q7C6ux/BCKi454UuBGKtxHiJjqiouzCB aPJQ== X-Gm-Message-State: APt69E15UXE69e3w5o3OrEPhJinXaQ5mCNEt1JGsNgc1Iy6rFoeH4AR7 bXYbk1aZD5mhhbpE0rzUhrPCsJXumho= X-Received: by 2002:a19:a892:: with SMTP id r140-v6mr6555672lfe.39.1529307976900; Mon, 18 Jun 2018 00:46:16 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id x18-v6sm2616390ljh.63.2018.06.18.00.46.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 00:46:15 -0700 (PDT) From: Linus Walleij To: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, dev@lists.96boards.org Cc: John Stultz , Manivannan Sadhasivam , Rob Herring , Mark Rutland , Frank Rowand , Mark Brown , Michal Simek , Andy Shevchenko , Mika Westerberg , Arnd Bergmann , Linus Walleij Subject: [PATCH 3/5] RFC: spi: Make of_find_spi_device_by_node() available Date: Mon, 18 Jun 2018 09:45:54 +0200 Message-Id: <20180618074556.6944-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180618074556.6944-1-linus.walleij@linaro.org> References: <20180618074556.6944-1-linus.walleij@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org This externalizes and exports the symbol of_find_spi_device_by_node() from the SPI core akin to how of_find_i2c_adapter_by_node() is already available. As we will need this also for non-dynamic OF setups, we move it under a CONFIG_OF check. Signed-off-by: Linus Walleij --- drivers/spi/spi.c | 33 ++++++++++++++++++--------------- include/linux/spi/spi.h | 4 ++++ 2 files changed, 22 insertions(+), 15 deletions(-) -- 2.17.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index ec395a6baf9c..6a1085077317 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -3314,27 +3314,14 @@ EXPORT_SYMBOL_GPL(spi_write_then_read); /*-------------------------------------------------------------------------*/ -#if IS_ENABLED(CONFIG_OF_DYNAMIC) -static int __spi_of_device_match(struct device *dev, void *data) -{ - return dev->of_node == data; -} - -/* must call put_device() when done with returned spi_device device */ -static struct spi_device *of_find_spi_device_by_node(struct device_node *node) -{ - struct device *dev = bus_find_device(&spi_bus_type, NULL, node, - __spi_of_device_match); - return dev ? to_spi_device(dev) : NULL; -} - +#if IS_ENABLED(CONFIG_OF) static int __spi_of_controller_match(struct device *dev, const void *data) { return dev->of_node == data; } /* the spi controllers are not using spi_bus, so we find it with another way */ -static struct spi_controller *of_find_spi_controller_by_node(struct device_node *node) +struct spi_controller *of_find_spi_controller_by_node(struct device_node *node) { struct device *dev; @@ -3349,6 +3336,22 @@ static struct spi_controller *of_find_spi_controller_by_node(struct device_node /* reference got in class_find_device */ return container_of(dev, struct spi_controller, dev); } +EXPORT_SYMBOL_GPL(of_find_spi_controller_by_node); +#endif + +#if IS_ENABLED(CONFIG_OF_DYNAMIC) +static int __spi_of_device_match(struct device *dev, void *data) +{ + return dev->of_node == data; +} + +/* must call put_device() when done with returned spi_device device */ +static struct spi_device *of_find_spi_device_by_node(struct device_node *node) +{ + struct device *dev = bus_find_device(&spi_bus_type, NULL, node, + __spi_of_device_match); + return dev ? to_spi_device(dev) : NULL; +} static int of_spi_notify(struct notifier_block *nb, unsigned long action, void *arg) diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index a64235e05321..c2be93224bd1 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -639,6 +639,10 @@ extern int devm_spi_register_controller(struct device *dev, struct spi_controller *ctlr); extern void spi_unregister_controller(struct spi_controller *ctlr); +#if IS_ENABLED(CONFIG_OF) +struct spi_controller *of_find_spi_controller_by_node(struct device_node *node); +#endif + extern struct spi_controller *spi_busnum_to_master(u16 busnum); /* From patchwork Mon Jun 18 07:45:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 138860 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp3643954lji; Mon, 18 Jun 2018 00:46:23 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLRInUwDchz4VwiVXafz4r2PFYoX/lVC4sVv6HTw1Hvt0pWr6EB4hvREXantPotwcwmXm86 X-Received: by 2002:a63:5fc1:: with SMTP id t184-v6mr10127011pgb.132.1529307983833; Mon, 18 Jun 2018 00:46:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529307983; cv=none; d=google.com; s=arc-20160816; b=z3kZ/t2CsnQcTA4DaW5vZXQTFwby0vR5QOHHj4YwkjhWBx6WJlZWv65A024pJH+vYy wsWe7oV5LQZU1e78HESsOdgTe3JqZ13wjmTxvYX6G0EuiOotasUxyN34OYoQitFyncOF xYsbRetvNtZOT04ICFKqXlvOBXLR32OKQ+JdYhsNT+vYF+EiSW8+WaZWAM6PfPxlDSKA zJXWMtygtouZxj3PaGoW3a9kCogOzItC6fUfxB7BUiIbbvJvyEo1BeM7LZximTatntQ8 SQVdB1R9bkn9BdxfKQrBXr+9N0zml9Ohf4ZSst8TWG713lehJbuw4hDyn+ix1zPCeRaC b/KA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=JL/OnXAeXcsFYZDvnjn0KqHGuKIQZNY1Vf2kjD10TTU=; b=qDA1cEYNyHycIV5pYGWcF0mlV1j2tfC+mdccBUL2+5cQFD01tiZgC3tlQ30gep8s+h rIKXz+P+qtyOA3K3SNyc1lI1AO6w2flePGuFDDNhRGp7/LlwjJJT0Nx+3PJ5Tl5CPwVQ 7uqtt3aiMy1ke2UpQ5nvPsCy4c8rwnjaHm9BDyHzdSDKcpUmUqUkHg/xXF9jx2oLoyKM OF3R6isaLVQxdULC3jUwqwZ1IKRNUseqE2WeCkAK89Zupjlxu0+XisZ9y5WyMwkUWPJv hr0+x7BzEmU2kwJ1dFiwuJJbKYV+mnlqae/sWijE1niITwpSVBmayCJjTB/saa4Ip+hz H8YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=iV0YYJ3L; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w2-v6si11655956pgs.59.2018.06.18.00.46.23; Mon, 18 Jun 2018 00:46:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=iV0YYJ3L; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755008AbeFRHqX (ORCPT + 5 others); Mon, 18 Jun 2018 03:46:23 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:41386 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755232AbeFRHqV (ORCPT ); Mon, 18 Jun 2018 03:46:21 -0400 Received: by mail-lf0-f68.google.com with SMTP id d24-v6so23114752lfa.8 for ; Mon, 18 Jun 2018 00:46:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=iHjAczc9uDZGPTtK262zzU8xHVGPHwz51X0Esx7c4a0=; b=iV0YYJ3LntF2PQcvxheyeZX7nCaA8o3IZJWCz+5trfkYLmZ5tuedQdLLIku7gmORag kQ4eIexdzB2yVN49zLPzrZGoxPkcEECD28q6xIDcDBaHAb3+rEmFezod8wIT9NGyHjXB vHXVyV5s1NGPDq81rNhdSxI0nR3Ea+IKjNmP0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=iHjAczc9uDZGPTtK262zzU8xHVGPHwz51X0Esx7c4a0=; b=BohIYUcm/xYdAY53IaWckirJdAL0YEih3blDLtWvhvBGZsCvOKbqrCwZZZUHmmZljy rDlpNA1vFTyG/PqLU+QPqI9zjdTS/p4TCN37tBfRJk9qbFo6Lv/AahnndL3cPGbZ9jIa OoeRchbeAhP45uYL7l8LQjFebeLde4CSx43w/FjKc4RngbOqJh/pAqQwBgthe1cy8ygC 3Fn8KdIDXb+40t86tKI87eZ4j3TkV8K3ArKOlCRvK07pyLgz1TnQaPQmcOsyGWqgVAEr +acBCNkXdVLoiZOnf/rafrNHIC7olFR81VjtthlaIgBNSWCEaMlqRqJmy/GUpQa1aODc wKoQ== X-Gm-Message-State: APt69E3wDQmce0UE3D8ZKnOwviTE8mmB644UJlvMu0Fi076YkKM4k44P 9sM4X9YK/N1aWNyZR3PgaNan5A== X-Received: by 2002:a2e:1945:: with SMTP id p66-v6mr7162855lje.114.1529307979742; Mon, 18 Jun 2018 00:46:19 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id x18-v6sm2616390ljh.63.2018.06.18.00.46.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 00:46:18 -0700 (PDT) From: Linus Walleij To: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, dev@lists.96boards.org Cc: John Stultz , Manivannan Sadhasivam , Rob Herring , Mark Rutland , Frank Rowand , Mark Brown , Michal Simek , Andy Shevchenko , Mika Westerberg , Arnd Bergmann , Linus Walleij Subject: [PATCH 4/5] RFC: bus: 96boards Low-Speed Connector Date: Mon, 18 Jun 2018 09:45:55 +0200 Message-Id: <20180618074556.6944-5-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180618074556.6944-1-linus.walleij@linaro.org> References: <20180618074556.6944-1-linus.walleij@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org This illustrates my idea for using a small connector driver to plug in "mezzanine boards" on the 96boards low-speed connector. These "mezzanine boards" are no different than "capes", "logic modules", etc. This thing, a non-discoverable connector where a user can plug in a few peripherals has been reinvented a few times. As a proof-of-concept we add the Secure96, a quite minimal mezzanine board. Users can register their boards in a simple way. Either just add their compatible-string in the device tree: board { compatible = "96boards,secure96"; }; And if they can't even change three lines in their device tree, or if they at runtime decide to plug in some board and test it, they can use sysfs, as exemplified by plugging in the secure96 security board at runtime: > cd /sys/devices/platform/connector > echo 1 > secure96 [ 61.014629] lscon connector: called mezzanine_store on secure96 [ 61.020530] lscon connector: populate secure96 [ 61.027081] at24 1-0050: 2048 byte 24c128 EEPROM, writable, 128 bytes/write [ 61.053569] atmel-ecc 1-0060: configuration zone is unlocked [ 61.502535] tpm_tis_spi spi0.0: 2.0 TPM (device-id 0x1B, rev-id 16) (...) The plug-in board can be removed from sysfs and added back again multiple times like this with the devices being runtime added and removed by two writes to sysfs. > echo 0 > secure96 > echo 1 > secure96 > echo 0 > secure96 (...) I certainly see some scalability problems with this particular code for example, but the fact is: it pretty much works. The devices need hooks in I2C and SPI, and need to be able to accept initialized GPIO descriptors passed in as platform data. Any discussions related to the concept compared to doing device tree overlays/fragments etc: please discuss in patch 0 (the cover letter). Signed-off-by: Linus Walleij --- .../96boards-ls-connector.c | 307 ++++++++++++++++++ .../96boards-mezzanines/96boards-mezzanines.h | 46 +++ .../96boards-mezzanines/96boards-secure96.c | 249 ++++++++++++++ drivers/bus/96boards-mezzanines/Kconfig | 36 ++ drivers/bus/96boards-mezzanines/Makefile | 6 + drivers/bus/Kconfig | 2 + drivers/bus/Makefile | 4 +- 7 files changed, 649 insertions(+), 1 deletion(-) create mode 100644 drivers/bus/96boards-mezzanines/96boards-ls-connector.c create mode 100644 drivers/bus/96boards-mezzanines/96boards-mezzanines.h create mode 100644 drivers/bus/96boards-mezzanines/96boards-secure96.c create mode 100644 drivers/bus/96boards-mezzanines/Kconfig create mode 100644 drivers/bus/96boards-mezzanines/Makefile -- 2.17.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/bus/96boards-mezzanines/96boards-ls-connector.c b/drivers/bus/96boards-mezzanines/96boards-ls-connector.c new file mode 100644 index 000000000000..1a012b0cd457 --- /dev/null +++ b/drivers/bus/96boards-mezzanines/96boards-ls-connector.c @@ -0,0 +1,307 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * 96boards Low-speed Connector driver + * (C) 2018 Linus Walleij + */ + +#include +#include +#include +#include +#include +#include +#include +#include "96boards-mezzanines.h" + +/** + * struct mezzanine - daughter boards (mezzanines) data + * Having dynamic data here means that we can only plug ONE board + * of each type. Stacking two different boards is fine. This + * should be fixed using a linked list of mezzanines if we + * go for this solution. + */ +struct mezzanine { + const char *compatible; + const char *sysfs_name; + struct dev_ext_attribute ext_attr; + void * (*populate) (struct lscon *ls); + void (*depopulate) (void *data); + void *data; +}; + +static struct mezzanine mezzanines[] = { +#if IS_ENABLED(96BOARDS_SECURE96) + { + .compatible = "96boards,secure96", + .sysfs_name = "secure96", + .populate = secure96_populate, + .depopulate = secure96_depopulate, + }, +#endif + /* Add any other mezzanines here */ +}; + +struct gpio_desc *mezzanine_ls_get_gpiod(struct lscon *ls, + enum mezzanine_ls_gpio pin, + const char *consumer_name, + enum gpiod_flags flags) +{ + struct gpio_desc *retdesc; + + /* + * TODO: get all the LS GPIOs as an array on probe() then + * the consumers can skip error handling of IS_ERR() descriptors + * and this need only set the consumer name. + */ + retdesc = devm_gpiod_get_index(ls->dev, NULL, pin, flags); + if (!IS_ERR(retdesc) && consumer_name) + gpiod_set_consumer_name(retdesc, consumer_name); + + return retdesc; +} +EXPORT_SYMBOL_GPL(mezzanine_ls_get_gpiod); + +/* + * Mezzanine boards will call this to orderly remove their claimed + * gpio descriptors, since we acquired them all with devm_gpiod_get() + * they will eventually be released once this connector device + * disappears if the board do not release them in order. + */ +void mezzanine_ls_put_gpiod(struct lscon *ls, struct gpio_desc *gpiod) +{ + devm_gpiod_put(ls->dev, gpiod); +} +EXPORT_SYMBOL_GPL(mezzanine_ls_put_gpiod); + +static ssize_t mezzanine_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct lscon *ls = dev_get_drvdata(dev); + struct dev_ext_attribute *d = container_of(attr, + struct dev_ext_attribute, + attr); + struct mezzanine *mez = d->var; + + dev_info(ls->dev, "called %s on %s\n", __func__, mez->sysfs_name); + return 0; +} + +static ssize_t mezzanine_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct lscon *ls = dev_get_drvdata(dev); + struct dev_ext_attribute *d = container_of(attr, + struct dev_ext_attribute, + attr); + struct mezzanine *mez = d->var; + unsigned long state; + int ret; + + dev_info(ls->dev, "called %s on %s\n", __func__, mez->sysfs_name); + + ret = kstrtoul(buf, 0, &state); + if (ret) + return ret; + + if (state == 1) { + void *data; + + /* Already populated */ + if (mez->data) + return count; + + data = mez->populate(ls); + if (IS_ERR(data)) + return PTR_ERR(data); + mez->data = data; + return count; + } + + if (state == 0) { + /* Not populated so nothing to do here */ + if (!mez->data) + return count; + mez->depopulate(mez->data); + mez->data = NULL; + return count; + } + + return -EINVAL; +} + +/** + * This adds one sysfs file per mezzanine board that we support, so they + * can be probed and added from userspace. + */ +static int lscon_add_sysfs_mezzanines(struct lscon *ls) +{ + struct mezzanine *mez; + struct dev_ext_attribute *ext_attr; + int ret; + int i; + + for (i = 0; i < ARRAY_SIZE(mezzanines); i++) { + mez = &mezzanines[i]; + ext_attr = &mez->ext_attr; + + ext_attr->var = mez; + ext_attr->attr.attr.name = mez->sysfs_name; + ext_attr->attr.attr.mode = VERIFY_OCTAL_PERMISSIONS(0644); + ext_attr->attr.show = mezzanine_show; + ext_attr->attr.store = mezzanine_store; + ret = device_create_file(ls->dev, &ext_attr->attr); + if (ret) + dev_err(ls->dev, "unable to create sysfs entries\n"); + + } + + return 0; +} + +static int lscon_probe_of_mezzanine(struct lscon *ls, struct device_node *np) +{ + struct mezzanine *mez; + void *data; + int i; + + for (i = 0; i < ARRAY_SIZE(mezzanines); i++) { + mez = &mezzanines[i]; + if (of_device_is_compatible(np, mez->compatible)) { + dev_info(ls->dev, "found %s\n", mez->compatible); + data = mez->populate(ls); + if (IS_ERR(data)) + return PTR_ERR(data); + mez->data = data; + return 0; + } + } + + return 0; +} + +static int lscon_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct device_node *np = dev->of_node; + struct device_node *child; + struct spi_controller *spi; + struct mezzanine *mez; + struct lscon *ls; + int ret; + int i; + + ls = devm_kzalloc(dev, sizeof(*ls), GFP_KERNEL); + if (!ls) + return -ENOMEM; + ls->dev = dev; + + /* Bridge I2C busses */ + child = of_parse_phandle(np, "i2c0", 0); + if (!child) { + dev_err(dev, "no i2c0 phandle\n"); + return -ENODEV; + } + ls->i2c0 = of_get_i2c_adapter_by_node(child); + if (!ls->i2c0) { + dev_err(dev, "no i2c0 adapter, deferring\n"); + return -EPROBE_DEFER; + } + + child = of_parse_phandle(np, "i2c1", 0); + if (!child) { + dev_err(dev, "no i2c1 phandle\n"); + ret = -ENODEV; + goto out_put_i2c0; + } + ls->i2c1 = of_get_i2c_adapter_by_node(child); + if (!ls->i2c1) { + dev_err(dev, "no i2c0 adapter, deferring\n"); + ret = -EPROBE_DEFER; + goto out_put_i2c0; + } + + /* Bride SPI bus */ + child = of_parse_phandle(np, "spi", 0); + if (!child) { + dev_err(dev, "no spi phandle\n"); + ret = -ENODEV; + goto out_put_i2c1; + } + spi = of_find_spi_controller_by_node(child); + if (!spi) { + dev_err(dev, "no spi controller, deferring\n"); + ret = -EPROBE_DEFER; + goto out_put_i2c1; + } + ls->spi = spi_controller_get(spi); + if (!ls->spi) { + dev_err(dev, "no spi reference\n"); + ret = -ENODEV; + goto out_put_i2c1; + } + + platform_set_drvdata(pdev, ls); + + /* Get the mezzanine boards, stacking possible */ + for_each_available_child_of_node(np, child) + lscon_probe_of_mezzanine(ls, child); + + ret = lscon_add_sysfs_mezzanines(ls); + if (ret) + goto out_remove_mezzanines; + + return 0; + +out_remove_mezzanines: + /* Depopulate any populated boards */ + for (i = 0; i < ARRAY_SIZE(mezzanines); i++) { + mez = &mezzanines[i]; + if (mez->data) + mez->depopulate(mez->data); + mez->data = NULL; + } +out_put_i2c1: + i2c_put_adapter(ls->i2c1); +out_put_i2c0: + i2c_put_adapter(ls->i2c0); + return ret; +} + +static int lscon_remove(struct platform_device *pdev) +{ + struct lscon *ls = platform_get_drvdata(pdev); + struct mezzanine *mez; + int i; + + /* Depopulate any populated boards */ + for (i = 0; i < ARRAY_SIZE(mezzanines); i++) { + mez = &mezzanines[i]; + if (mez->data) + mez->depopulate(mez->data); + mez->data = NULL; + } + + spi_controller_put(ls->spi); + i2c_put_adapter(ls->i2c1); + i2c_put_adapter(ls->i2c0); + + return 0; +} + +static const struct of_device_id lscon_of_match[] = { + { + .compatible = "96boards,low-speed-connector", + }, +}; + +static struct platform_driver lscon_driver = { + .driver = { + .name = "lscon", + .of_match_table = of_match_ptr(lscon_of_match), + }, + .probe = lscon_probe, + .remove = lscon_remove, +}; +builtin_platform_driver(lscon_driver); diff --git a/drivers/bus/96boards-mezzanines/96boards-mezzanines.h b/drivers/bus/96boards-mezzanines/96boards-mezzanines.h new file mode 100644 index 000000000000..f6a460766ff3 --- /dev/null +++ b/drivers/bus/96boards-mezzanines/96boards-mezzanines.h @@ -0,0 +1,46 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include +#include +#include + +/** + * enum mezzanine_ls_gpio - the GPIO lines on the low-speed connector + */ +enum mezzanine_ls_gpio { + MEZZANINE_LS_GPIO_A = 0, + MEZZANINE_LS_GPIO_B, + MEZZANINE_LS_GPIO_C, + MEZZANINE_LS_GPIO_D, + MEZZANINE_LS_GPIO_E, + MEZZANINE_LS_GPIO_F, + MEZZANINE_LS_GPIO_G, + MEZZANINE_LS_GPIO_H, + MEZZANINE_LS_GPIO_I, + MEZZANINE_LS_GPIO_J, + MEZZANINE_LS_GPIO_K, + MEZZANINE_LS_GPIO_L, +}; + +/** + * struct lscon - low speed connector state container + * @dev: containing device for this instance + */ +struct lscon { + struct device *dev; + struct i2c_adapter *i2c0; + struct i2c_adapter *i2c1; + struct spi_controller *spi; +}; + +struct gpio_desc *mezzanine_ls_get_gpiod(struct lscon *ls, + enum mezzanine_ls_gpio pin, + const char *consumer_name, + enum gpiod_flags flags); +void mezzanine_ls_put_gpiod(struct lscon *ls, struct gpio_desc *gpiod); + +#if IS_ENABLED(96BOARDS_SECURE96) +void *secure96_populate(struct lscon *ls); +void secure96_depopulate(void *data); +#endif +/* Add any other mezzanine population calls here */ diff --git a/drivers/bus/96boards-mezzanines/96boards-secure96.c b/drivers/bus/96boards-mezzanines/96boards-secure96.c new file mode 100644 index 000000000000..6c44a699d2e0 --- /dev/null +++ b/drivers/bus/96boards-mezzanines/96boards-secure96.c @@ -0,0 +1,249 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * 96boards Secure96 mezzanine board driver + * (C) 2018 Linus Walleij + */ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "96boards-mezzanines.h" + +struct secure96 { + struct device *dev; + struct lscon *ls; + struct platform_device *leds_device; + struct gpio_led *secure96_leds; + struct i2c_client *eeprom; + struct i2c_client *crypto; + struct i2c_client *hash; + struct gpio_desc *tpm_reset; + struct gpio_desc *tpm_irq; + struct spi_device *tpm; +}; + +struct secure96_ledinfo { + enum mezzanine_ls_gpio pin; + const char *ledname; +}; + +/* + * GPIO-F, G, H and I are connected to LEDs, two red and two green + */ +static const struct secure96_ledinfo ledinfos[] = { + { + .pin = MEZZANINE_LS_GPIO_F, + .ledname = "secure96:red:0", + }, + { + .pin = MEZZANINE_LS_GPIO_G, + .ledname = "secure96:red:1", + }, + { + .pin = MEZZANINE_LS_GPIO_H, + .ledname = "secure96:green:0", + }, + { + .pin = MEZZANINE_LS_GPIO_I, + .ledname = "secure96:green:1", + }, +}; + +/* + * The On Semiconductor CAT21M01 is 131072bits i.e. 16KB. This should be + * mostly compatible to 24c128 so we register that with special pdata so + * that we can fill in the GPIO descriptor for write protect. + */ +static struct at24_platform_data secure96_eeprom_pdata = { + .byte_len = SZ_16K / 8, + .page_size = 256, + .flags = AT24_FLAG_ADDR16, +}; + +static const struct i2c_board_info secure96_eeprom = { + I2C_BOARD_INFO("24c128", 0x50), + .platform_data = &secure96_eeprom_pdata, +}; + +/* Crypto chip */ +static const struct i2c_board_info secure96_crypto = { + I2C_BOARD_INFO("atecc508a", 0x60), +}; + +/* SHA hash chip */ +static const struct i2c_board_info secure96_hash = { + I2C_BOARD_INFO("atsha204a", 0x64), +}; + +/* Infineon SLB9670 TPM 2.0 chip */ +static struct spi_board_info secure96_tpm = { + .modalias = "tpm_tis_spi", + /* The manual says 22.5MHz for 1.8V supply */ + .max_speed_hz = 22500000, + .chip_select = 0, +}; + +void *secure96_populate(struct lscon *ls) +{ + struct device *dev = ls->dev; + struct secure96 *sec; + struct gpio_desc *gpiod; + struct gpio_led_platform_data secure96_leds_pdata; + int ret; + int i; + + /* TODO: create a struct device for secure96? */ + + sec = devm_kzalloc(dev, sizeof(*sec), GFP_KERNEL); + if (!sec) + return ERR_PTR(-ENOMEM); + sec->dev = dev; + sec->ls = ls; + + sec->secure96_leds = devm_kzalloc(dev, + ARRAY_SIZE(ledinfos) * sizeof(*sec->secure96_leds), + GFP_KERNEL); + if (!sec->secure96_leds) + return ERR_PTR(-ENOMEM); + + dev_info(ls->dev, "populate secure96\n"); + + /* Populate the four LEDs */ + for (i = 0; i < ARRAY_SIZE(ledinfos); i++) { + const struct secure96_ledinfo *linfo; + + linfo = &ledinfos[i]; + + gpiod = mezzanine_ls_get_gpiod(ls, linfo->pin, linfo->ledname, + GPIOD_OUT_LOW); + if (IS_ERR(gpiod)) { + dev_err(dev, "failed to get GPIO line %d\n", + linfo->pin); + return ERR_PTR(-ENODEV); + } + sec->secure96_leds[i].gpiod = gpiod; + sec->secure96_leds[i].name = linfo->ledname; + /* Heartbeat on first LED */ + if (i == 0) + sec->secure96_leds[i].default_trigger = "heartbeat"; + } + + secure96_leds_pdata.num_leds = ARRAY_SIZE(ledinfos); + secure96_leds_pdata.leds = sec->secure96_leds; + + sec->leds_device = platform_device_register_data(dev, + "leds-gpio", + PLATFORM_DEVID_AUTO, + &secure96_leds_pdata, + sizeof(secure96_leds_pdata)); + if (IS_ERR(sec->leds_device)) { + dev_err(dev, "failed to populate LEDs device\n"); + return ERR_PTR(-ENODEV); + } + + /* Populate the three I2C0 devices */ + gpiod = mezzanine_ls_get_gpiod(ls, MEZZANINE_LS_GPIO_B, "cat21m01-wp", + GPIOD_OUT_HIGH); + if (IS_ERR(gpiod)) + dev_err(dev, "no CAT21M01 write-protect GPIO\n"); + else + secure96_eeprom_pdata.wp_gpiod = gpiod; + sec->eeprom = i2c_new_device(ls->i2c0, &secure96_eeprom); + if (!sec->eeprom) { + dev_err(dev, "failed to populate EEPROM\n"); + ret = -ENODEV; + goto out_unreg_leds; + } + + sec->crypto = i2c_new_device(ls->i2c0, &secure96_crypto); + if (!sec->eeprom) { + dev_err(dev, "failed to populate crypto device\n"); + ret = -ENODEV; + goto out_remove_eeprom; + } + + sec->hash = i2c_new_device(ls->i2c0, &secure96_hash); + if (!sec->eeprom) { + dev_err(dev, "failed to populate hash device\n"); + ret = -ENODEV; + goto out_remove_crypto; + } + + /* Populate the SPI TPM device */ + gpiod = mezzanine_ls_get_gpiod(ls, MEZZANINE_LS_GPIO_D, + "tpm-slb9670-rst", + GPIOD_OUT_LOW); + if (IS_ERR(gpiod)) { + dev_err(dev, "failed to get TPM RESET\n"); + ret = -ENODEV; + goto out_remove_hash; + } + udelay(80); + /* Deassert RST */ + gpiod_set_value(gpiod, 1); + sec->tpm_reset = gpiod; + + gpiod = mezzanine_ls_get_gpiod(ls, MEZZANINE_LS_GPIO_C, + "tpm-slb9670-irq", + GPIOD_IN); + if (IS_ERR(gpiod)) { + dev_err(dev, "failed to get TPM IRQ GPIO\n"); + ret = -ENODEV; + goto out_remove_tpm_reset; + } + sec->tpm_irq = gpiod; + secure96_tpm.irq = gpiod_to_irq(gpiod); + sec->tpm = spi_new_device(ls->spi, &secure96_tpm); + if (!sec->tpm) { + dev_err(dev, "failed to populate TPM device\n"); + ret = -ENODEV; + goto out_remove_tpm_irq; + } + + return sec; + +out_remove_tpm_irq: + mezzanine_ls_put_gpiod(ls, sec->tpm_irq); +out_remove_tpm_reset: + mezzanine_ls_put_gpiod(ls, sec->tpm_reset); +out_remove_hash: + i2c_unregister_device(sec->hash); +out_remove_crypto: + i2c_unregister_device(sec->crypto); +out_remove_eeprom: + i2c_unregister_device(sec->eeprom); + if (secure96_eeprom_pdata.wp_gpiod) + mezzanine_ls_put_gpiod(ls, secure96_eeprom_pdata.wp_gpiod); +out_unreg_leds: + platform_device_unregister(sec->leds_device); + for (i = 0; i < ARRAY_SIZE(ledinfos); i++) { + mezzanine_ls_put_gpiod(ls, sec->secure96_leds[i].gpiod); + }; + return ERR_PTR(ret); +} +EXPORT_SYMBOL_GPL(secure96_populate); + +void secure96_depopulate(void *data) +{ + struct secure96 *sec = data; + int i; + + spi_unregister_device(sec->tpm); + mezzanine_ls_put_gpiod(sec->ls, sec->tpm_irq); + mezzanine_ls_put_gpiod(sec->ls, sec->tpm_reset); + i2c_unregister_device(sec->hash); + i2c_unregister_device(sec->crypto); + i2c_unregister_device(sec->eeprom); + if (secure96_eeprom_pdata.wp_gpiod) + mezzanine_ls_put_gpiod(sec->ls, secure96_eeprom_pdata.wp_gpiod); + platform_device_unregister(sec->leds_device); + for (i = 0; i < ARRAY_SIZE(ledinfos); i++) { + mezzanine_ls_put_gpiod(sec->ls, sec->secure96_leds[i].gpiod); + }; +} +EXPORT_SYMBOL_GPL(secure96_depopulate); diff --git a/drivers/bus/96boards-mezzanines/Kconfig b/drivers/bus/96boards-mezzanines/Kconfig new file mode 100644 index 000000000000..18f94e9ec0f8 --- /dev/null +++ b/drivers/bus/96boards-mezzanines/Kconfig @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# 96boards mezzanine connectors and drivers + +menuconfig 96BOARDS_MEZZANINES + bool "96boards mezzanine boards" + +if 96BOARDS_MEZZANINES + +config 96BOARDS_LS_CONNECTOR + bool "96boards low speed connector driver" + depends on OF + depends on I2C + depends on SPI_MASTER + depends on GPIOLIB + help + Driver for the 96boards low speed connector + +config 96BOARDS_SECURE96 + bool "96boards Secure96 board driver" + depends on 96BOARDS_LS_CONNECTOR + select NEW_LEDS + select LEDS_CLASS + select LEDS_GPIO + select EEPROM_AT24 + select CRYPTO_HW + select CRYPTO_DEV_ATMEL_ECC + select HW_RANDOM + select TCG_TPM + select HW_RANDOM_TPM + select TCG_TIS + select TCG_TIS_SPI + help + Driver for the 96boards Secure96 mezzanine + +endif diff --git a/drivers/bus/96boards-mezzanines/Makefile b/drivers/bus/96boards-mezzanines/Makefile new file mode 100644 index 000000000000..a6e1f3507672 --- /dev/null +++ b/drivers/bus/96boards-mezzanines/Makefile @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Makefile for the 96boards mezzanines +# +obj-$(CONFIG_96BOARDS_LS_CONNECTOR) += 96boards-ls-connector.o +obj-$(CONFIG_96BOARDS_SECURE96) += 96boards-secure96.o diff --git a/drivers/bus/Kconfig b/drivers/bus/Kconfig index d1c0b60e9326..46f7785f27e9 100644 --- a/drivers/bus/Kconfig +++ b/drivers/bus/Kconfig @@ -173,4 +173,6 @@ config DA8XX_MSTPRI source "drivers/bus/fsl-mc/Kconfig" +source "drivers/bus/96boards-mezzanines/Kconfig" + endmenu diff --git a/drivers/bus/Makefile b/drivers/bus/Makefile index b8f036cca7ff..f6d080a63bd7 100644 --- a/drivers/bus/Makefile +++ b/drivers/bus/Makefile @@ -29,5 +29,7 @@ obj-$(CONFIG_TI_SYSC) += ti-sysc.o obj-$(CONFIG_TS_NBUS) += ts-nbus.o obj-$(CONFIG_UNIPHIER_SYSTEM_BUS) += uniphier-system-bus.o obj-$(CONFIG_VEXPRESS_CONFIG) += vexpress-config.o - obj-$(CONFIG_DA8XX_MSTPRI) += da8xx-mstpri.o + +# 96boards mezzanines +obj-$(CONFIG_96BOARDS_MEZZANINES) += 96boards-mezzanines/ From patchwork Mon Jun 18 07:45:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 138861 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp3643973lji; Mon, 18 Jun 2018 00:46:24 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJKPF0LL9sKcwD0scQhtnPYyUyb6VXaXsa0uDfhSNVmrGCO8yMkZKHHnO4v5r9OpSAhukag X-Received: by 2002:a17:902:e281:: with SMTP id cf1-v6mr12959168plb.86.1529307984864; Mon, 18 Jun 2018 00:46:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529307984; cv=none; d=google.com; s=arc-20160816; b=We6DFDOfYGjcyEIlwUQH5VSYSvSWDNuD4bp/jLd0iEK0MQ7NNSpe8qqCAQeF9PhSCq hO6d+VWfoCnnw9tGkca9LJVeC4tLDyIJF46Xn5fIyzf3B6DWgPd+qV6RoiClUC1eOLXi cU2fr2l5GjiRtcezRivkRtwf98UjityfC78rzV/QNh/kyU81SEXpSnBi8Oc8jNDiD9+X c2Q3Xc47wcojdgAe9y8NQk042LKCU9VpjYq36rtAJ2xLc9bD2BohoQZ0c6asWdayP2mf xKlV8/W1H9AfyI2BzIJ0iKO16nRNZ1qN/lOyyWKlXc9pZaPpdDGoWecpxpnhE7n7mHwR Gelg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=EWEIXoRN9SWaVlVhOpLl08y8ik5mNGHsbD/HmsqaZDQ=; b=Chiec7cJl3+T8/G4lsJLwE2Zq6T6dhMGQa99t+CfTTr3myz7vqcG9yjp/r4zSqsmjs kHLGfmitSCBL15op5eN1soyuc6AmS+UXJwNJxctE/gQJqFOtqO5jRDny87792ToDK9YN T4rIS6Eiirsl+hvAh6QU97Zx9m3RvYFR6IzKgK4erU1P2yZ6DnB/B4tA38dE/0+hAxYf +6uocplGO3QNglEd7iaMlC+crB44pCyz6WHg8qj1CclBdn0iW6+AEJa0mBX+L5a1vlzY TAqnbvhVJaksCosffjEN74z1ueRf62Gpf/FWHfGdGQ4xm21g4668daOEAfjatHK2EvjZ V94w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=bhP9eF35; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w2-v6si11655956pgs.59.2018.06.18.00.46.24; Mon, 18 Jun 2018 00:46:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=bhP9eF35; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755232AbeFRHqY (ORCPT + 5 others); Mon, 18 Jun 2018 03:46:24 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:42983 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754983AbeFRHqX (ORCPT ); Mon, 18 Jun 2018 03:46:23 -0400 Received: by mail-lf0-f68.google.com with SMTP id z207-v6so1739938lff.9 for ; Mon, 18 Jun 2018 00:46:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OlGzRwAnBRBCEgiXp+1cMtmNLHQk8qc/Q/u3JXxs9JM=; b=bhP9eF35tVXK/gFdsHbLImdZ6DphzUqJwCjqX3GVG0SLIflaRbYG+zsnzBRUhkFwhp lzXlT1+V+BqRJOIGBvFvr/ywAWa45bVJY3+m06lfiMFOk9uT66K6H6+IM75nqMfJ8hwz rtfnUgJqi0y/8Ew7SJNhuC8MjaYde3+H2i+qw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OlGzRwAnBRBCEgiXp+1cMtmNLHQk8qc/Q/u3JXxs9JM=; b=Iq/OghhUjyEExXcBvsWoMWf+l8aEI75RpLMluW18atT4VC59J0R3LG2waIcB1hVHKY QeXLc4eL24/gpaSIyRk1usncRRI1EIHpO3pcNBvLppAJANLZLMQjpnXlgyjF3eEfB9g4 DZa+lWMDzq6rfWDcjHCKTQqjGNKiKMwH5ttb9I2dfXiURA41hy0vaYtWTfZQrypLWjLE HhdmFlXoaVh8d7GddrZ3oEK+orQpbDEV0bpPYYGFF7Ad0sUlpFnj307Kj+Pyoto/UlVq Gp4ATpLyWHtroKm7oBpyJknhACI0oe+2N5QvCirrzm+YcckruiBnZfjOiZF4Sd6pRZJJ yNew== X-Gm-Message-State: APt69E3EAmc4Yu+3HK5DjB6dFoURQqXgXkDhMZZckMLUQ/bbVaIBx3Si nEySgv3b3ye1/VHj3pd8vAlshA== X-Received: by 2002:a2e:18b:: with SMTP id f11-v6mr7304793lji.83.1529307981992; Mon, 18 Jun 2018 00:46:21 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id x18-v6sm2616390ljh.63.2018.06.18.00.46.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 00:46:20 -0700 (PDT) From: Linus Walleij To: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, dev@lists.96boards.org Cc: John Stultz , Manivannan Sadhasivam , Rob Herring , Mark Rutland , Frank Rowand , Mark Brown , Michal Simek , Andy Shevchenko , Mika Westerberg , Arnd Bergmann , Linus Walleij Subject: [PATCH 5/5] RFC: ARM64: dts: Add Low-Speed Connector to ZCU100 Date: Mon, 18 Jun 2018 09:45:56 +0200 Message-Id: <20180618074556.6944-6-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180618074556.6944-1-linus.walleij@linaro.org> References: <20180618074556.6944-1-linus.walleij@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org This adds the low-speed connector to the ZCU100 rev C device tree (also known as the Ultra96 board). This is a proof-of-concept only, showing how it is possible to populate a Secure96 board using the other patches in the series. If you comment out or delete the board {} node, you can populate/depopulate the board from sysfs instead. Signed-off-by: Linus Walleij --- .../boot/dts/xilinx/zynqmp-zcu100-revC.dts | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) -- 2.17.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/arm64/boot/dts/xilinx/zynqmp-zcu100-revC.dts b/arch/arm64/boot/dts/xilinx/zynqmp-zcu100-revC.dts index d62276e0e0a9..fc30497f248d 100644 --- a/arch/arm64/boot/dts/xilinx/zynqmp-zcu100-revC.dts +++ b/arch/arm64/boot/dts/xilinx/zynqmp-zcu100-revC.dts @@ -110,6 +110,28 @@ compatible = "mmc-pwrseq-simple"; reset-gpios = <&gpio 7 GPIO_ACTIVE_LOW>; /* WIFI_EN */ }; + + lscon: connector { + compatible = "96boards,low-speed-connector"; + i2c0 = <&i2csw_0>; + i2c1 = <&i2csw_1>; + spi = <&spi0>; + gpios = <&gpio 36 GPIO_ACTIVE_HIGH>, /* GPIO-A */ + <&gpio 37 GPIO_ACTIVE_HIGH>, /* GPIO-B */ + <&gpio 39 GPIO_ACTIVE_HIGH>, /* GPIO-C */ + <&gpio 40 GPIO_ACTIVE_HIGH>, /* GPIO-D */ + <&gpio 44 GPIO_ACTIVE_HIGH>, /* GPIO-E */ + <&gpio 45 GPIO_ACTIVE_HIGH>, /* GPIO-F */ + <&gpio 78 GPIO_ACTIVE_HIGH>, /* GPIO-G */ + <&gpio 79 GPIO_ACTIVE_HIGH>, /* GPIO-H */ + <&gpio 80 GPIO_ACTIVE_HIGH>, /* GPIO-I */ + <&gpio 81 GPIO_ACTIVE_HIGH>, /* GPIO-J */ + <&gpio 82 GPIO_ACTIVE_HIGH>, /* GPIO-K */ + <&gpio 83 GPIO_ACTIVE_HIGH>; /* GPIO-L */ + board { + compatible = "96boards,secure96"; + }; + }; }; &dcc { @@ -134,8 +156,9 @@ "USB1_DIR", "USB1_DATA2", "USB1_NXT", "USB1_DATA0", "USB1_DATA1", "USB1_STP", "USB1_DATA3", "USB1_DATA4", "USB1_DATA5", "USB1_DATA6", "USB_DATA7", "WLAN_IRQ", "PMIC_IRQ", /* MIO end and EMIO start */ - "", "", - "", "", "", "", "", "", "", "", "", "", + "GPIO-G", "GPIO-H", + "GPIO-I", "GPIO-J", "GPIO-K", "GPIO-L", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",