From patchwork Wed Jan 17 08:54:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 124794 Delivered-To: patch@linaro.org Received: by 10.46.64.148 with SMTP id r20csp1309462lje; Wed, 17 Jan 2018 00:59:43 -0800 (PST) X-Google-Smtp-Source: ACJfBovTNZnygfQysHK3e7wQy0gj3hAguZYcBa4KKTR4V8CvJlkHtMf6QKX67iLhNjG3fVvFahPM X-Received: by 10.80.138.208 with SMTP id k16mr1895641edk.181.1516179583654; Wed, 17 Jan 2018 00:59:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516179583; cv=none; d=google.com; s=arc-20160816; b=A/EygFy8FzrSplHHEPcq6XuENd5HFq23FB4DHIgHGOcjGdBUaAx8YyvOUM9A1q2Y9F BzM0ZFX62+uoQgJgp+DadmWwXvCBk/1Pbl7R83qHZnMSpgtMThnxDxjSso80cNsfcryp UUzKWA7dFz39MVX3M+79053DUTxYXEeL8Nah7eWyaJKt7rKKxaSoc4z/fT1kIWaoZ7MK X4GchMzsU2u5JckmmRsF5ZxeXgDE+Q4UPlS7KENHQh8POR6pr1zO6w7jz3SX5Ahqvsld s8t/RsnskCgfhr1B3TTsggfV/s62b2vAadeysTJIDPiwP7ExdxLG+dMyrAzJjDHw28CN tmjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:arc-authentication-results; bh=LKp5DLqGmpACn8zPdjaaDeVBxqRnnrIKsHyx6Pu1Qw8=; b=g8UIQtNr1hIKZ5t091LZPnQXZ6qB2c2HuTwrwWHZ55RZid06oW5D37itJqAO8dLFKi qwlww0eRgkqUoEEO+Kcm3sPBmKvjt0xY/j8PHytuVf8B1b2F/TcmOmJU6dV2e/P71u+e Gj5LlTrsPQB6qKthkGpdbJHQBx1Aeao6rHzc6lNuQQsVbG9jbT8zhruLjOuymzd6GuQy ye1Bi+EYyp+JlqFUwfDQoKmOd8H0FfUMsrml664iNxJ8sGpIUn3FvzOG2gOJufgzmuLW zmJG8umoPmncyyVRxeT4ogjppMRFyNzt5xuY77mZAyfD0hCHE/p/B4ifxgw3gjNjGVyp rcnw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id 36si2166089edk.378.2018.01.17.00.59.43; Wed, 17 Jan 2018 00:59:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 3B55CC21E18; Wed, 17 Jan 2018 08:56:51 +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_DNSWL_BLOCKED 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 E8FF8C21E70; Wed, 17 Jan 2018 08:55:05 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 6FE02C21C50; Wed, 17 Jan 2018 08:55:00 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id A0095C21DDF for ; Wed, 17 Jan 2018 08:54:59 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 19635AEF3; Wed, 17 Jan 2018 08:54:59 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Wed, 17 Jan 2018 09:54:52 +0100 Message-Id: <20180117085458.27293-2-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180117085458.27293-1-agraf@suse.de> References: <20180117085458.27293-1-agraf@suse.de> Cc: Heinrich Schuchardt Subject: [U-Boot] [PATCH v2 1/7] serial: Use next serial device if probing fails 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" Currently our serial device search chokes on the fact that the serial probe function could fail. If it does, instead of searching for the next usable serial device, it just quits. This patch changes the fallback logic so that even when a serial device was not probed correctly, we just try the next ones until we find one that works. Signed-off-by: Alexander Graf Reviewed-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v1 -> v2: - Make search logic easier to follow --- drivers/serial/serial-uclass.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c index 2e5116f7ce..68ca2d09d1 100644 --- a/drivers/serial/serial-uclass.c +++ b/drivers/serial/serial-uclass.c @@ -74,6 +74,7 @@ static void serial_find_console_or_panic(void) { const void *blob = gd->fdt_blob; struct udevice *dev; + int ret; if (CONFIG_IS_ENABLED(OF_PLATDATA)) { uclass_first_device(UCLASS_SERIAL, &dev); @@ -104,8 +105,8 @@ static void serial_find_console_or_panic(void) * from 1!). * * Failing that, get the device with sequence number 0, or in - * extremis just the first serial device we can find. But we - * insist on having a console (even if it is silent). + * extremis just the first working serial device we can find. + * But we insist on having a console (even if it is silent). */ #ifdef CONFIG_CONS_INDEX #define INDEX (CONFIG_CONS_INDEX - 1) @@ -113,10 +114,22 @@ static void serial_find_console_or_panic(void) #define INDEX 0 #endif if (!uclass_get_device_by_seq(UCLASS_SERIAL, INDEX, &dev) || - !uclass_get_device(UCLASS_SERIAL, INDEX, &dev) || - (!uclass_first_device(UCLASS_SERIAL, &dev) && dev)) { - gd->cur_serial_dev = dev; - return; + !uclass_get_device(UCLASS_SERIAL, INDEX, &dev)) { + if (dev->flags & DM_FLAG_ACTIVATED) { + gd->cur_serial_dev = dev; + return; + } + } + + /* Search for any working device */ + for (ret = uclass_first_device_check(UCLASS_SERIAL, &dev); + dev; + ret = uclass_next_device_check(&dev)) { + if (!ret) { + /* Device did succeed probing */ + gd->cur_serial_dev = dev; + return; + } } #undef INDEX } From patchwork Wed Jan 17 08:54:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 124789 Delivered-To: patch@linaro.org Received: by 10.46.64.148 with SMTP id r20csp1309053lje; Wed, 17 Jan 2018 00:57:25 -0800 (PST) X-Google-Smtp-Source: ACJfBotd5RjjAGXcth8jWtAMV2FRgDX3HX8moNtZ8Uai8SEN30SH6reOwXfHMG68UoQ+peUNntMR X-Received: by 10.80.148.16 with SMTP id p16mr1906251eda.68.1516179445640; Wed, 17 Jan 2018 00:57:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516179445; cv=none; d=google.com; s=arc-20160816; b=CAXdsLX5FbgtJZuFBrv0KhSqAFwq7v21LknkEDrXp+rwhy0f0Wdgq1LY8N/rvIU1K4 Q6T+aNancyxK57iohjV7yw1kJ5K47a9WvNft7vChAM++22HdaqSLcAmruyEZ6OzD3LxD +NOz6HgxNAIvzkDZO6vZGr8NKGMPWjlj3C5GjBXMAqp28dzKEceENT4s3LFiF2LKLUTI I47oCa2ljRUTrzsu/71wLnQe8uWqDKpJ5DqdvtB9uu3Sm8zpiNW3PQDAS3UoBsEElG0Y AMNptlTfdtd18SZ0Lbd6CHm20tKXbA3wlJAnSgZSAUdn+UGt0ZzDZimByyeodEwWn5kt XCPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:arc-authentication-results; bh=SsnJncwm8FQXavWrAXpK31M3kVfIUpqfH15tzfY8768=; b=vDQGpE6YtzIxTIGgtZrqy1Cypzs70l97Q4xORim1X/sXNH5+K9+F7C5trbcwII5FDx 4z6926N6RWY4dlYstBzE10dTLg9BrLOX73+3apJkGA8zpMFUmMNjrN0Dq2/hrbrUPvCx ccWPb0/A+MIxlwQSzDj7mUc1SonQ/i3bh1RvmBJ0Iq/8wA52lVq3cUUtGUwQKfV9DjIr zaMOVkeqHk2rgxYgyVFfcAi9HuKN4Z7JM36wId6ECZOOrmCH4Ov9bSgtXTCd5I3Nt9zd otV04JCfayNaj/pc8E0z6BPlT//62eg8j9wGzNmHYU8FwlWREI4qRzoKig5EQfIXAamF Qi1w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id 34si4187411edp.249.2018.01.17.00.57.25; Wed, 17 Jan 2018 00:57:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 06F47C21DE8; Wed, 17 Jan 2018 08:55:25 +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_DNSWL_BLOCKED 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 292ACC21E11; Wed, 17 Jan 2018 08:55:02 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E9A8BC21CA6; Wed, 17 Jan 2018 08:54:59 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 87DB8C21CA6 for ; Wed, 17 Jan 2018 08:54:59 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 1828CAEED; Wed, 17 Jan 2018 08:54:59 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Wed, 17 Jan 2018 09:54:53 +0100 Message-Id: <20180117085458.27293-3-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180117085458.27293-1-agraf@suse.de> References: <20180117085458.27293-1-agraf@suse.de> Cc: Heinrich Schuchardt Subject: [U-Boot] [PATCH v2 2/7] serial: Allow boards to determine whether a serial device is usable 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" On some boards, serial devices may or may not be muxed properly to actual pins, depending on firmware configuration. To determine whether we should use a serial device for U-Boot in-/output, we need to check whether it is muxed properly. This is something only the board file can do, so let's expose a weak function that a board can override to explicitly allow or disallow usage of certain serial devices. Signed-off-by: Alexander Graf --- drivers/serial/serial-uclass.c | 11 +++++++++++ include/serial.h | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c index 68ca2d09d1..ecd64f8e86 100644 --- a/drivers/serial/serial-uclass.c +++ b/drivers/serial/serial-uclass.c @@ -366,6 +366,16 @@ static int on_baudrate(const char *name, const char *value, enum env_op op, U_BOOT_ENV_CALLBACK(baudrate, on_baudrate); #if CONFIG_IS_ENABLED(SERIAL_PRESENT) +__weak int board_check_serial(struct udevice *dev) +{ + return 0; +} + +static int serial_pre_probe(struct udevice *dev) +{ + return board_check_serial(dev); +} + static int serial_post_probe(struct udevice *dev) { struct dm_serial_ops *ops = serial_get_ops(dev); @@ -438,6 +448,7 @@ UCLASS_DRIVER(serial) = { .name = "serial", .flags = DM_UC_FLAG_SEQ_ALIAS, .post_probe = serial_post_probe, + .pre_probe = serial_pre_probe, .pre_remove = serial_pre_remove, .per_device_auto_alloc_size = sizeof(struct serial_dev_priv), }; diff --git a/include/serial.h b/include/serial.h index d87f01082a..221b3e1402 100644 --- a/include/serial.h +++ b/include/serial.h @@ -207,4 +207,15 @@ void sh_serial_initialize(void); void uartlite_serial_initialize(void); void zynq_serial_initialize(void); +/** + * board_check_serial() - Determine whether a serial device works + * + * This is a board callback that allows boards to override whether a serial + * device is usable. By default, all devices are declared usable. + * + * @dev: Device pointer + * @return 0 if the device is usable, !0 otherwise + */ +int board_check_serial(struct udevice *dev); + #endif From patchwork Wed Jan 17 08:54:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 124790 Delivered-To: patch@linaro.org Received: by 10.46.64.148 with SMTP id r20csp1309159lje; Wed, 17 Jan 2018 00:57:56 -0800 (PST) X-Google-Smtp-Source: ACJfBovT0cddQapBd8HTBsGjPKRisXAlZY1ZUTxOFAt3DFnXn0CA/AaQAXgZHCPOCrMTMIe9vFvm X-Received: by 10.80.184.20 with SMTP id j20mr1883344ede.5.1516179476411; Wed, 17 Jan 2018 00:57:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516179476; cv=none; d=google.com; s=arc-20160816; b=UfrDNCFq00ytsC7q3Klf8xvaj/BBRLqIsUKGYUqxKtew53bAWQhx28JuI/gm5XtT07 MGqxyrl0gupr1wtm5K8+o1zZunO+65g3bYa5CBBGaOsCbU/frxfXTGMMhwyqfm20M47F oeu+YbmNF5x2pRA3JlEl//0GOBmxeokz9nbKWsLXOTJWozBjz24irCaoZexCQVwLR1/f ze/h4JrV64rp+IIHCbPsup0AEnIwWLBFY8UhoWrnNaYcP+d77DsXBkBEQl9/2ekSf4NA 0tYoi0XkQ6Q5Lg2Ga0hUbcoJMMohzdMn7wWwxFZ7Dd1gSQH6uJhhAVSTlwRYzCYcz71k OW3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:arc-authentication-results; bh=tfKFDOghbvJjez3iHmklb1qL5YdjG9EK15whrQBaeQQ=; b=UYm7q+yTfi+xNFNjvfIQHmFfooKgGOOQsMbjvg7Fvw0I0LrJ2pIklpCOo02wlokNNl nF6mDJ/obkx3ZzEMIkvyAF6+QjaMD4qFIIQx4C0w+d6wNxzYlh5hIKEcl8F4nvfH4tTS 1um0l8jJjWYQXE4BommhPwa5Y92Jz0Lhet30pHYIKsBDmYnUly4MDY/EUGWkdReT4hSn 5wA8uyZwwhuFexkU8nIoHfhwgVzTJt+O7UjyF+t2+y0eeaqKd8A6NPtsm89647/7DJA+ umuul0M8PelMet4ccFnfqkx28Olu5uogXyhxAEoeLUZiVfQdlyWfB+/+WOj3u+uqyZVg Z0Mw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id n30si1063276edc.416.2018.01.17.00.57.56; Wed, 17 Jan 2018 00:57:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 0CBBFC21E45; Wed, 17 Jan 2018 08:56:17 +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_DNSWL_BLOCKED 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 DC228C21E4E; Wed, 17 Jan 2018 08:55:03 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 48409C21CA6; Wed, 17 Jan 2018 08:55:00 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 9F2D4C21DD9 for ; Wed, 17 Jan 2018 08:54:59 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 17A80AEBE; Wed, 17 Jan 2018 08:54:59 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Wed, 17 Jan 2018 09:54:54 +0100 Message-Id: <20180117085458.27293-4-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180117085458.27293-1-agraf@suse.de> References: <20180117085458.27293-1-agraf@suse.de> Cc: Heinrich Schuchardt Subject: [U-Boot] [PATCH v2 3/7] rpi: Remove runtime disabling support for serial 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" We are switching to a model where our board file can directly fail probing of serial devices when they're not usable, so remove the current runtime hack we have. Signed-off-by: Alexander Graf --- arch/arm/mach-bcm283x/include/mach/gpio.h | 1 - board/raspberrypi/rpi/rpi.c | 43 ------------------------------- drivers/gpio/bcm2835_gpio.c | 2 +- 3 files changed, 1 insertion(+), 45 deletions(-) diff --git a/arch/arm/mach-bcm283x/include/mach/gpio.h b/arch/arm/mach-bcm283x/include/mach/gpio.h index 751594d09f..1bcb5846ca 100644 --- a/arch/arm/mach-bcm283x/include/mach/gpio.h +++ b/arch/arm/mach-bcm283x/include/mach/gpio.h @@ -61,7 +61,6 @@ struct bcm2835_gpio_platdata { unsigned long base; }; -int bcm2835_gpio_get_func_id(struct udevice *dev, unsigned gpio); void bcm2835_gpio_set_pinmux(struct udevice *dev, int handle); #endif /* _BCM2835_GPIO_H_ */ diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c index 3b7a54f519..a96d5d8952 100644 --- a/board/raspberrypi/rpi/rpi.c +++ b/board/raspberrypi/rpi/rpi.c @@ -419,54 +419,11 @@ static void get_board_rev(void) printf("RPI %s (0x%x)\n", model->name, revision); } -#ifndef CONFIG_PL01X_SERIAL -static bool rpi_is_serial_active(void) -{ - int serial_gpio = 15; - struct udevice *dev; - - /* - * The RPi3 disables the mini uart by default. The easiest way to find - * out whether it is available is to check if the RX pin is muxed. - */ - - if (uclass_first_device(UCLASS_GPIO, &dev) || !dev) - return true; - - if (bcm2835_gpio_get_func_id(dev, serial_gpio) != BCM2835_GPIO_ALT5) - return false; - - return true; -} - -/* Disable mini-UART I/O if it's not pinmuxed to our pins. - * The firmware only enables it if explicitly done in config.txt: enable_uart=1 - */ -static void rpi_disable_inactive_uart(void) -{ - struct udevice *dev; - struct bcm283x_mu_serial_platdata *plat; - - if (uclass_get_device_by_driver(UCLASS_SERIAL, - DM_GET_DRIVER(serial_bcm283x_mu), - &dev) || !dev) - return; - - if (!rpi_is_serial_active()) { - plat = dev_get_platdata(dev); - plat->disabled = true; - } -} -#endif - int board_init(void) { #ifdef CONFIG_HW_WATCHDOG hw_watchdog_init(); #endif -#ifndef CONFIG_PL01X_SERIAL - rpi_disable_inactive_uart(); -#endif get_board_rev(); diff --git a/drivers/gpio/bcm2835_gpio.c b/drivers/gpio/bcm2835_gpio.c index 209cbed9e6..3edd90ea97 100644 --- a/drivers/gpio/bcm2835_gpio.c +++ b/drivers/gpio/bcm2835_gpio.c @@ -73,7 +73,7 @@ static int bcm2835_gpio_set_value(struct udevice *dev, unsigned gpio, return 0; } -int bcm2835_gpio_get_func_id(struct udevice *dev, unsigned gpio) +static int bcm2835_gpio_get_func_id(struct udevice *dev, unsigned gpio) { struct bcm2835_gpios *gpios = dev_get_priv(dev); u32 val; From patchwork Wed Jan 17 08:54:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 124787 Delivered-To: patch@linaro.org Received: by 10.46.64.148 with SMTP id r20csp1308604lje; Wed, 17 Jan 2018 00:55:08 -0800 (PST) X-Google-Smtp-Source: ACJfBouK7YOS63hCKi0bSont+2lxo38PWjjh2OQ/Im16jirFzs9TzpScKvFt9uJy/yUmwULHllH1 X-Received: by 10.80.179.146 with SMTP id s18mr1900256edd.190.1516179308460; Wed, 17 Jan 2018 00:55:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516179308; cv=none; d=google.com; s=arc-20160816; b=o8fuDP2ROINfakrqup5T59gQqgSScp8OR33PioI4KqUlOk0pEv/+JLmVaacBPWnu6N eCEko+ZMfQk9yubZSKT+a5KR3hwSpp6W0W8cNviE5ph8pDoQA6YbKSxyjy6kOdRnSXjk JRP/OczrDv0kqtXbAGsH2oWIm8JW8RPnu5LuPsRGLgodLeIngPlaNBNsUTetxedUizMK s2DzoLH4kSUaO8uLUFW5AdUbuYxsbY2n9sufDOIFQOpRQJd4nAdDdkeGtIj47D+Gh+mX aoPb/yPMgHgtsDs8gHVYwh8qBVY3ZywPf7OPmPzotfWmjopFsNeN+Hp42Ufzcj9FHh8t 5J9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:arc-authentication-results; bh=HJqILOaDFKg7ohORG24VvFdjWHLuwXj53eUdG+GG74I=; b=rOctOjfe5vTJgzXE+DbGP1ljbQyUUwlGQfamdnSoq/SJmGc86UGAeKpeUognzFaPY5 LuLOtgswR8bPhfIWLKMqqS0xJW+OvI4/iTCJSrJAt4YGVUdgvdnx186Whpj4d1fSkQb9 NPppB7UPKRqXW9320HvaDTFT7m6isk3dtKtf52QsoJsPtF6tPOdBbINb30yWsj3q5OS9 9s81Y3/02LUAhmSfkac6/EFqsoebqvDd2WZqhS18/rSAxMbmFC9yrPTZvCWu1kXBZBRH 0du4XlxQ9GTt/Hk0nWSGtFtA3r0nhtAXJR6sHjH9NCfgz8xmWOWAdGVa65REi8veKzXC 0Iag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id 90si4248596edp.552.2018.01.17.00.55.08; Wed, 17 Jan 2018 00:55:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id ECB35C21E7F; Wed, 17 Jan 2018 08:55:04 +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_DNSWL_BLOCKED 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 9C861C21CA6; Wed, 17 Jan 2018 08:55:01 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id DF29DC21E0C; Wed, 17 Jan 2018 08:54:59 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 92016C21DB5 for ; Wed, 17 Jan 2018 08:54:59 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 17931AEBA; Wed, 17 Jan 2018 08:54:59 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Wed, 17 Jan 2018 09:54:55 +0100 Message-Id: <20180117085458.27293-5-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180117085458.27293-1-agraf@suse.de> References: <20180117085458.27293-1-agraf@suse.de> Cc: Heinrich Schuchardt Subject: [U-Boot] [PATCH v2 4/7] serial: bcm283x_mu: Remove support for post-init disabling 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" We are switching to a model where a serial device doesn't even get probed when it's not muxed properly, so we don't need device specific disabling functionality anymore. Signed-off-by: Alexander Graf --- drivers/serial/serial_bcm283x_mu.c | 18 +----------------- include/dm/platform_data/serial_bcm283x_mu.h | 1 - 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/drivers/serial/serial_bcm283x_mu.c b/drivers/serial/serial_bcm283x_mu.c index 41c26b3d93..7ce990b9b8 100644 --- a/drivers/serial/serial_bcm283x_mu.c +++ b/drivers/serial/serial_bcm283x_mu.c @@ -59,7 +59,7 @@ static int bcm283x_mu_serial_setbrg(struct udevice *dev, int baudrate) struct bcm283x_mu_regs *regs = priv->regs; u32 divider; - if (plat->disabled || plat->skip_init) + if (plat->skip_init) return 0; divider = plat->clock / (baudrate * 8); @@ -75,9 +75,6 @@ static int bcm283x_mu_serial_probe(struct udevice *dev) struct bcm283x_mu_serial_platdata *plat = dev_get_platdata(dev); struct bcm283x_mu_priv *priv = dev_get_priv(dev); - if (plat->disabled) - return -ENODEV; - priv->regs = (struct bcm283x_mu_regs *)plat->base; return 0; @@ -85,14 +82,10 @@ static int bcm283x_mu_serial_probe(struct udevice *dev) static int bcm283x_mu_serial_getc(struct udevice *dev) { - struct bcm283x_mu_serial_platdata *plat = dev_get_platdata(dev); struct bcm283x_mu_priv *priv = dev_get_priv(dev); struct bcm283x_mu_regs *regs = priv->regs; u32 data; - if (plat->disabled) - return -EAGAIN; - /* Wait until there is data in the FIFO */ if (!(readl(®s->lsr) & BCM283X_MU_LSR_RX_READY)) return -EAGAIN; @@ -104,13 +97,9 @@ static int bcm283x_mu_serial_getc(struct udevice *dev) static int bcm283x_mu_serial_putc(struct udevice *dev, const char data) { - struct bcm283x_mu_serial_platdata *plat = dev_get_platdata(dev); struct bcm283x_mu_priv *priv = dev_get_priv(dev); struct bcm283x_mu_regs *regs = priv->regs; - if (plat->disabled) - return 0; - /* Wait until there is space in the FIFO */ if (!(readl(®s->lsr) & BCM283X_MU_LSR_TX_EMPTY)) return -EAGAIN; @@ -123,14 +112,10 @@ static int bcm283x_mu_serial_putc(struct udevice *dev, const char data) static int bcm283x_mu_serial_pending(struct udevice *dev, bool input) { - struct bcm283x_mu_serial_platdata *plat = dev_get_platdata(dev); struct bcm283x_mu_priv *priv = dev_get_priv(dev); struct bcm283x_mu_regs *regs = priv->regs; unsigned int lsr; - if (plat->disabled) - return 0; - lsr = readl(®s->lsr); if (input) { @@ -168,7 +153,6 @@ static int bcm283x_mu_serial_ofdata_to_platdata(struct udevice *dev) 1); plat->skip_init = fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev), "skip-init"); - plat->disabled = false; return 0; } #endif diff --git a/include/dm/platform_data/serial_bcm283x_mu.h b/include/dm/platform_data/serial_bcm283x_mu.h index c47d3c0e60..57ae6adc05 100644 --- a/include/dm/platform_data/serial_bcm283x_mu.h +++ b/include/dm/platform_data/serial_bcm283x_mu.h @@ -19,7 +19,6 @@ struct bcm283x_mu_serial_platdata { unsigned long base; unsigned int clock; bool skip_init; - bool disabled; }; #endif From patchwork Wed Jan 17 08:54:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 124791 Delivered-To: patch@linaro.org Received: by 10.46.64.148 with SMTP id r20csp1309197lje; Wed, 17 Jan 2018 00:58:06 -0800 (PST) X-Google-Smtp-Source: ACJfBovDlfaJCaHvXNQQvGMADcGVFRzm9Ad3yrOI49QBL21RashaJniTDMGepqW6cGFTHQGTLAB5 X-Received: by 10.80.230.142 with SMTP id z14mr1911503edm.174.1516179486853; Wed, 17 Jan 2018 00:58:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516179486; cv=none; d=google.com; s=arc-20160816; b=Hx1ruHEFczRggOFLI3erXuZWU8BLGcN2hs7XBaQsILXQXxdtHs6vRII5mZz8d9KPBa PhHoSUjEr5MrOZ7JoaZyzztVrpVDxIplGXPESAV6tgrnXFFV5BibyTsflDYGYKttyN7Q D3n2puTN3P5QwXI9d8jtTGBgStrdWTYz+7KES7lU7nH3YSN7zM7PiHt/MtKX7l80OKSJ HbHWNQvorpN8DVBZZUme3NVl7fO0aeI0FY7KQIFbnTGQ+WSFf64SC0WJn0hd1qNTcjiA uYaB7lWFxlKEH/Ne6rTseL/5Yvjg8XbppXHTDIBWoq1TkVkQZ+K8Zuygws/xbUOYmg6l PNkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:arc-authentication-results; bh=lgTVubtFZyct4UncXXkgNczrVP2SVw6RC3sxouxiV5U=; b=Wi0+xNrUIiYX3t9Savst6gwGwEC3kBTZz9tOZdgEDdDnEXTHxCju14EXWDtTAqoRG0 Zf3XR5ln5Ers0G5JSWTYRi0g6Vp80Ve7KnTGNlwcHWgM9LK0/cSuYCp9DmY6Ji+nWfK3 MV2+9YpeqAUhrfCvZBR1rtaAXY4EYZLGRUJXsGxOJAVSXkIbgninKHqra452NRbj5S3z x9QfOfCFt2KVuGDx7VUFlyyNVpvhz64JM8xinImOkCVZNltRP/YxEoozgsS8jkRk1oD5 ecVQDHvVbRH6/eckOXBT0FkPE9cVbYexrP+/z+u9vxkWzAwN6Br9bDiLuXA58YxQE8G8 NLCg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id o26si994600edf.195.2018.01.17.00.58.06; Wed, 17 Jan 2018 00:58:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 66035C21E70; Wed, 17 Jan 2018 08:56: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_DNSWL_BLOCKED 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 01F10C21E3E; Wed, 17 Jan 2018 08:55:03 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 2E5A6C21C50; Wed, 17 Jan 2018 08:55:00 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id BD1C6C21DE8 for ; Wed, 17 Jan 2018 08:54:59 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 1950FAEEF; Wed, 17 Jan 2018 08:54:59 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Wed, 17 Jan 2018 09:54:56 +0100 Message-Id: <20180117085458.27293-6-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180117085458.27293-1-agraf@suse.de> References: <20180117085458.27293-1-agraf@suse.de> Cc: Heinrich Schuchardt Subject: [U-Boot] [PATCH v2 5/7] rpi: Properly detect which serial device is active 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" Now that we have all infrastructure in place to dynamically determine whether a serial device is actually usable (read: routed to user accessible pins), we can wire it up to the board. This patch adds support to determine whether the pl011 or mini-uart or no serial is routed to the UART RX/TX pins on the Raspberry Pi family of boards. Signed-off-by: Alexander Graf --- board/raspberrypi/rpi/rpi.c | 69 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c index a96d5d8952..b0cdad70f7 100644 --- a/board/raspberrypi/rpi/rpi.c +++ b/board/raspberrypi/rpi/rpi.c @@ -24,9 +24,16 @@ #include #endif #include +#include DECLARE_GLOBAL_DATA_PTR; +/* + * This is the GPIO pin that the user facing UART RX line is attached to. + * We use this pin to determine which serial device is available. + */ +#define BCM2835_GPIO_RX 15 + /* From lowlevel_init.S */ extern unsigned long fw_dtb_pointer; @@ -419,6 +426,68 @@ static void get_board_rev(void) printf("RPI %s (0x%x)\n", model->name, revision); } +/* + * We may get called before the device model is initialized, so we can not + * rely on the GPIO driver. + */ +int get_func_id(unsigned gpio) +{ + u32 val; + u32 node; + u32 *gpfsel; + fdt_addr_t addr; + fdt_size_t size; + + node = fdt_node_offset_by_compatible(gd->fdt_blob, -1, "brcm,bcm2835-gpio"); + if (node < 0) + return -EINVAL; + + addr = fdtdec_get_addr_size_auto_noparent(gd->fdt_blob, node, "reg", + 0, &size, true); + gpfsel = (void*)addr; + + val = readl(&gpfsel[BCM2835_GPIO_FSEL_BANK(gpio)]); + + return (val >> BCM2835_GPIO_FSEL_SHIFT(gpio) & BCM2835_GPIO_FSEL_MASK); +} + + +/* + * The RPi has 2 serial ports: A PL011 based one and the mini-uart. + * Depending on firmware configuration, either can be configured to either + * nothing, the wifi adapter or serial output. + * + * We only want to use the serial port that is user facing to not + * end up with a potentially unresponsive serial port. Due to this + * we need to check whether the serial device is actually connected + * to the UART RX/TX pins on the RPi GPIO pin bar. + * + * We only allow U-Boot to instantiate the serial driver for the serial + * device that is muxed correctly. + */ +int board_check_serial(struct udevice *dev) +{ + int func; + + printf("Checking serial %s\n", dev->name); + + if (device_is_compatible(dev, "arm,pl011")) { + func = BCM2835_GPIO_ALT0; + } else if (device_is_compatible(dev, "brcm,bcm2835-aux-uart")) { + func = BCM2835_GPIO_ALT5; + } else { + return 0; + } + + if (get_func_id(BCM2835_GPIO_RX) != func) { + printf("Disabling serial %s\n", dev->name); + return -ENODEV; + } + + printf("Enabling serial %s\n", dev->name); + return 0; +} + int board_init(void) { #ifdef CONFIG_HW_WATCHDOG From patchwork Wed Jan 17 08:54:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 124788 Delivered-To: patch@linaro.org Received: by 10.46.64.148 with SMTP id r20csp1308994lje; Wed, 17 Jan 2018 00:57:09 -0800 (PST) X-Google-Smtp-Source: ACJfBosaZZTBdeufYmMZe2tbrTYH95tXYFqqvc5F1fH4BSishfURFDtn4ZxrSGQVEP4vYSeCK28H X-Received: by 10.80.222.2 with SMTP id z2mr1894610edk.78.1516179429094; Wed, 17 Jan 2018 00:57:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516179429; cv=none; d=google.com; s=arc-20160816; b=0043o1+g4G+3Ld5W5nqRF7ipdUBvRRG5CfPQnyPmXdY+6IL7MW7v5lCmKgMyDRI4YQ E+KHfoWy6yDQ0mv0Q1xT4fF5T2QMtdQYepXPDXQ1qNNJEDzLRe8ySf6sx1xrVZl2V3WM CX2+wzgwhgVoRxPqVQmJldRtnR0ycw8uenZTxiTJvjTnfAQ5t2bI/5saq9+8kuB8SQf4 KWsfVUb8V9Rxp92UWQDglLow1px2CnPSOb0D451wo7YxA0RGE9R4ULLMsxTrpTbwjKMm EPb8POt3iXFN5zKdBlibg8zqyvKRBUQ5gIz+EjEHs7HRLrMlFhLlyM5ZeLMgVy34yOnA U+tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:arc-authentication-results; bh=vjByN3VpjONssZ//WMNF3UyzxPOSm30YZEVIUSnmtlQ=; b=07SZgxblIz2beyxNMxhBhW20W0j2QFfw8KYEJEnd/bVSDsCVicqyTD+1PeIsmMxHyX lt/lVSFtQo+uuqeP+2J9F6RQ5bs/leB5m3SqOV1rdIpY5j2OOCJ9R7u8MbPfKZJskFoo MtjAhP3/AKLeLOncRq1eCtaVF+ZFjRngmDiBMUq0OQNi4YcemWAH1CfnvCvqPfwO4MqG Bs/vqXgkS2PeJxAKaWZGNI5nFAUvOFsc6HUoc44kL6yRrfLWGWKz1FwHPdwuD45kfgkT b+DoNynjBV8O1Zp8yO7RP8LFN13ArBFOaZgiYJcH+H9e+sDpOiYiVeFRxbSMARxpuk8J l6iw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id g7si431656edj.376.2018.01.17.00.57.08; Wed, 17 Jan 2018 00:57:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 99CBAC21DE8; Wed, 17 Jan 2018 08:55:41 +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_DNSWL_BLOCKED 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 85277C21E2F; Wed, 17 Jan 2018 08:55:02 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 1BEEBC21DB5; Wed, 17 Jan 2018 08:55:00 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 837DFC21C50 for ; Wed, 17 Jan 2018 08:54:59 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 1C28DAEF6; Wed, 17 Jan 2018 08:54:59 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Wed, 17 Jan 2018 09:54:57 +0100 Message-Id: <20180117085458.27293-7-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180117085458.27293-1-agraf@suse.de> References: <20180117085458.27293-1-agraf@suse.de> Cc: Heinrich Schuchardt Subject: [U-Boot] [PATCH v2 6/7] rpi: Determine PL011/Mini-UART availability at runtime 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" Firmware on the Raspberry Pi family of devices can dynamically configure either the PL011, Mini-UART or no device at all to be routed to the user accessible UART pins. That means we need to always include both drivers, because we can never be sure which of the two serial devices firmware actually chooses to use. Signed-off-by: Alexander Graf --- include/configs/rpi.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/include/configs/rpi.h b/include/configs/rpi.h index cab8661779..2c84cf9a49 100644 --- a/include/configs/rpi.h +++ b/include/configs/rpi.h @@ -75,12 +75,9 @@ #define CONFIG_MISC_INIT_R #endif -/* Console UART */ -#if defined (CONFIG_BCM2837) || defined(CONFIG_TARGET_RPI_0_W) +/* Console UART, can be configured dynamically in config.txt */ #define CONFIG_BCM283X_MU_SERIAL -#else #define CONFIG_PL01X_SERIAL -#endif /* Console configuration */ #define CONFIG_SYS_CBSIZE 1024 From patchwork Wed Jan 17 08:54:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 124793 Delivered-To: patch@linaro.org Received: by 10.46.64.148 with SMTP id r20csp1309313lje; Wed, 17 Jan 2018 00:58:49 -0800 (PST) X-Google-Smtp-Source: ACJfBovIFq5ijpA+HYOBu50RB693ZDKDEu14K/T8QtMULtgUudhx9kbJ5cuuZ4bCdqUQ+fkmXeWr X-Received: by 10.80.169.48 with SMTP id l45mr1939540edc.128.1516179529888; Wed, 17 Jan 2018 00:58:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516179529; cv=none; d=google.com; s=arc-20160816; b=Wq9KCmXrC47pPMw/v23ta3JzwM0aqIismKnkDKEBufNGROjp5Srs7DYJI2x1Wgl8es nhLNDW2KTN6sJyWpTpPdgwquXVjxRYTTQCPlbqEKggRcuvia/eSxG6+iek395Ww1jlR7 f3GTNhu+wV5uzjH7z9gJTRLNOgZMT7tvnxuRULqAjT1joM1+OIBtmi9gJKofCWMgQTXz CDk+wz28Z8kVQM5QSjyNDkDcx1o5NWptUHfUaxG+O0XVhPPUuQx/D+wPYrUJEOqYvbCF l1q1GeCTrUi6WkbspZtWLW4saGPZO7QWv5l78Wier4OeWun4N4G+ognEwNltbmFBMezA q+zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:arc-authentication-results; bh=oOWTcYk0cwWPhl9lfuY/O6r+BPgjR83Y9L9Ah+zqJyM=; b=BWH1DC16ClZAQjBjhrdoCDdVFcq+iw0El16FBMehEjh7rcWdVIdpHut5ZFOSSBQg4a X/NJc4A6RIH3E64IkEzKsQMGJgbh28OzALDvCj6Bb6qT9oVQ/XnaPThumrEh7pvz5Jao bXGkpK8G4+xDcIdWTWAOIkazFcvr+BL5DNm2HbgqVDeki7J0cdFjPdjtElSGkTZsDK+M zPgRNEUiKbDsRIJo1u+49ZfII1gAILs7CJeY3oYhTTmmSMioqdjLF40Qfw3B7sxSfPtr a4yrv8atAYsn68L7eFbzvlyikRdxxnfbk2xM63KnG4r1e4Vzv3up7a7gOVtGeUrhLt0+ eK1A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id f6si2464199eda.157.2018.01.17.00.58.49; Wed, 17 Jan 2018 00:58:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 6AC1AC21E67; Wed, 17 Jan 2018 08:57:08 +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_DNSWL_BLOCKED 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 D0764C21E79; Wed, 17 Jan 2018 08:55:06 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 8069DC21CA6; Wed, 17 Jan 2018 08:55:00 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id BD25FC21DFA for ; Wed, 17 Jan 2018 08:54:59 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 2B233AEF9; Wed, 17 Jan 2018 08:54:59 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Wed, 17 Jan 2018 09:54:58 +0100 Message-Id: <20180117085458.27293-8-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180117085458.27293-1-agraf@suse.de> References: <20180117085458.27293-1-agraf@suse.de> Cc: Heinrich Schuchardt Subject: [U-Boot] [PATCH v2 7/7] rpi: Force skip_init on serial devices 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" The serial devices on the raspberry pi are based on clocks we can't easily read and influence in U-Boot. However, the serial devices are always already properly set up when coming up, so all we need to do is leave them alone. The way to do that is to specify "skip-init" in device tree usually, but if we set CONFIG_OF_BOARD to get the device tree from the RPi firmware, that does not have skip-init properly set. So instead we just force it in board specific code. That way serial devices also work fine when skip-init is not passed explicitly in DT. Signed-off-by: Alexander Graf --- board/raspberrypi/rpi/rpi.c | 7 +++++++ drivers/serial/serial_bcm283x_mu.c | 2 +- drivers/serial/serial_pl01x.c | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c index b0cdad70f7..ce1286a53a 100644 --- a/board/raspberrypi/rpi/rpi.c +++ b/board/raspberrypi/rpi/rpi.c @@ -20,6 +20,7 @@ #include #include #include +#include #ifdef CONFIG_ARM64 #include #endif @@ -472,9 +473,15 @@ int board_check_serial(struct udevice *dev) printf("Checking serial %s\n", dev->name); if (device_is_compatible(dev, "arm,pl011")) { + struct pl01x_serial_platdata *plat = dev_get_platdata(dev); + func = BCM2835_GPIO_ALT0; + plat->skip_init = true; } else if (device_is_compatible(dev, "brcm,bcm2835-aux-uart")) { + struct bcm283x_mu_serial_platdata *plat = dev_get_platdata(dev); + func = BCM2835_GPIO_ALT5; + plat->skip_init = true; } else { return 0; } diff --git a/drivers/serial/serial_bcm283x_mu.c b/drivers/serial/serial_bcm283x_mu.c index 7ce990b9b8..8a7ca75d4a 100644 --- a/drivers/serial/serial_bcm283x_mu.c +++ b/drivers/serial/serial_bcm283x_mu.c @@ -151,7 +151,7 @@ static int bcm283x_mu_serial_ofdata_to_platdata(struct udevice *dev) plat->base = addr; plat->clock = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "clock", 1); - plat->skip_init = fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev), + plat->skip_init |= fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev), "skip-init"); return 0; } diff --git a/drivers/serial/serial_pl01x.c b/drivers/serial/serial_pl01x.c index 4ec0f29c42..f957eddc07 100644 --- a/drivers/serial/serial_pl01x.c +++ b/drivers/serial/serial_pl01x.c @@ -357,7 +357,7 @@ static int pl01x_serial_ofdata_to_platdata(struct udevice *dev) plat->clock = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "clock", 1); plat->type = dev_get_driver_data(dev); - plat->skip_init = fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev), + plat->skip_init |= fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev), "skip-init"); return 0; }