From patchwork Wed Aug 1 15:58:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrice CHOTARD X-Patchwork-Id: 952244 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=st.com Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41gdLk4znfz9s3Z for ; Thu, 2 Aug 2018 02:00:30 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 45140C21DD3; Wed, 1 Aug 2018 15:59:32 +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 1FE3AC21EE3; Wed, 1 Aug 2018 15:59:12 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 82B9DC21DD3; Wed, 1 Aug 2018 15:59:10 +0000 (UTC) Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) by lists.denx.de (Postfix) with ESMTPS id 34A6EC21C2C for ; Wed, 1 Aug 2018 15:59:10 +0000 (UTC) Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w71Fx8D7017923; Wed, 1 Aug 2018 17:59:09 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2kjehvgtmv-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 01 Aug 2018 17:59:09 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 1654643; Wed, 1 Aug 2018 15:59:08 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag6node3.st.com [10.75.127.18]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id F30A85659; Wed, 1 Aug 2018 15:59:07 +0000 (GMT) Received: from localhost (10.75.127.47) by SFHDAG6NODE3.st.com (10.75.127.18) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Wed, 1 Aug 2018 17:59:07 +0200 From: Patrice Chotard To: Simon Glass Date: Wed, 1 Aug 2018 17:58:53 +0200 Message-ID: <1533139133-27800-4-git-send-email-patrice.chotard@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1533139133-27800-1-git-send-email-patrice.chotard@st.com> References: <1533139133-27800-1-git-send-email-patrice.chotard@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.47] X-ClientProxiedBy: SFHDAG1NODE1.st.com (10.75.127.1) To SFHDAG6NODE3.st.com (10.75.127.18) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-08-01_06:, , signatures=0 Cc: Joe Hershberger , Michal Simek , u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 3/3] sandbox: Add serial test 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Signed-off-by: Patrice Chotard Reviewed-by: Simon Glass --- Changes in v2: - Add sandbox serial test drivers/serial/sandbox.c | 14 ++++++++++++++ include/common.h | 1 + test/dm/Makefile | 1 + test/dm/serial.c | 26 ++++++++++++++++++++++++++ 4 files changed, 42 insertions(+) create mode 100644 test/dm/serial.c diff --git a/drivers/serial/sandbox.c b/drivers/serial/sandbox.c index a60dabe58835..94b4fdfb1714 100644 --- a/drivers/serial/sandbox.c +++ b/drivers/serial/sandbox.c @@ -143,6 +143,19 @@ static int sandbox_serial_getc(struct udevice *dev) return result; } +static int sandbox_serial_setconfig(struct udevice *dev, uint serial_config) +{ + u8 parity = SERIAL_GET_PARITY(serial_config); + u8 bits = SERIAL_GET_BITS(serial_config); + u8 stop = SERIAL_GET_STOP(serial_config); + + if (bits != SERIAL_8_BITS || stop != SERIAL_ONE_STOP || + parity != SERIAL_PAR_NONE) + return -ENOTSUPP; /* not supported in driver*/ + + return 0; +} + static const char * const ansi_colour[] = { "black", "red", "green", "yellow", "blue", "megenta", "cyan", "white", @@ -173,6 +186,7 @@ static const struct dm_serial_ops sandbox_serial_ops = { .putc = sandbox_serial_putc, .pending = sandbox_serial_pending, .getc = sandbox_serial_getc, + .setconfig = sandbox_serial_setconfig, }; static const struct udevice_id sandbox_serial_ids[] = { diff --git a/include/common.h b/include/common.h index 940161f1758b..5c952af5e319 100644 --- a/include/common.h +++ b/include/common.h @@ -359,6 +359,7 @@ void serial_putc_raw(const char); void serial_puts (const char *); int serial_getc (void); int serial_tstc (void); +int serial_setconfig(uint config); /* $(CPU)/speed.c */ int get_clocks (void); diff --git a/test/dm/Makefile b/test/dm/Makefile index d2ed96c61533..97517c7f825e 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -44,4 +44,5 @@ obj-$(CONFIG_DM_VIDEO) += video.o obj-$(CONFIG_ADC) += adc.o obj-$(CONFIG_SPMI) += spmi.o obj-$(CONFIG_WDT) += wdt.o +obj-$(CONFIG_DM_SERIAL) += serial.o endif diff --git a/test/dm/serial.c b/test/dm/serial.c new file mode 100644 index 000000000000..4d8422eebd34 --- /dev/null +++ b/test/dm/serial.c @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2018, STMicroelectronics + */ + +#include +#include +#include +#include +#include + +static int dm_test_serial(struct unit_test_state *uts) +{ + struct udevice *dev_serial; + + ut_assertok(uclass_get_device_by_name(UCLASS_SERIAL, "serial", + &dev_serial)); + + ut_assertok(serial_tstc()); + + ut_assertok(serial_setconfig(SERIAL_DEFAULT_CONFIG)); + + return 0; +} + +DM_TEST(dm_test_serial, DM_TESTF_SCAN_FDT);