From patchwork Tue Jan 16 13:47:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 124693 Delivered-To: patch@linaro.org Received: by 10.46.64.148 with SMTP id r20csp1019987lje; Tue, 16 Jan 2018 05:49:47 -0800 (PST) X-Google-Smtp-Source: ACJfBou2Ixz66XDC2HenLl1u0OeqVKsCSY2WpkHffLHbMlQVZ1tvvRe2Y4IKIzWftYf4sExtSnaV X-Received: by 10.80.167.101 with SMTP id h92mr52911992edc.202.1516110587245; Tue, 16 Jan 2018 05:49:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516110587; cv=none; d=google.com; s=arc-20160816; b=GbYyMsBykRv7QLEZZRpuoTF5vnnpq0n3+CO0djTLfySSe9UCAAgW9BgcA7gTQDapQO k3e9tnuzO7sU5D+Xd4JTMUZA8C6r6Wm7/FgFZMSV+hPiYyC0Wr6RQ+QS5w4Zu+br1kxl RbfOP1n2JAcmE9Vj8soH+UfNJn/kJpMuHu+BDmjvH6+vgG6xJncZl5R37DZ+5EPP/Etu phbpev2G0mMfoHhSFu1AE3fNwwUNcLL+3j/k5GeQ7aUlKbG4Bogt06qhRlfsz2i+ly0i W9PaMfw6iBR8I/JkhweaqiAiWuXHENPD1dlKmmbjkXKjyXzz/X7JOzhDSChM7x0ExHQF j4+Q== 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:references:in-reply-to:message-id:date :to:from:arc-authentication-results; bh=ufvIM3QBRA05ppCL0whjQfYHHlVYBz8TyGlWDIcClLw=; b=JeHv6kF822sEW5jR/ytrepkxgo06AS/aGxZhkYdr0FhDRV4TQ6j7xA0edHAG8ouuQx iqxxqLEMzQT1IBVQWeepWOoR7zXW0tdVvxYghJLmmSTqma+pqFuB0MP3jh8+m3P38gIF MAUBBiYXtxLZU1iMzNC8sL6lwGisJ4su7GFyeBFtNJHYrOt10eErWJGh2kmTPuLpfnzE QKB+2FZ7W1J/p2e2vTjlOBdDeklR3auOyZ+3yBXYAW1Oo7t0kHjg7Ux3dCbuvsbgIPf3 7xZcAUR4LDS/6dzvKsfkob8IHWlEVzazuE/1mw3RU0Urw2EhnKMoNjO+h3tWz4F2+7eH zsOQ== 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 w50si2229958eda.81.2018.01.16.05.49.46; Tue, 16 Jan 2018 05:49:47 -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 C1CF4C21E0E; Tue, 16 Jan 2018 13:49:16 +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=none 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 A5E7EC21DF3; Tue, 16 Jan 2018 13:48:41 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 89639C21E0A; Tue, 16 Jan 2018 13:47:56 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 743BFC21E48 for ; Tue, 16 Jan 2018 13:47:42 +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 3E33FAD02; Tue, 16 Jan 2018 13:47:42 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Tue, 16 Jan 2018 14:47:35 +0100 Message-Id: <20180116134741.4103-2-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180116134741.4103-1-agraf@suse.de> References: <20180116134741.4103-1-agraf@suse.de> Subject: [U-Boot] [PATCH 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 --- drivers/serial/serial-uclass.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c index 2e5116f7ce..637544d1a7 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,8 +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)) { + !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 */ + continue; + } + gd->cur_serial_dev = dev; return; } From patchwork Tue Jan 16 13:47:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 124708 Delivered-To: patch@linaro.org Received: by 10.46.64.148 with SMTP id r20csp1021135lje; Tue, 16 Jan 2018 05:54:16 -0800 (PST) X-Google-Smtp-Source: ACJfBotQCBofCbrseB6gKcolU3BKCa9RcIC0zVqeL9+SST52eUdnjM+ILqYYiZQG4/BQO5o/Ln2h X-Received: by 10.80.170.18 with SMTP id o18mr54690299edc.34.1516110856367; Tue, 16 Jan 2018 05:54:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516110856; cv=none; d=google.com; s=arc-20160816; b=zC0kPADhvQ0ZZXHwBVlU5iPZO4ggy+i9Fw9uvvhFzJEiRlHEmngMkjStusy1QZ6laD Q0eK03gLKThbBnjsz+2M/11M8ymu3mwTkf3dYRYfnVqbxiBwYOJveNbZmos+qncGcj3u pdPkkWsy4pId+0djWrkwrrqykEweWq1CVmZYyKV/OAjqSZA2kzVa3bs2YVD1Ivhj+j7M nOsKpiXf3uFz/kk+WAonittQpG/jXyknVQ0tU1/VaJ8Db1159mGIf91Zib7iL0AxAR7I QqjjzZPZXQbNmP2B+XIgAAlvbPDGfUUeK76ARc/7CdDjQrGWuLg8p+kDiIQ//bl5+GHM abow== 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:references:in-reply-to:message-id:date :to:from:arc-authentication-results; bh=ZN4dc0eC5amotXZ08WKyDSfzWJII1RsjIIx+54tlVI4=; b=jE1xirzEwM6ZNXnIOKg3J0RXzIIJ/i/5Vcz1I35uoOdTDj4I8Wba+5SXebuFz+qGJp 6Q/eKtfp3YVw1iAfntDeTE6IkHc4IaiIU14oYXQTureXQ5RfLD9fvSRGHeYA+rKow0Bq 06/Jqp7X58WhNFp3EL2UQwD191MHWL4896uHBEEmk9Jnu7vM//RqujYVvgxjqcdbD7ia FifWphGdF4RdXYyNk6nkAfG4hlM8XZ5kdvEohA//Hw0VABAa4neBrrybUYxn0ItedpX1 u4I0ndzvJsEgVAjFqxLhYuBKQPNaPLv+IwDxPOZpJq62RPSW3gI9iB2cDFBE/SKyfK62 mWGg== 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 g3si296463eda.26.2018.01.16.05.54.15; Tue, 16 Jan 2018 05:54:16 -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 BCDE3C21DE5; Tue, 16 Jan 2018 13:51:01 +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=none 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 4D9AFC21DEF; Tue, 16 Jan 2018 13:49:23 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 99955C21DA5; Tue, 16 Jan 2018 13:48:11 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id CA427C21DB0 for ; Tue, 16 Jan 2018 13:47:42 +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 7521EAD1C; Tue, 16 Jan 2018 13:47:42 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Tue, 16 Jan 2018 14:47:36 +0100 Message-Id: <20180116134741.4103-3-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180116134741.4103-1-agraf@suse.de> References: <20180116134741.4103-1-agraf@suse.de> Subject: [U-Boot] [PATCH 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 637544d1a7..72d7835285 100644 --- a/drivers/serial/serial-uclass.c +++ b/drivers/serial/serial-uclass.c @@ -368,6 +368,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); @@ -440,6 +450,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 Tue Jan 16 13:47:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 124703 Delivered-To: patch@linaro.org Received: by 10.46.64.148 with SMTP id r20csp1020622lje; Tue, 16 Jan 2018 05:52:06 -0800 (PST) X-Google-Smtp-Source: ACJfBouTNNLaUj6klO+9d+JlzTvitIQJz+rvINmFW3aBI9JPDapbjnBxp083Qq3hGcABdbBS452O X-Received: by 10.80.158.79 with SMTP id z73mr52690141ede.134.1516110726759; Tue, 16 Jan 2018 05:52:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516110726; cv=none; d=google.com; s=arc-20160816; b=YXbihpnc4IIg8ZtrULO2PXQH79m7JAjmly3nsLmxQWQ8grNolsIQ0eCOYUhCisWEkF bMpqTVaE8zFRVl7Q3M4d4NEbhDl0ZQ3+xxIQGj9ZDcp8p5nV1ZEri6TsmIGeoj0038f4 EvaKCs5EvkMpUfREsDrRmFP2DDO/Gy7BlJQNHzdLsJpOyqPcoEIXxeUDulGbnla3rag0 PjNmrSv+oIc6/Nx19xUk1euK0jRC39MHINtDWJlDCoupCUJzrIMSO2rwQXhxnLq6/FH8 0u8UDFRZ0JbPv7ogGFxHdEj1/bV+aVJID0SOWk2hoBGyYlrQRNMT8G0XmYBDQCWDCd7O vVGQ== 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:references:in-reply-to:message-id:date :to:from:arc-authentication-results; bh=tfKFDOghbvJjez3iHmklb1qL5YdjG9EK15whrQBaeQQ=; b=EjTFZtZg9hhwZVfNQV6A/3sHgDypaypuOJ3B25+LjlvBXg3LlVA0cUNbQGBEyNAkED LcR6YKxII0GNVJRzJZN0N1Q3qpantyG4HdWWeq/zx154pqT5fOqbYrotBjvoFgThAwL4 Hk1RVL9QFI6jR//o0KNISXRTsZBPCkhk4zrgF+o2zlWR/qLNNd1G1poMy9LEjH9etd+Z 6Mxj7MYSTWSv+mvUtwwqjzwaLdHaGREN+o9M7KSQafJNHMwTddExJkpeNYaS+CmpHhH9 GvfY/FXTWIZhSBKcEuao1sNTwSGzTNyf2PfIRdaEmRTXo1+vl+lIvUMGRjq+k3Wz70uP +mgA== 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 o26si725293edf.195.2018.01.16.05.52.06; Tue, 16 Jan 2018 05:52: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 62036C21DE5; Tue, 16 Jan 2018 13:49:35 +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=none 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 B22AAC21E40; Tue, 16 Jan 2018 13:48:44 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 94E7FC21DB0; Tue, 16 Jan 2018 13:47:56 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 8BE1AC21E4C for ; Tue, 16 Jan 2018 13:47:42 +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 48491AD05; Tue, 16 Jan 2018 13:47:42 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Tue, 16 Jan 2018 14:47:37 +0100 Message-Id: <20180116134741.4103-4-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180116134741.4103-1-agraf@suse.de> References: <20180116134741.4103-1-agraf@suse.de> Subject: [U-Boot] [PATCH 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 Tue Jan 16 13:47:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 124707 Delivered-To: patch@linaro.org Received: by 10.46.64.148 with SMTP id r20csp1021077lje; Tue, 16 Jan 2018 05:54:04 -0800 (PST) X-Google-Smtp-Source: ACJfBouVjHW90ho+JWN1T/HcSCtOeKLBt5jMQVD/CugJaSFWTOykHSS6MWD0dVS+xfWuigAjdclb X-Received: by 10.80.186.161 with SMTP id x30mr53974737ede.138.1516110844548; Tue, 16 Jan 2018 05:54:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516110844; cv=none; d=google.com; s=arc-20160816; b=n8/mAMrorxAQcq7NbSgGBhOUU88ynM0vEbbbtYyiXb0e3NM+lo5C05kpO/KGjE98J0 iFdsx6ZNtAPagdzV7L5EVGDM5cZ6QVjOZN0eYJMZ46gi9FyhFoO+FL7ASHso/317LBwK Y1HAdC0p1Bco5bsQlXN1IbgaHPAyASowFVdrVKcHHt/yTL+kbaUc4iTQXsvLznY4vRYm I+gIUk08/JhIpcAY/vlLAvPRaSFI73bdogN+c5bgI2VDk+Rt2sCAJB3nfeL/u3RcRVrm qseUC0NPstercNrv2fO1UnuogSau3iz2py4PcTP7x9CKZiLdeMZ+lJCSI9pKB5u/b/C0 mZ1w== 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:references:in-reply-to:message-id:date :to:from:arc-authentication-results; bh=HJqILOaDFKg7ohORG24VvFdjWHLuwXj53eUdG+GG74I=; b=MK3oVQvXmffwhN0im9fWcZDilXApR+bBOYuMv3DcS3UusSOa5pssH46ikB6IRxBUuC Etjq4ICaiFDEEzoIgTFPpgf1Sb+33qTbFv4QH8dVJJI1BPkeaUZHuNewYTaizL4xG9C7 8sUO3LCsFqtiTMYkPR6hvPLFCDJag+LXmPbMbxCLpVXPUQmPCHlhNWUprvWrTgkiHrU3 T+qeRlmGAFfQ6584p2HxQnYV+S3Y+23//Piy4Vv27zHKy1m+9nLRp2/mXvGdVzU2Se9m 4hxOfj7fE08IaPAjG37xLkn+1OnrsdTZSthm6RZkXP4f2pf6ahEjYhCKDmU/4UGaa3Nq MPzg== 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 n44si3123487edn.262.2018.01.16.05.54.04; Tue, 16 Jan 2018 05:54:04 -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 1E234C21E41; Tue, 16 Jan 2018 13:50:27 +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=none 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 3C26CC21E3B; Tue, 16 Jan 2018 13:48:59 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 3E2F8C21DB0; Tue, 16 Jan 2018 13:47:56 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 8BE28C21E50 for ; Tue, 16 Jan 2018 13:47:42 +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 506D7AD0C; Tue, 16 Jan 2018 13:47:42 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Tue, 16 Jan 2018 14:47:38 +0100 Message-Id: <20180116134741.4103-5-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180116134741.4103-1-agraf@suse.de> References: <20180116134741.4103-1-agraf@suse.de> Subject: [U-Boot] [PATCH 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 Tue Jan 16 13:47:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 124702 Delivered-To: patch@linaro.org Received: by 10.46.64.148 with SMTP id r20csp1020606lje; Tue, 16 Jan 2018 05:52:02 -0800 (PST) X-Google-Smtp-Source: ACJfBotGT/F0bEMG5ZZhHmuAR5kz307XgUb6fsTTvf0QvggB343hPVyRZRfMFcUIXy8Rkcu1D2Zu X-Received: by 10.80.165.180 with SMTP id a49mr30435383edc.79.1516110722169; Tue, 16 Jan 2018 05:52:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516110722; cv=none; d=google.com; s=arc-20160816; b=XB+9oMwIjmmpTTIAbCflH45HzDRywXlhSc/CUDgQ8WYvsAEWYOL3jtVhgtHiXMWAgU oMxH8Sq+w+h1ruTApXL3Jcr7v+B85WMBDPpKBho6V9i14RokBE7yKmW6d6yNDEQ1L9wS 1MZl8xlxVEqjP9sgV3JfuKOk/npIuKdGdKdZTmos95mjgbVczzPyNkRmv48XCGNTZyCy wlTr/huqqY8mq47OmoQaWrMkAUBsPb5OtATrkyrGVHxYlS2YspFJAzFbpqId3o9++ydb 7q7lz325pLIQHP7qtrmk2ZkIObpt3Nl7GdsIKyPpa/Ra9iey708uVpvbeDHp6f66wyzS Rtqw== 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:references:in-reply-to:message-id:date :to:from:arc-authentication-results; bh=lgTVubtFZyct4UncXXkgNczrVP2SVw6RC3sxouxiV5U=; b=paMiY96VoPrb21EXdnyc7dIGK6bDc89p4QbbIwTfl4j3it1DsNxpNXWd3R7lqqdXUz rBQ9rG76nklXTzF8JjqxKqJ1kvo+WqU24TXiHmu1OjqWk3VRIqi0k10RN+C7WvEww39J ykW4bGEwXiALHllvv+oKTnCU+ukDIUR2EhxAqa7LhIB8n9+xO6mgokG8Fa3UYaqT/9Gg ZX5sMiMbMxWFuX/ypwA46cSjtteftiRNSKYJ8LI7gHb6Lzf2fjqBZd4Qz+d3IXpij3i4 T6p85mkr6OLPHhoj2gmAt5YrCZLXsZ1kXzyqXXh6jvStH9Gxry/X8q3S4iiRBc9UMtus PoKA== 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 w51si2316235edb.141.2018.01.16.05.52.01; Tue, 16 Jan 2018 05:52:02 -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 BD9AFC21DA6; Tue, 16 Jan 2018 13:50:10 +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=none 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 F20D6C21DFA; Tue, 16 Jan 2018 13:48:55 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D967EC21E1E; Tue, 16 Jan 2018 13:47:56 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 95438C21E16 for ; Tue, 16 Jan 2018 13:47:42 +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 5E6F4AD0F; Tue, 16 Jan 2018 13:47:42 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Tue, 16 Jan 2018 14:47:39 +0100 Message-Id: <20180116134741.4103-6-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180116134741.4103-1-agraf@suse.de> References: <20180116134741.4103-1-agraf@suse.de> Subject: [U-Boot] [PATCH 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 Tue Jan 16 13:47:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 124701 Delivered-To: patch@linaro.org Received: by 10.46.64.148 with SMTP id r20csp1020559lje; Tue, 16 Jan 2018 05:51:50 -0800 (PST) X-Google-Smtp-Source: ACJfBouVcwsgUtpshcKrn+6aQR2AXJro3PYdcKIOIQrSodaqOowKMDGaYfudJXSqfP4sbp+4N/xu X-Received: by 10.80.226.203 with SMTP id q11mr11645758edl.248.1516110710338; Tue, 16 Jan 2018 05:51:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516110710; cv=none; d=google.com; s=arc-20160816; b=B/W+3ZsAgWXnf7R7YAZ5NEnygYiVfZZEU+NjVEuqnTH48zU7Xny2NuZRQr5n89mreI asZLWnL+yjb1OhQe2rfygYGzJ4pMjVQsXYJWeea787OnTNR7yIfnzay4tBHT/CdhHY8k mSRK4mNR024/uMLOAxOzq6CuXxQKyefqJzZHR+GVa16EaoJNMFYeLUoS4iRggoUQRi2s sJQr0p9L6wWba+oPEXJeikExfa693a4FitBzZ4uoayma+qrRFchCB9cAQTyFuzDuRtTU 5CyauwOlrvkScTHNWqmcOGLpyfh5m2xEb27MNSCYVzVV6NT+yhRca36IoPBR12MyUBZf QPAg== 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:references:in-reply-to:message-id:date :to:from:arc-authentication-results; bh=vjByN3VpjONssZ//WMNF3UyzxPOSm30YZEVIUSnmtlQ=; b=GfNkSnvOKlQ495NVAfPJU6QzETlrHl1+4KgN/Yh59A26myEH0MrL+Mq1aB2pbYlTD/ pXDYMBR2M2+thAiqXPAVMUWkxG4q3i/7ND5v6YoKWmDbY9riKors3nN2k1tU7vTAUph9 aR0dMpay22l0JQPqG6WB04YCie3VuNf9SMDVrKjgaW6GTNgUmKnpp/t+rWOPPqTGaMH8 yqbFuF9QozI+ELphYdHjcGIghId+13S4vxzfWb+Iz2WYGzJE8YA+LL5Jt1sR6tCJMq03 tKVh0aL9i/H3NAcy6MPRTCrxMlCcSE+lwNctOWMOc1f2JnUREsxj+HlixUXa0+uKYgHN EP9A== 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 f12si2278708ede.477.2018.01.16.05.51.50; Tue, 16 Jan 2018 05:51:50 -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 D3B71C21E31; Tue, 16 Jan 2018 13:50:44 +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=none 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 65087C21E48; Tue, 16 Jan 2018 13:49:00 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id A7BCAC21E18; Tue, 16 Jan 2018 13:48:11 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id CDA93C21E18 for ; Tue, 16 Jan 2018 13:47:42 +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 6AB93AD11; Tue, 16 Jan 2018 13:47:42 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Tue, 16 Jan 2018 14:47:40 +0100 Message-Id: <20180116134741.4103-7-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180116134741.4103-1-agraf@suse.de> References: <20180116134741.4103-1-agraf@suse.de> Subject: [U-Boot] [PATCH 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 Tue Jan 16 13:47:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 124706 Delivered-To: patch@linaro.org Received: by 10.46.64.148 with SMTP id r20csp1020950lje; Tue, 16 Jan 2018 05:53:33 -0800 (PST) X-Google-Smtp-Source: ACJfBosL/hcSUcxzIOydh27TZZi70k4aBfW4uUDprbTf/ww7nxuB+yjFPMkH/AXPD6B504ewr26i X-Received: by 10.80.174.174 with SMTP id e43mr16668880edd.9.1516110813693; Tue, 16 Jan 2018 05:53:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516110813; cv=none; d=google.com; s=arc-20160816; b=SwDX9qob/1hANn7GqbTWEfPGq6v79QRjrsZwYCQlMQEyV0WQFfDVVkTXfKNwAVI3vX b2/p2+PZ4nP0eCdZ/e+eW1jkjiqmdIsnBPu5OV2IXjJn5Fg88MjvTLAmJhs1mdyWcd3o I3YRMTvUiKGbtg4yjsW3bQnXFSNcv5mtNM0CjZfV2CS4m7LV/d/3AIOc6UChnvLyi5qk 9CZwM7XRrEj7OC73qJpSJ1i9WrPIFTc8Ao5gERMg89HU9RINNTl1Ta8OzqKKaioj7WAT TGhO8/PM3Lt7IVxwDNPdLn4rvK5iPq+tkKrrVoaGDWrEVrFxHrpO6+Sb4ceMp9EY2ywj uc9g== 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:references:in-reply-to:message-id:date :to:from:arc-authentication-results; bh=oOWTcYk0cwWPhl9lfuY/O6r+BPgjR83Y9L9Ah+zqJyM=; b=oOwe4ZexmxH3XXy7wHoVYQ95NZZ0bOSGPQ3eBDqDnDD2vBo0bmaKisOP1Z416EglAK Fa0WstQsETNK/c/7djyUgXLnJylYfYLO1QJz8adpl+rGREs6H0Cz/j47TvmiifsFsXX9 yX8hwJ+l02FHnfQnzCrMeu2HOO9+p9BNSScpK1LnjiCQL+coq+VKVuJvO/pwKPVNVd6d jxv29CxZ9tp+TC3xVSL+jp/2JReihjZjULHjbe3Mcb+mWs2nddnZGY3sMR7IvUisYRhg AmGYxrDLVOGx48D3Qekz1JofLWtQ6BPrTuiTsmxE9ScQ3ZOKeuJIIhEizgEOs62PbL8V 6NeQ== 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 g7si2381999edj.376.2018.01.16.05.53.33; Tue, 16 Jan 2018 05:53:33 -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 41DEBC21E24; Tue, 16 Jan 2018 13:49:54 +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=none 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 C5CA6C21E3C; Tue, 16 Jan 2018 13:48:50 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 76033C21E1E; Tue, 16 Jan 2018 13:48:11 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id D0C3CC21E30 for ; Tue, 16 Jan 2018 13:47:42 +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 77A43AD26; Tue, 16 Jan 2018 13:47:42 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Tue, 16 Jan 2018 14:47:41 +0100 Message-Id: <20180116134741.4103-8-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180116134741.4103-1-agraf@suse.de> References: <20180116134741.4103-1-agraf@suse.de> Subject: [U-Boot] [PATCH 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; }