From patchwork Mon Oct 12 06:23:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 317611 Delivered-To: patch@linaro.org Received: by 2002:a92:d603:0:0:0:0:0 with SMTP id w3csp4324500ilm; Sun, 11 Oct 2020 22:58:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPx+ISeJ6runcKOqLWEChwErNjVety5pynKy/uZ3m2nK9LsKawsEjuGyqyJFEj+wZTM+KM X-Received: by 2002:aa7:c7c2:: with SMTP id o2mr12747571eds.366.1602482295084; Sun, 11 Oct 2020 22:58:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1602482295; cv=pass; d=google.com; s=arc-20160816; b=kt4HVTqH64CEkn/izV7u7tbQrQKsT8vxd9iCYQonc/r8OwIwnn2yYmB+BV1u3Tg4WB /AG4vdPEyG8H6iPK1yXPfkeb7uSl2Pqx6X2sTDXflKiH96Wf2Mgt33zWdhvXjK6/6dfu S7omLefWwG9IEvOehRqFPF5oPdBRaAlgth8AhfxyYtXiho245MB4xk9Tu+OScB4MUTRQ 249MwJ+UcjmGFejq5SweAUxI9rczmjCyNxFfdzqqpVMkd6146lkcmJvZWgYxMbRNhwCQ 5mcGHEUIXJNH8eTnod0ljQjNusZeP0bhNUQlkbVITUXiLUo1/SS/3QT8dzSoVkEBNnIP 4jTw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version :content-transfer-encoding:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=oYkWu8Jyra/FYE0iM/n998E5/9s4OLBH6yfyXmecTRc=; b=X+mCrHHIeCKy8UFacScnGd2W9DP42g1jNkW7gzlBYVHzxeSQLsz0OM+Kdmodbd9bIl jTMYC44qYuV8PZtxFPmne46d1+Wnd2XVAzMkv2E4DeGdL5G/g6YNEYWMnggXCzPhIbi/ kgtyd2d25KwfYTujOOxsowL9TRb+MQYck6H+v4Ae1HhyV5WozblvD8IcIIARlicliLyc Jl+nxQ5AoeKoLsGkUMqJyCNIPgA6p8k3GeItEimCV/6aZSxnXN6hdXUDXnMWMnr4DXD8 QplZ1EWAZ8RmRketGm3fGkfxIQ2pEFEy6DPJnmcOn/20rS+95Rn1s1FlVFm+0lGzhGJg ya3w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=hYFFhK7n; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id y2si10841330ede.379.2020.10.11.22.58.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Oct 2020 22:58:15 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=hYFFhK7n; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 383FD824B0; Mon, 12 Oct 2020 07:57:33 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.b="hYFFhK7n"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2DBC1824B1; Mon, 12 Oct 2020 07:57:31 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FORGED_SPF_HELO,MSGID_FROM_MTA_HEADER, SPF_HELO_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0613.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe02::613]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 7CCB8824A4 for ; Mon, 12 Oct 2020 07:57:28 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=peng.fan@nxp.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BGNASOrSrZqI+WKvWuYR7xzwdPFF4WBNpn0IJh5gWAwztdzjGyi0ycuuupYg9xNfx/8gqDmL3j7+aN9Om00AukvLX/wx6Ukzv7Y914bzFB7lPO7EFj70TWZ6nAGdWeWFUiGsHIoNZXYgtu20zBfxwUX/w+f5ayW0ssz9tE/HHI1z0wxODm3q+SvtqxjNvPJubYNvxGfPz1rVPZ71g/qBqo9jur3BXaXbk1T0kKTRrq6iN73jwVW2Z+DaahSZRXLmNyMaA3mB6gI5rdVokzZp6/aB9Ak9y43DcP6mgJamZwcuCESQJEl9RUxaZbPSYFY8aaT6lgwJagT1/YgzV3656w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oYkWu8Jyra/FYE0iM/n998E5/9s4OLBH6yfyXmecTRc=; b=KkC3e0C2L+44h35eh+J3x1r2qgis9bzmBLY6vbkAit24Uf4LWFu57OiHBK9gY0JC2OBPqGbiaQ94ppAqnzdcvdJLBGYQKdYGwlLXP3BX9MnhYErjt+H90ZNl85cLB8DNPT5A2ctE6PYErCAagBASzHEAYskleSacTYsO1u8X7WfNfy8gbSugtX0jEgxdovcCuE6FcpYm8liuaV/ObjF6VGmfo4i3b8hVrdjNdjWmI1O2R11sFzyY1TEtOoNtPPFtFZM0MAyxLxirl1H5/pviYDC3gyJB5ZExaLlnYPokaCfltJg+oX/drImDFnwQZDXvqY9N8+D+vQW9j1JT8wgZPw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oYkWu8Jyra/FYE0iM/n998E5/9s4OLBH6yfyXmecTRc=; b=hYFFhK7nySOSlx0aWF1SjNNYtReGfhRjE/cZ14H6FJjSfcuPWSU8BN3UHxvoZWYwm5aiioh0akuV1/7tggg2fXc74wuQJdhrC+wZUuGqS2knWxj2BRpiWqPBYZuiEjThA7jGtmGHkpzpM0fKXy6N3jiCw4xWuUihwTZiTYLY3Yk= Authentication-Results: denx.de; dkim=none (message not signed) header.d=none;denx.de; dmarc=none action=none header.from=nxp.com; Received: from DB6PR0402MB2760.eurprd04.prod.outlook.com (2603:10a6:4:a1::14) by DB7PR04MB4235.eurprd04.prod.outlook.com (2603:10a6:5:22::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.26; Mon, 12 Oct 2020 05:57:27 +0000 Received: from DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::35c5:8c71:91f3:6bc6]) by DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::35c5:8c71:91f3:6bc6%12]) with mapi id 15.20.3455.029; Mon, 12 Oct 2020 05:57:27 +0000 From: Peng Fan To: sbabic@denx.de, festevam@gmail.com, marex@denx.de, lukma@denx.de Cc: uboot-imx@nxp.com, u-boot@lists.denx.de, Peng Fan Subject: [PATCH 5/8] imx8m: enable usb power domain Date: Mon, 12 Oct 2020 14:23:51 +0800 Message-Id: <20201012062354.3743-6-peng.fan@nxp.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201012062354.3743-1-peng.fan@nxp.com> References: <20201012062354.3743-1-peng.fan@nxp.com> X-Originating-IP: [119.31.174.71] X-ClientProxiedBy: SG2PR01CA0105.apcprd01.prod.exchangelabs.com (2603:1096:3:15::31) To DB6PR0402MB2760.eurprd04.prod.outlook.com (2603:10a6:4:a1::14) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from linux-1xn6.ap.freescale.net (119.31.174.71) by SG2PR01CA0105.apcprd01.prod.exchangelabs.com (2603:1096:3:15::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.22 via Frontend Transport; Mon, 12 Oct 2020 05:57:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 0fffa67c-bfb1-4aeb-bee3-08d86e73b2cd X-MS-TrafficTypeDiagnostic: DB7PR04MB4235: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:37; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mmGXbwXG5IS8ZhA3rb3KReQfDmTrt6TnCm+L5IGnPkA5Z49EqyrPJidssSpMCgREt0CNa5XuTYrulkc3UJy8o14ZAhTqNCIZr0P3cKBHNrrdRL3+uTgVbRA9k93/tFd78iA1x3awfDO7qwRnsaFfBptbWl6q0L9+TL86t+dnJqH2fUpnsWrpttWKChQOBbNkr5HlMEYEcWcf9EJUsTrVDBrFltLrxcAbH6h1kNgdPG0oQ01x637buCJscSFePq4we9CErv5VUoCY+P7hk+HD2QqC7CxU6mW0/oY/tDoUk6TFm7Tp88AXpyGpgzKeXwS23Vmi1Sx+Wd5vU7gq2SN9Q2guIY+0r25zIxqXCdAM6TulgNdE4vyTdqv+tN3NhF41 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB6PR0402MB2760.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(39860400002)(376002)(346002)(366004)(136003)(52116002)(83380400001)(8936002)(6506007)(4326008)(8676002)(44832011)(6512007)(1076003)(6486002)(86362001)(5660300002)(6666004)(66476007)(66946007)(66556008)(316002)(36756003)(2616005)(956004)(2906002)(186003)(26005)(478600001)(16526019)(32563001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 9swdmozo7+UViAN6XAkzEEkpMCiRYYIWIJXakkEEgGWDZQEpdhvZm/fiO5Wx5fxnlXaGcJOweFroxg2j5JV9eXapNWsIrRadTrFR1scKDoVSvFZnYpyRY0zRDuDktes+qsvAdwEDiDN5Br/TmTsiriTxQ8TstPkcTq9dy+lSs2TXPtAjPZFjCfFVd25ZIRcYmiHCxgKgewHMuG1y05o0gNpCNADKgJOYMlIJWFhJNE9EMzwQFcNVbMqlQzCcqMdnvFKhAxGMPEthOpgZYgs2rplqsIncRfLJJNs3zTcnFVfFXnCj/cwapXNB41HIuMhTxCQIhnI1zAQv0l7rglIyeKb3A52jQtgXRMmHj5Uo2AiGuBzh04IbDs+1hMLUqpm20ce6ocuqEdkO7jms8O+pqECMUdNeUhrkEhZ8uUD7dXu7EwmctFjYsImu4I+HlJAJuVzlkF4EiytEsPnx9yNnk80evJuIajHzUb6NYPrE+7GjFJYDRTWbod2CbD8lWA4jAWAAVe8CrmwBsJ/gSvkMuJpyWxOE7hfoTPyhqP17gyupIuMR+GpP4Ikdtljd4a6NwTxnIVIzjRSj/Al1CeZwsFtutEgWaFV3cKa/3/Xik52iHC5bRPf0iv1a00YsdHCuLxRcSPFkNfbgtG6P4mBXTA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0fffa67c-bfb1-4aeb-bee3-08d86e73b2cd X-MS-Exchange-CrossTenant-AuthSource: DB6PR0402MB2760.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Oct 2020 05:57:27.5116 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: MIgR6HDq5kzS9iXkOshKw/AdaIjJ5wXt0dfcjlIKsk6uj9hu8OhbJUctjkiCyaeY0DZDxSR9xtpx9tNDIksXdQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB4235 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean Enable usb power domain, we are not using a power domain driver now. Currently NXP use a ARM SIP based power domain driver, but this has been rejected by Linux Kernel, so we are thinking SCMI, however kernel stuff still not settle down, to make uboot feature work, we directly use SIP call for U-Boot and MMIO for SPL. Signed-off-by: Peng Fan --- arch/arm/include/asm/arch-imx8m/sys_proto.h | 1 + arch/arm/mach-imx/imx8m/soc.c | 55 +++++++++++++++++++++ 2 files changed, 56 insertions(+) -- 2.28.0 diff --git a/arch/arm/include/asm/arch-imx8m/sys_proto.h b/arch/arm/include/asm/arch-imx8m/sys_proto.h index d328542ece..3e54f9b676 100644 --- a/arch/arm/include/asm/arch-imx8m/sys_proto.h +++ b/arch/arm/include/asm/arch-imx8m/sys_proto.h @@ -11,6 +11,7 @@ void set_wdog_reset(struct wdog_regs *wdog); void enable_tzc380(void); void restore_boot_params(void); +int imx8m_usb_power(int usb_id, bool on); extern unsigned long rom_pointer[]; enum boot_device get_boot_device(void); bool is_usb_boot(void); diff --git a/arch/arm/mach-imx/imx8m/soc.c b/arch/arm/mach-imx/imx8m/soc.c index 9bca5bf972..830d1ac901 100644 --- a/arch/arm/mach-imx/imx8m/soc.c +++ b/arch/arm/mach-imx/imx8m/soc.c @@ -1112,3 +1112,58 @@ long long env_get_offset(long long defautl_offset) } #endif #endif + +#ifdef CONFIG_SPL_BUILD +static uint32_t gpc_pu_m_core_offset[11] = { + 0xc00, 0xc40, 0xc80, 0xcc0, + 0xdc0, 0xe00, 0xe40, 0xe80, + 0xec0, 0xf00, 0xf40, +}; + +#define PGC_PCR 0 + +void imx_gpc_set_m_core_pgc(unsigned int offset, bool pdn) +{ + uint32_t val; + uintptr_t reg = GPC_BASE_ADDR + offset; + + val = readl(reg); + val &= ~(0x1 << PGC_PCR); + + if(pdn) + val |= 0x1 << PGC_PCR; + writel(val, reg); +} + +void imx8m_usb_power_domain(uint32_t domain_id, bool on) +{ + uint32_t val; + uintptr_t reg; + + imx_gpc_set_m_core_pgc(gpc_pu_m_core_offset[domain_id], true); + + reg = GPC_BASE_ADDR + (on ? 0xf8 : 0x104); + val = 1 << (domain_id > 3 ? (domain_id + 3) : domain_id); + writel(val, reg); + while (readl(reg) & val) + ; + imx_gpc_set_m_core_pgc(gpc_pu_m_core_offset[domain_id], false); +} +#endif + +int imx8m_usb_power(int usb_id, bool on) +{ + if (usb_id > 1) + return -EINVAL; + +#ifdef CONFIG_SPL_BUILD + imx8m_usb_power_domain(2 + usb_id, on); +#else + struct arm_smccc_res res; + + /* Get ARM Trusted Firmware commit id */ + arm_smccc_smc(IMX_SIP_GPC, IMX_SIP_GPC_PM_DOMAIN, 2 + usb_id, on, 0, 0, 0, 0, &res); +#endif + + return 0; +}