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