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