From patchwork Mon May 7 10:13:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akshu Agrawal X-Patchwork-Id: 10383845 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3EBC6602D8 for ; Mon, 7 May 2018 10:17:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F23828B08 for ; Mon, 7 May 2018 10:17:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 22CC228B0A; Mon, 7 May 2018 10:17:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 986B828B08 for ; Mon, 7 May 2018 10:17:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752136AbeEGKRJ (ORCPT ); Mon, 7 May 2018 06:17:09 -0400 Received: from mail-bl2nam02on0075.outbound.protection.outlook.com ([104.47.38.75]:42592 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752003AbeEGKQD (ORCPT ); Mon, 7 May 2018 06:16:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Pomy1B2CUZ6pN8UL6+bQh8cheWAlQFycnR6gq93rDWw=; b=G8G9Gw3bCuHh3TwVhSShhwHayBLPSZp43aU7lKGmNiqVfnSC0IpIi33+cTGrW6x02VFaggwYHaHMYhoDMaVixFrA1l+GhdtI5WMiL5i9AgMmv607ku6FODBDHA06R7l+qVOnZEFlNiIW9GGbFnC/8Fse6WajWaJ1xmIZfpmulA4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Akshu.Agrawal@amd.com; Received: from akshu-HP-EliteBook-745-G2.mshome.net (202.56.249.162) by SN1PR12MB2366.namprd12.prod.outlook.com (2603:10b6:802:25::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.735.16; Mon, 7 May 2018 10:15:57 +0000 From: Akshu Agrawal Cc: djkurtz@chromium.org, akshu.agrawal@amd.com, Alexander.Deucher@amd.com, mturquette@baylibre.com, sboyd@kernel.org, christian.koenig@amd.com, airlied@redhat.com, Shaoyun.Liu@amd.com, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, rjw@rjwysocki.net, lenb@kernel.org, linux-acpi@vger.kernel.org Subject: [PATCH v4 1/2] clk: x86: Add ST oscout platform clock Date: Mon, 7 May 2018 18:13:32 +0800 Message-Id: <1525688013-9928-2-git-send-email-akshu.agrawal@amd.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1525688013-9928-1-git-send-email-akshu.agrawal@amd.com> References: <1525688013-9928-1-git-send-email-akshu.agrawal@amd.com> MIME-Version: 1.0 X-Originating-IP: [202.56.249.162] X-ClientProxiedBy: MA1PR01CA0099.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:1::15) To SN1PR12MB2366.namprd12.prod.outlook.com (2603:10b6:802:25::19) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(2017052603328)(7153060)(7193020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CX+J1kj9AAYYuOM8rZZzvXXykqUmijXFjkBffXkef9Hkdr1M866t2trqV6Jbfnjj0f6/nbo+Ku9OfkjmQM9rVYMoii2opJbckiWUBu/hrZBeG49i70LH7DHlFN3d57SqKAWKiLm+KLbE/V350lbZfNhJgQI1XU40/Ff73bg7Bncj7IM8duVlA0ItwSFnBIxv3uBC36fazqGuAADWzQXRHuYfDI9dVDmxu3d81xC/8n4/XHeY+H/hPH029KA/NlApKlo22mvmH9QtPD6t/ePTicRttBFYmT0pDoYIRMEXqvOnOs0SVy+e+nIWdPvQFCSBJ16CNdJ4rawPrEAl6AbFZ0xe+eHEti1YuNBUysVMUmdqs9PG7WuxHZFCnXiUksNkYGmzEK6yZptlMKyCTo19jyM/5; 4:dMAz+lFfrgKeXWUMiahngD049KRG+PUxEpsfZYbzxKEYXL3pwLuwFbhW/eIwVzmk41RZI6fP+JLsa7aME4fmq+6sWvJCX7O3VYYrBL9xtzrHNPHiJ6W99y2cDYk9C8I+KXaWU6xKqfxWBywjeVRK/3lhBLH6t5CQoSNjf6M6nRR3BXa47n5Skb5iFl2PZE59X6uQ715+oWQzYHCiBu2jD5HMG3R0ljCYB8/XJnBJB8S3s3Y2vUtyO1w2Ky8k7Up466H6dwaOcd5ADGX2Jr7ZFR9o9QAPst3KkEHjsEPQRa3GmkqXSoR1EhrD9aQOtsjJ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3002001)(10201501046)(3231254)(944501410)(52105095)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(6072148)(201708071742011); SRVR:SN1PR12MB2366; BCL:0; PCL:0; RULEID:; SRVR:SN1PR12MB2366; X-Forefront-PRVS: 066517B35B X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(39380400002)(39860400002)(366004)(376002)(346002)(189003)(199004)(1671002)(50466002)(8676002)(48376002)(66066001)(316002)(81166006)(186003)(81156014)(4326008)(44832011)(6116002)(69596002)(26005)(6486002)(3846002)(6666003)(8936002)(47776003)(305945005)(16586007)(25786009)(478600001)(2906002)(68736007)(50226002)(53936002)(59450400001)(36756003)(7736002)(6512007)(86362001)(105586002)(5660300001)(52116002)(51416003)(76176011)(53416004)(476003)(386003)(6506007)(72206003)(16526019)(446003)(106356001)(11346002)(109986005)(2616005)(956004)(486006)(97736004)(266003); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB2366; H:akshu-HP-EliteBook-745-G2.mshome.net; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR12MB2366; 23:oteH3m1PQw7x+pJWCsQIVL582nNQvVKD3mhgs//iS?= =?us-ascii?Q?XksD8Ix1XqvY6RlssdjHtlqNTVVaFTRR1JjR1isauDiAVYTmg+kEsgTC+aAK?= =?us-ascii?Q?s7RYwNz5kmnQqyM89urb/p1U0k4yeAX5GiJI7nkQunFb0X86OztE3bO5juov?= =?us-ascii?Q?S91+Wq2d6an7McnaldT9KNZ5BY0Wktw8nVbXXfPiwMaIMp5/AvdPloycK/ov?= =?us-ascii?Q?DXtzyg79UVRO4IvuxvHx/aaOioduZiKpHpn0kroXnA1td7DFIkjChQl9kFKe?= =?us-ascii?Q?1pyZU3IxEeWlG1WbLLelKRJn3D2AdDJmBV59NCb5afB+FxmSL7ZcTfu+2z/o?= =?us-ascii?Q?aXR3qbaJSd9dT/Gi1bttbnJWdIf/8hOgjLDIjwGfy87/witDVirrC5jWPRxg?= =?us-ascii?Q?vJ8sYwu/Ns73xOBLE/Tb5Gz2y/Wo6VFJmKXeAQGX4FzJGdFE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M X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB2366; 7:qvW7mvXiGRzKg0VGhAHxssHmIKmGOhUl2Fd57npGYv4A/YC6L1axuauZJRSfPWSd0qzZmFoz8IFSaSi1+2C0WW13Gr28c8tFdof1KICT/1kmfi/0qr4e5Vzcp/5bf3oc3fgzj49t9KKdqvAPSGPBYBQDbZqoZV0iX9T/Ixsga4Qitw3FIx4kEH5/0I9IqhFemQFzE0Zw0db5U8yAmZTMTwTNGNDFw38fHCh9Z5lbwBPfSy8sZ65YlsQGya24mv6w; 20:x8km512fqpdcqh+H6/xGE1tAlAUhwSEzzK+ima74OqeAx5m3HNpMIkgECiByv5phN8WABCZOltAatVPmI82lS0MMdlNybo6zAVBL43lkeKUlK8TzUki3nrNmHiPeUHBpZjhcpAFgHgWXx61FtCcV1XE3KV0DCHwie3HLoBVJshiP40LeibTYlG6eCaVS4CdZVBByVXvDdCxOtmtznEQ7TNu2B+0I8wSet2nWLJgIyt40taRWtmWB+dOM5oireGgE X-MS-Office365-Filtering-Correlation-Id: 1882ac0f-1086-4c11-df59-08d5b4038891 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2018 10:15:57.6500 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1882ac0f-1086-4c11-df59-08d5b4038891 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2366 To: unlisted-recipients:; (no To-header on input) Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Stoney SoC provides oscout clock. This clock can support 25Mhz and 48Mhz of frequency. The clock is available for general system use. Signed-off-by: Akshu Agrawal --- v2: config change, added SPDX tag and used clk_hw_register_. v3: Fix kbuild warning for checking of NULL pointer v4: unregister clk_hw in driver remove, add .suppress_bind_attrs drivers/clk/x86/Makefile | 3 +- drivers/clk/x86/clk-st.c | 85 ++++++++++++++++++++++++++++++++++++ include/linux/platform_data/clk-st.h | 17 ++++++++ 3 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 drivers/clk/x86/clk-st.c create mode 100644 include/linux/platform_data/clk-st.h diff --git a/drivers/clk/x86/Makefile b/drivers/clk/x86/Makefile index 1367afb..00303bc 100644 --- a/drivers/clk/x86/Makefile +++ b/drivers/clk/x86/Makefile @@ -1,3 +1,4 @@ +obj-$(CONFIG_PMC_ATOM) += clk-pmc-atom.o +obj-$(CONFIG_X86_AMD_PLATFORM_DEVICE) += clk-st.o clk-x86-lpss-objs := clk-lpt.o obj-$(CONFIG_X86_INTEL_LPSS) += clk-x86-lpss.o -obj-$(CONFIG_PMC_ATOM) += clk-pmc-atom.o diff --git a/drivers/clk/x86/clk-st.c b/drivers/clk/x86/clk-st.c new file mode 100644 index 0000000..8a7795c --- /dev/null +++ b/drivers/clk/x86/clk-st.c @@ -0,0 +1,85 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * clock framework for AMD Stoney based clocks + * + * Copyright 2018 Advanced Micro Devices, Inc. + */ + +#include +#include +#include +#include +#include + +/* Clock Driving Strength 2 register */ +#define CLKDRVSTR2 0x28 +/* Clock Control 1 register */ +#define MISCCLKCNTL1 0x40 +/* Auxiliary clock1 enable bit */ +#define OSCCLKENB 2 +/* 25Mhz auxiliary output clock freq bit */ +#define OSCOUT1CLK25MHZ 16 + +#define ST_CLK_48M 0 +#define ST_CLK_25M 1 +#define ST_CLK_MUX 2 +#define ST_CLK_GATE 3 +#define ST_MAX_CLKS 4 + +static const char * const clk_oscout1_parents[] = { "clk48MHz", "clk25MHz" }; + +static int st_clk_probe(struct platform_device *pdev) +{ + struct st_clk_data *st_data; + struct clk_hw **hws; + + st_data = dev_get_platdata(&pdev->dev); + if (!st_data || !st_data->base) + return -EINVAL; + + hws = devm_kzalloc(&pdev->dev, sizeof(*hws) * ST_MAX_CLKS, GFP_KERNEL); + if (!hws) + return -ENOMEM; + + hws[ST_CLK_48M] = clk_hw_register_fixed_rate(NULL, "clk48MHz", NULL, 0, + 48000000); + hws[ST_CLK_25M] = clk_hw_register_fixed_rate(NULL, "clk25MHz", NULL, 0, + 25000000); + + hws[ST_CLK_MUX] = clk_hw_register_mux(NULL, "oscout1_mux", + clk_oscout1_parents, ARRAY_SIZE(clk_oscout1_parents), + 0, st_data->base + CLKDRVSTR2, OSCOUT1CLK25MHZ, 3, 0, NULL); + + clk_set_parent(hws[ST_CLK_MUX]->clk, hws[ST_CLK_25M]->clk); + + hws[ST_CLK_GATE] = clk_hw_register_gate(NULL, "oscout1", "oscout1_mux", + 0, st_data->base + MISCCLKCNTL1, OSCCLKENB, + CLK_GATE_SET_TO_DISABLE, NULL); + + clk_hw_register_clkdev(hws[ST_CLK_GATE], "oscout1", NULL); + + platform_set_drvdata(pdev, hws); + return 0; +} + +static int st_clk_remove(struct platform_device *pdev) +{ + struct clk_hw **hws; + int i; + + hws = platform_get_drvdata(pdev); + + for (i = 0; i < ST_MAX_CLKS; i++) + clk_hw_unregister(hws[i]); + return 0; +} + +static struct platform_driver st_clk_driver = { + .driver = { + .name = "clk-st", + .suppress_bind_attrs = true, + }, + .probe = st_clk_probe, + .remove = st_clk_remove, +}; +builtin_platform_driver(st_clk_driver); diff --git a/include/linux/platform_data/clk-st.h b/include/linux/platform_data/clk-st.h new file mode 100644 index 0000000..188184d --- /dev/null +++ b/include/linux/platform_data/clk-st.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * clock framework for AMD Stoney based clock + * + * Copyright 2018 Advanced Micro Devices, Inc. + */ + +#ifndef __CLK_ST_H +#define __CLK_ST_H + +#include + +struct st_clk_data { + void __iomem *base; +}; + +#endif /* __CLK_ST_H */