From patchwork Wed Jul 17 04:41:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Park, Aiden" X-Patchwork-Id: 1133100 X-Patchwork-Delegate: bmeng.cn@gmail.com 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=fail (p=none dis=none) header.from=intel.com Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45pPmb16Jjz9s3l for ; Wed, 17 Jul 2019 14:43:59 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id C3972C21E56; Wed, 17 Jul 2019 04:42: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=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 AF507C21DF3; Wed, 17 Jul 2019 04:41:49 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 74F2CC21EA8; Wed, 17 Jul 2019 04:41:37 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lists.denx.de (Postfix) with ESMTPS id AF76EC21D4A for ; Wed, 17 Jul 2019 04:41:33 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jul 2019 21:41:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,272,1559545200"; d="scan'208";a="161639090" Received: from orsmsx108.amr.corp.intel.com ([10.22.240.6]) by orsmga008.jf.intel.com with ESMTP; 16 Jul 2019 21:41:31 -0700 Received: from orsmsx121.amr.corp.intel.com (10.22.225.226) by ORSMSX108.amr.corp.intel.com (10.22.240.6) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 16 Jul 2019 21:41:30 -0700 Received: from orsmsx116.amr.corp.intel.com ([169.254.7.102]) by ORSMSX121.amr.corp.intel.com ([169.254.10.173]) with mapi id 14.03.0439.000; Tue, 16 Jul 2019 21:41:30 -0700 From: "Park, Aiden" To: U-Boot Mailing List , Simon Glass , Bin Meng , Andy Shevchenko Thread-Topic: [PATCH v5 4/8] x86: slimbootloader: Add serial driver Thread-Index: AdU8WHQ6yR9VqqJ0QKaviR7ai8L1ng== Date: Wed, 17 Jul 2019 04:41:29 +0000 Message-ID: Accept-Language: ko-KR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiY2VlNjEzYTEtOTlmNi00MThmLWI2ZjgtOTY1MWU0NGQyZjljIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiYlFpZ202YTZzNHRcL2cyUnFcL2dqWk81ZzNGV2xlbW44YjJmME55T25QZE1FbG1JYmZcL0RVeXkycno0VHNNVVBSRiJ9 x-ctpclassification: CTP_NT x-originating-ip: [10.22.254.139] MIME-Version: 1.0 Subject: [U-Boot] [PATCH v5 4/8] x86: slimbootloader: Add serial driver 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" Slim Bootloader provides serial port info thru its HOB list pointer. All these HOBs are eligible for Slim Bootloader based board only. - Get serial port information from the serial port info hob - Leverage ns16550 driver with slimbootloader specific platform data Signed-off-by: Aiden Park Reviewed-by: Bin Meng --- Changes in v4: * Add static keyword in static function Changes in v3: * Use HOB function from the common HOB library arch/x86/cpu/slimbootloader/Makefile | 2 +- arch/x86/cpu/slimbootloader/serial.c | 69 +++++++++++++++++++ .../asm/arch-slimbootloader/slimbootloader.h | 36 ++++++++++ 3 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 arch/x86/cpu/slimbootloader/serial.c -- 2.20.1 diff --git a/arch/x86/cpu/slimbootloader/Makefile b/arch/x86/cpu/slimbootloader/Makefile index 05d0ca4a19..68c4a91955 100644 --- a/arch/x86/cpu/slimbootloader/Makefile +++ b/arch/x86/cpu/slimbootloader/Makefile @@ -2,4 +2,4 @@ # # Copyright (C) 2019 Intel Corporation -obj-y += car.o slimbootloader.o dram.o +obj-y += car.o slimbootloader.o dram.o serial.o diff --git a/arch/x86/cpu/slimbootloader/serial.c b/arch/x86/cpu/slimbootloader/serial.c new file mode 100644 index 0000000000..5a8591889f --- /dev/null +++ b/arch/x86/cpu/slimbootloader/serial.c @@ -0,0 +1,69 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2019 Intel Corporation + */ + +#include +#include +#include +#include +#include + +/** + * The serial port info hob is generated by Slim Bootloader, so eligible for + * Slim Bootloader based boards only. + */ +static int slimbootloader_serial_ofdata_to_platdata(struct udevice *dev) +{ + const struct efi_guid guid = LOADER_SERIAL_PORT_INFO_GUID; + struct serial_port_info *serial_info = NULL; + struct ns16550_platdata *plat = dev->platdata; + + if (!gd->arch.hob_list) + panic("hob list not found!"); + + serial_info = (struct serial_port_info *) + hob_get_guid_hob_data(gd->arch.hob_list, NULL, &guid); + + if (!serial_info) { + debug("failed to get serial port information\n"); + return -ENOENT; + } + debug("type:%d base=0x%08x baudrate=%d stride=%d clk=%d\n", + serial_info->type, + serial_info->base, + serial_info->baud, + serial_info->stride, + serial_info->clk); + + /* + * The serial_info->type provides port io or mmio access type info, + * but the access type will be controlled by + * CONFIG_SYS_NS16550_PORT_MAPPED or CONFIG_SYS_NS16550_MEM32. + * + * TBD: ns16550 access type configuration in runtime. + * ex) plat->access_type = serial_info->type + */ + plat->base = serial_info->base; + /* ns16550 uses reg_shift, then covert stride to shift */ + plat->reg_shift = (serial_info->stride >> 1); + plat->clock = serial_info->clk; + + return 0; +} + +static const struct udevice_id slimbootloader_serial_ids[] = { + { .compatible = "intel,slimbootloader-uart" }, + {} +}; + +U_BOOT_DRIVER(serial_slimbootloader) = { + .name = "serial_slimbootloader", + .id = UCLASS_SERIAL, + .of_match = slimbootloader_serial_ids, + .ofdata_to_platdata = slimbootloader_serial_ofdata_to_platdata, + .platdata_auto_alloc_size = sizeof(struct ns16550_platdata), + .priv_auto_alloc_size = sizeof(struct NS16550), + .probe = ns16550_serial_probe, + .ops = &ns16550_serial_ops, +}; diff --git a/arch/x86/include/asm/arch-slimbootloader/slimbootloader.h b/arch/x86/include/asm/arch-slimbootloader/slimbootloader.h index d9265ac534..5a0994544a 100644 --- a/arch/x86/include/asm/arch-slimbootloader/slimbootloader.h +++ b/arch/x86/include/asm/arch-slimbootloader/slimbootloader.h @@ -18,6 +18,15 @@ { 0xa9, 0xe4, 0x92, 0xf3, 0x57, 0xd1, 0x28, 0x32 } \ } +/** + * A GUID to get SerialPort info hob which is provided by Slim Bootloader + */ +#define LOADER_SERIAL_PORT_INFO_GUID \ + { \ + 0x6c6872fe, 0x56a9, 0x4403, \ + { 0xbb, 0x98, 0x95, 0x8d, 0x62, 0xde, 0x87, 0xf1 } \ + } + /** * A single entry of memory map information * @@ -35,6 +44,33 @@ struct memory_map_entry { u8 rsvd[6]; } __packed; +/** + * This includes serial port info which has already been initialized in previous + * Slim Bootloader stage. + * The Slim Bootloader initializes serial port regardless of debug/release build + * modes, and it passes the information to a payload thru hob. So, a payload can + * re-use the serial information without re-initializing serial port. + * + * @rev : revision of serial_port_info structure. currently 1. + * @rsvd : padding for alignment + * @type : port io: 1, mmio: 2 + * @base : io base address. ex) 0x3f8, 0x80001000 + * @baud : uart baud rate + * @stride: register stride in Bytes + * @clk : uart frequency in Hz + * @rsvd1 : reserved + */ +struct serial_port_info { + u8 rev; + u8 rsvd[3]; + u32 type; + u32 base; + u32 baud; + u32 stride; + u32 clk; + u32 rsvd1; +} __packed; + /** * This includes all memory map entries which is sorted based on physical start * address, from low to high, and carved out reserved, acpi nvs, acpi reclaim