From patchwork Wed Jul 3 09:46:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Li X-Patchwork-Id: 1126789 X-Patchwork-Delegate: sbabic@denx.de 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=nxp.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.b="OjJ6ritI"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45dxF81C5xz9s4V for ; Wed, 3 Jul 2019 19:50:51 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id ADE7DC21DA6; Wed, 3 Jul 2019 09:50:47 +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=SPF_HELO_PASS, T_DKIM_INVALID 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 4591BC21E0B; Wed, 3 Jul 2019 09:46:43 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 6897DC21DAF; Wed, 3 Jul 2019 09:46:40 +0000 (UTC) Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10077.outbound.protection.outlook.com [40.107.1.77]) by lists.denx.de (Postfix) with ESMTPS id 360D1C21D74 for ; Wed, 3 Jul 2019 09:46:33 +0000 (UTC) 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=STsMql7jEnwcxdImgWVKm6EEy2c5+xTUmrPNGwv2EnI=; b=OjJ6ritIXo0kaBifvISG5lzixgP8clffFGh44PdWFuxBNJ6eiHQBpy/wepM8g1uTLqpaetKJ9VkpcSE71dx8UTDn8LsCp1kwhVI5yQOmGmVEvm4bOhv9v2q1Tn3tN/K3rxX4No7nMqzsA+ZM4A69cWL+17EG2OoJqkYvHCmr1mE= Received: from VI1PR04MB4414.eurprd04.prod.outlook.com (20.177.55.153) by VI1PR04MB4861.eurprd04.prod.outlook.com (20.177.49.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2032.20; Wed, 3 Jul 2019 09:46:31 +0000 Received: from VI1PR04MB4414.eurprd04.prod.outlook.com ([fe80::6517:7774:1033:6466]) by VI1PR04MB4414.eurprd04.prod.outlook.com ([fe80::6517:7774:1033:6466%7]) with mapi id 15.20.2032.019; Wed, 3 Jul 2019 09:46:31 +0000 From: Ye Li To: "sbabic@denx.de" , Fabio Estevam , Peng Fan Thread-Topic: [PATCH v2 2/7] misc: scu_api: Add new APIs for clk-imx8 driver Thread-Index: AQHVMYQx9gVVVZIxIkC0vCFkUCJtug== Date: Wed, 3 Jul 2019 09:46:31 +0000 Message-ID: <1562147167-27330-2-git-send-email-ye.li@nxp.com> References: <1562147167-27330-1-git-send-email-ye.li@nxp.com> In-Reply-To: <1562147167-27330-1-git-send-email-ye.li@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.7.4 x-clientproxiedby: HK0PR03CA0021.apcprd03.prod.outlook.com (2603:1096:203:2e::33) To VI1PR04MB4414.eurprd04.prod.outlook.com (2603:10a6:803:6e::25) authentication-results: spf=none (sender IP is ) smtp.mailfrom=ye.li@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.68] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: c8768bce-a88f-493f-770a-08d6ff9b53e6 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:VI1PR04MB4861; x-ms-traffictypediagnostic: VI1PR04MB4861: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:291; x-forefront-prvs: 00872B689F x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(979002)(4636009)(39860400002)(396003)(136003)(346002)(376002)(366004)(189003)(199004)(25786009)(4326008)(14454004)(66476007)(53936002)(486006)(316002)(5660300002)(7736002)(68736007)(6116002)(3846002)(6512007)(2906002)(478600001)(50226002)(71190400001)(6436002)(476003)(52116002)(36756003)(110136005)(73956011)(256004)(2501003)(8936002)(26005)(102836004)(86362001)(76176011)(186003)(81166006)(386003)(6506007)(6486002)(6636002)(446003)(81156014)(71200400001)(8676002)(99286004)(11346002)(305945005)(2616005)(14444005)(44832011)(66446008)(66946007)(64756008)(66556008)(66066001)(54906003)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR04MB4861; H:VI1PR04MB4414.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: mE3GP0yHEZx904/qj66YsLcxMwAbzRjg0d4xYuaTs50XNe/U9u1txgncyLDSmMyZGAPOG1h/miq2NuQ26W5qxXQsqZLwKNvzorIh2t/rD7jkyenIjQDFAM6y0Cyak0PrXFnsUDmAAV/8EUFMGHR589Nyx/eU7mZ+Pnb4SOeReVFw8tfjAgdr1WyplO3FAS6pR9M4C69oZ6bc0S6J+y7oDzlnVYGUMFtbZuNtjCv0dg2Xr8fmHn8M16ylwIw/LLFOflTJY3HkE39tQq+1fAe7wvnQo/Sbd2sRm1Hk0C2WlDVR5YMDzfySat9Oh6lYopMJ9bek4zVJNYRflIzFPv59uhJq0bxM+tSLxUdkMLYrgEPZ15xPpLV8qoxx9E8e17U8n2N/Omy09nOzJ+Zg7wGeioDdPAw3WboLf1EAC5ZNgzg= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c8768bce-a88f-493f-770a-08d6ff9b53e6 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Jul 2019 09:46:31.7497 (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: ye.li@nxp.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4861 Cc: "u-boot@lists.denx.de" , dl-uboot-imx Subject: [U-Boot] [PATCH v2 2/7] misc: scu_api: Add new APIs for clk-imx8 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" Add sc_misc_set_control to write the subsystem's DSC GPR registers, and sc_pm_set_clock_parent to select parent clock source. Signed-off-by: Ye Li --- Changes in v2: - None arch/arm/include/asm/arch-imx8/sci/sci.h | 4 ++ arch/arm/include/asm/arch-imx8/sci/svc/pm/api.h | 7 ++++ arch/arm/include/asm/arch-imx8/sci/types.h | 13 ++++++- drivers/misc/imx8/scu_api.c | 52 +++++++++++++++++++++++++ include/dt-bindings/soc/imx_rsrc.h | 2 + 5 files changed, 77 insertions(+), 1 deletion(-) diff --git a/arch/arm/include/asm/arch-imx8/sci/sci.h b/arch/arm/include/asm/arch-imx8/sci/sci.h index 9737769..52a3ac8 100644 --- a/arch/arm/include/asm/arch-imx8/sci/sci.h +++ b/arch/arm/include/asm/arch-imx8/sci/sci.h @@ -64,8 +64,12 @@ int sc_pm_get_clock_rate(sc_ipc_t ipc, sc_rsrc_t resource, sc_pm_clk_t clk, sc_pm_clock_rate_t *rate); int sc_pm_clock_enable(sc_ipc_t ipc, sc_rsrc_t resource, sc_pm_clk_t clk, sc_bool_t enable, sc_bool_t autog); +int sc_pm_set_clock_parent(sc_ipc_t ipc, sc_rsrc_t resource, sc_pm_clk_t clk, + sc_pm_clk_parent_t parent); /* MISC API */ +int sc_misc_set_control(sc_ipc_t ipc, sc_rsrc_t resource, + sc_ctrl_t ctrl, u32 val); int sc_misc_get_control(sc_ipc_t ipc, sc_rsrc_t resource, sc_ctrl_t ctrl, u32 *val); void sc_misc_get_boot_dev(sc_ipc_t ipc, sc_rsrc_t *boot_dev); diff --git a/arch/arm/include/asm/arch-imx8/sci/svc/pm/api.h b/arch/arm/include/asm/arch-imx8/sci/svc/pm/api.h index 9008b85..109ec27 100644 --- a/arch/arm/include/asm/arch-imx8/sci/svc/pm/api.h +++ b/arch/arm/include/asm/arch-imx8/sci/svc/pm/api.h @@ -35,6 +35,13 @@ #define SC_PM_CLK_MODE_AUTOGATE_HW 4U /* Clock is in HW autogate mode */ #define SC_PM_CLK_MODE_AUTOGATE_SW_HW 5U /* Clock is in SW-HW autogate mode */ +/* Defines for sc_pm_clk_parent_t */ +#define SC_PM_PARENT_XTAL 0U /*!< Parent is XTAL. */ +#define SC_PM_PARENT_PLL0 1U /*!< Parent is PLL0 */ +#define SC_PM_PARENT_PLL1 2U /*!< Parent is PLL1 or PLL0/2 */ +#define SC_PM_PARENT_PLL2 3U /*!< Parent in PLL2 or PLL0/4 */ +#define SC_PM_PARENT_BYPS 4U /*!< Parent is a bypass clock. */ + typedef u8 sc_pm_power_mode_t; typedef u8 sc_pm_clk_t; typedef u8 sc_pm_clk_mode_t; diff --git a/arch/arm/include/asm/arch-imx8/sci/types.h b/arch/arm/include/asm/arch-imx8/sci/types.h index 9eadc88..2d5912e 100644 --- a/arch/arm/include/asm/arch-imx8/sci/types.h +++ b/arch/arm/include/asm/arch-imx8/sci/types.h @@ -185,7 +185,18 @@ typedef u64 sc_ipc_t; #define SC_C_RST0 43U #define SC_C_RST1 44U #define SC_C_SEL0 45U -#define SC_C_LAST 46U +#define SC_C_CALIB0 46U +#define SC_C_CALIB1 47U +#define SC_C_CALIB2 48U +#define SC_C_IPG_DEBUG 49U +#define SC_C_IPG_DOZE 50U +#define SC_C_IPG_WAIT 51U +#define SC_C_IPG_STOP 52U +#define SC_C_IPG_STOP_MODE 53U +#define SC_C_IPG_STOP_ACK 54U +#define SC_C_SYNC_CTRL 55U +#define SC_C_LAST 56U + #define SC_P_ALL ((sc_pad_t)UINT16_MAX) /* All pads */ diff --git a/drivers/misc/imx8/scu_api.c b/drivers/misc/imx8/scu_api.c index d9c4d5d..cab8995 100644 --- a/drivers/misc/imx8/scu_api.c +++ b/drivers/misc/imx8/scu_api.c @@ -93,6 +93,31 @@ int sc_pm_clock_enable(sc_ipc_t ipc, sc_rsrc_t resource, sc_pm_clk_t clk, return ret; } +int sc_pm_set_clock_parent(sc_ipc_t ipc, sc_rsrc_t resource, + sc_pm_clk_t clk, sc_pm_clk_parent_t parent) +{ + struct udevice *dev = gd->arch.scu_dev; + int size = sizeof(struct sc_rpc_msg_s); + struct sc_rpc_msg_s msg; + int ret; + + RPC_VER(&msg) = SC_RPC_VERSION; + RPC_SVC(&msg) = (u8)(SC_RPC_SVC_PM); + RPC_FUNC(&msg) = (u8)(PM_FUNC_SET_CLOCK_PARENT); + RPC_U16(&msg, 0U) = (u16)(resource); + RPC_U8(&msg, 2U) = (u8)(clk); + RPC_U8(&msg, 3U) = (u8)(parent); + RPC_SIZE(&msg) = 2U; + + ret = misc_call(dev, SC_FALSE, &msg, size, &msg, size); + if (ret) + printf("%s: resource:%d clk:%d: parent clk: %d, res:%d\n", + __func__, resource, clk, parent, RPC_R8(&msg)); + + return ret; +} + + int sc_pm_set_resource_power_mode(sc_ipc_t ipc, sc_rsrc_t resource, sc_pm_power_mode_t mode) { @@ -146,6 +171,33 @@ int sc_pad_set(sc_ipc_t ipc, sc_pad_t pad, u32 val) } /* MISC */ +int sc_misc_set_control(sc_ipc_t ipc, sc_rsrc_t resource, + sc_ctrl_t ctrl, u32 val) +{ + struct udevice *dev = gd->arch.scu_dev; + int size = sizeof(struct sc_rpc_msg_s); + struct sc_rpc_msg_s msg; + int ret; + + if (!dev) + hang(); + + RPC_VER(&msg) = SC_RPC_VERSION; + RPC_SVC(&msg) = (u8)(SC_RPC_SVC_MISC); + RPC_FUNC(&msg) = (u8)(MISC_FUNC_SET_CONTROL); + RPC_U32(&msg, 0U) = (u32)(ctrl); + RPC_U32(&msg, 4U) = (u32)(val); + RPC_U16(&msg, 8U) = (u16)(resource); + RPC_SIZE(&msg) = 4U; + + ret = misc_call(dev, SC_FALSE, &msg, size, &msg, size); + if (ret) + printf("%s: ctrl:%d resource:%d: res:%d\n", + __func__, ctrl, resource, RPC_R8(&msg)); + + return ret; +} + int sc_misc_get_control(sc_ipc_t ipc, sc_rsrc_t resource, sc_ctrl_t ctrl, u32 *val) { diff --git a/include/dt-bindings/soc/imx_rsrc.h b/include/dt-bindings/soc/imx_rsrc.h index 4870eb9..a1c3b1f 100644 --- a/include/dt-bindings/soc/imx_rsrc.h +++ b/include/dt-bindings/soc/imx_rsrc.h @@ -554,4 +554,6 @@ #define SC_R_VPU 540 #define SC_R_LAST 541 +#define SC_R_NONE 0xFFF0 + #endif /* DT_BINDINGS_RSCRC_IMX_H */