From patchwork Wed May 9 09:59:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akshu Agrawal X-Patchwork-Id: 10388977 X-Patchwork-Delegate: rjw@sisk.pl 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 5DAC460153 for ; Wed, 9 May 2018 10:02:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D3CB28790 for ; Wed, 9 May 2018 10:02:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 41BB528DFA; Wed, 9 May 2018 10:02:04 +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 974DB28790 for ; Wed, 9 May 2018 10:02:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934232AbeEIKBv (ORCPT ); Wed, 9 May 2018 06:01:51 -0400 Received: from mail-sn1nam01on0059.outbound.protection.outlook.com ([104.47.32.59]:12544 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934017AbeEIKBe (ORCPT ); Wed, 9 May 2018 06:01:34 -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=ZJJtKQnr7Lv5ULVkJUjDZW2ia8EFHWTb/IuuIdw2GuY=; b=Rbz4U9bQR6ClDhN+tkCPSjc7UScQNAety2AkmfjF6oAht3BuEVAyaYjuGvDkllI6KIM0lGY5Xmvn3ilT2O2+J9CJwFjnD2tFDz1BGM/pKruqoei2DuvqoAGRfocIJm3qh77k9kbspqs4mFW/OMjrN8ySpxudslDxI2PPDGfjm0E= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Akshu.Agrawal@amd.com; Received: from akshu-HP-EliteBook-745-G2.amd.com (202.56.249.162) by MW2PR12MB2364.namprd12.prod.outlook.com (2603:10b6:907:8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.735.17; Wed, 9 May 2018 10:01:28 +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 v3 2/2] ACPI: APD: Add AMD misc clock handler support Date: Wed, 9 May 2018 17:59:01 +0800 Message-Id: <1525859941-23654-3-git-send-email-akshu.agrawal@amd.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1525859941-23654-1-git-send-email-akshu.agrawal@amd.com> References: <1525859941-23654-1-git-send-email-akshu.agrawal@amd.com> MIME-Version: 1.0 X-Originating-IP: [202.56.249.162] X-ClientProxiedBy: MA1PR0101CA0061.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:20::23) To MW2PR12MB2364.namprd12.prod.outlook.com (2603:10b6:907:8::11) 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); SRVR:MW2PR12MB2364; X-Microsoft-Exchange-Diagnostics: 1; MW2PR12MB2364; 3:A9znNR8IDj57hs5hMPgb1WT+gJn9npI2Tye5GoINY2usVrRSNguwqO7ftiJzSGW5xpX7YfBkes/LYK4spfu16QxJRJWQ9SLUFVF6KzO54w7so6FrNV9SyEvgVglfuahewxcRgtjJijgWlvFyUxHzR4c+RReO/wwc63//rK64c0Gk9poYi/G71ZjJBkOobgEC/qsu/Y/NqJD4krsvIbFUcY80cqShJ31w5k48V932SFGhPh25HnCNOcgUUE0kWyT0; 25:bNmNq1cP0eoUh/hga/iuHDgHBOOO/VoEyEvgTac5v7wFCkrfSZ6yC0xCA+WF0etlDJ+i+hY+yQ28TlIilCuydSaNI8yv9hES2ryfJi5mLiSR+UoFjfrd6sJObGKfwhha52Q4JkqKotCihsp76uRKYPXWFHfOEfmUHjjJheKqTp5rsOFA3s/p30ganOlDmCOkpfMSEVa9SgZT7TRPdlygqFi1M5raAL260+1wnz4PD23GXWKVJSizMniV1sQ4GSxB1h/T7nUeCI5y16o+Vd4eMKwhaKmGfk7f+C03lLiN5uIYnB7UWfs4UOhdWARGzo1yplxFZZXgZG8Scmp9bgwbXg==; 31:bKa4DYz8v8XzdGuc7z71xXxGfBRbka86Q9Zk0oM04xniKiWdoXkgcQ2uuUJo6OOx/h+0/1/GUUgdWHYvvvkOwy+0Plf/8W1w0soZ9jmWZYG7I72vcjXk0fUjmZ57GD1FykF9o0Og+bpBEIrDsiMErn4WEB2RDqYOJumfXB8mfPFZbK2t7xlEKSjce1zj7erfHK7MlOlq2FrNxXZvmkerEZXG2z2UOgZOXEH0KpkCC9s= X-MS-TrafficTypeDiagnostic: MW2PR12MB2364: X-Microsoft-Exchange-Diagnostics: 1; MW2PR12MB2364; 20:TpKsDuQr4AbwuMjeQxhS6nv2dMPnghiaeFif7pJ0CN4xAtvOSKxQ/HQDglTObhM0R7nENH8P6SrA9gQbC4HjH6nzc8GeyMDiOKrn/fzxYzCRqhpl2zVt7tTVFapweH4yI3utjuW7KJIDHfE0G1NFYptM3JE0pm+sPCLS00ioKPDNJrHEhC1nf/zYUP6BDO1dj5MNiHGAkJ7XGScVwiLxyMlf9zoG6Vr/PBNumagsnGbHI9ioYu1xoISCg3n29XyrFv1y26tC9tR9ZZLbWFcb+RVQ9Nkho9VJdiQVT170lIUusROgnShMXx3ruBaZPGI11cKWN2H15UVAZ0nnt5in1PbaRj0wN9aBhV0tqBg3kZSX27zISZ4KutT1eEzInziuZb4rDRbSYe6i668hbSfBi0Vf5RkuWmeYJ0lvlLm79lnusovGfoFbMhzFZDRa70rpSLf1jhVp8oDxwb+nVxEebbu/yk+xks+HpC0dTG/xOY7IKN2S+rjA3rnztaznWtIE; 4:x4qAxZ/bat2zLCzgQSei2ZGfNXHM+r4feTrC/wrWsLtaLLttme/Wl7jWVgtbKO5UTNx88BYGraSqTv2JKuK4FmrWTp735RKixZ3gKvyWFdxVQ2BSYn5bl35+n8qt/H2JJ27VE9pn+JWUBAIfvqcNnVTuZJG8WkA9sz21XsTRyKAuooIL5icstkpxh2ObUwinW9wkAzlIuVow+5Ae6xlV3W73PUJRsVk+2VmtgVfyBVQzSj+rVtZ4F4jHLflJUZ4dmlRllUKNCvHuBuRbJViPSo2zD4lC0CIICiIvZ4Euc0ond7DdsRfzYSSMniDZZFCp8n7+zvL2tu+PTifxl+qgCbnryxpakht/QixsdhH6JmM= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(21532816269658); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3002001)(93006095)(93001095)(3231254)(944501410)(52105095)(10201501046)(6055026)(149027)(150027)(6041310)(20161123558120)(20161123564045)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:MW2PR12MB2364; BCL:0; PCL:0; RULEID:; SRVR:MW2PR12MB2364; X-Forefront-PRVS: 0667289FF8 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(979002)(39860400002)(39380400002)(396003)(366004)(376002)(346002)(189003)(199004)(316002)(16526019)(305945005)(7736002)(53936002)(446003)(59450400001)(68736007)(16586007)(25786009)(50226002)(956004)(105586002)(186003)(109986005)(76176011)(2616005)(53416004)(476003)(486006)(26005)(51416003)(386003)(8936002)(8676002)(11346002)(81156014)(44832011)(7696005)(575784001)(3846002)(86362001)(6486002)(52116002)(81166006)(4326008)(478600001)(66066001)(6666003)(36756003)(72206003)(48376002)(1671002)(50466002)(106356001)(97736004)(6116002)(2906002)(47776003)(5660300001)(266003)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:MW2PR12MB2364; H:akshu-HP-EliteBook-745-G2.amd.com; 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; MW2PR12MB2364; 23:VlDfn2UYMtnNr/lG+F+rIM57kxI2pV+vGj89J6eZw?= =?us-ascii?Q?tTL3a6QNpGhOCiCChnVNhMN8TpwSVrsk37vd1ha49aYlch772Rno4GTTmFYr?= =?us-ascii?Q?Ss7cgo+EgSNTZ9bKbp4Lug47vmjFKFYjwrZlxS/cIPEuesIlxlG5KO+sCm0e?= =?us-ascii?Q?tQnckumwetvqlQGzGWWuEmHu9uYsX6SvMSh4WwaqJC9wcwD6pqqrqTIA6vrj?= =?us-ascii?Q?4r40LuxZeK+CkK15Y4r5cHmfuM3zGsCrfVOsHZmWhBPVK38NC6gzfDOsvroQ?= =?us-ascii?Q?OE9FRmrpL5JjTTo8Kwwvfx0mtiY91Q5hK76tx7zCG3Zwdcfqdap3jhh0f/tF?= =?us-ascii?Q?xhfFmhE0oMFWemyv18E2fDmjYbDvxggnyEjM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kIM+LVWhp31nwWil4=; 24:Ub56H4kFzS6UTFm0GtR9TYstqHxj0KWYG9XtcKvRiOHBcnz6wXEjDH10ig4K+Vf3p4NAWCi9YbTbjzn9wg0rxSxf3Kn9xq4neYPNeNsXWuE= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; MW2PR12MB2364; 7:fr+7hk/dmeJVlcdcWMZWO+qpPGkNS0KyWO2uYwTdv6vZkiFZKtiIqhUL3MzilgG5pn8nMpUruvGDjmMvpKQUL4Gbxn0eti5iaODpVNlvjMlBNvsGnH0K+Bs6TuNGS+Dng1rKSvQGhWyZIs/YqAxbydcbmibLglKgy4Mc3na5bGAg6aa5xg6dVRDBwpfXpWPCq29ttXmB9DzAOthF2siiiiq2jEjY3xXOiaY4sZSdPwZU5m5y1nsa6OjGIzoAEY2t; 20:uUmIsg4VppA9YRHeleTdqfBNTjwO5WmdRsVksG1B+7+0JrtW7elvkChIZckjCbcIBZI6VIjwO/876LRmXxfQaOQ+Xjb1G73u8mzDfUv/C0ONa5QwSZtjK+BOjCW8696iqPrZDiqAOLo/WbqoQ+0CSx5o+/z9IUL5tA3WReexdZ7HBosOm44H6CQ0u05fSArrq+IuNMYkLYVVdNBSc0YkA2JeSdP4hL2a5LZ1ksj2p21SAO8qrI/BjP4UDtsqZSWT X-MS-Office365-Filtering-Correlation-Id: 8a2c37d6-b56f-417e-9d8b-08d5b593d768 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2018 10:01:28.9695 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8a2c37d6-b56f-417e-9d8b-08d5b593d768 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR12MB2364 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 AMD SoC exposes clock for general purpose use. The clock registration is done in clk-st driver. The MMIO mapping are passed on to the clock driver for accessing the registers. The misc clock handler will create MMIO mappings to access the clock registers and enable the clock driver to expose the clock for use of drivers which will connect to it. Signed-off-by: Akshu Agrawal Reviewed-by: Daniel Kurtz --- v2: Submitted with dependent patch, removed unneeded kfree for devm_kzalloc v3: used devm_ioremap and fix coccinelle warning drivers/acpi/acpi_apd.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/drivers/acpi/acpi_apd.c b/drivers/acpi/acpi_apd.c index d553b00..2664452 100644 --- a/drivers/acpi/acpi_apd.c +++ b/drivers/acpi/acpi_apd.c @@ -11,6 +11,7 @@ */ #include +#include #include #include #include @@ -72,6 +73,47 @@ static int acpi_apd_setup(struct apd_private_data *pdata) } #ifdef CONFIG_X86_AMD_PLATFORM_DEVICE + +static int misc_check_res(struct acpi_resource *ares, void *data) +{ + struct resource res; + + return !acpi_dev_resource_memory(ares, &res); +} + +static int st_misc_setup(struct apd_private_data *pdata) +{ + struct acpi_device *adev = pdata->adev; + struct platform_device *clkdev; + struct st_clk_data *clk_data; + struct resource_entry *rentry; + struct list_head resource_list; + int ret; + + clk_data = devm_kzalloc(&adev->dev, sizeof(*clk_data), GFP_KERNEL); + if (!clk_data) + return -ENOMEM; + + INIT_LIST_HEAD(&resource_list); + ret = acpi_dev_get_resources(adev, &resource_list, misc_check_res, + NULL); + if (ret < 0) + return -ENOENT; + + list_for_each_entry(rentry, &resource_list, node) { + clk_data->base = devm_ioremap(&adev->dev, rentry->res->start, + resource_size(rentry->res)); + break; + } + + acpi_dev_free_resource_list(&resource_list); + + clkdev = platform_device_register_data(&adev->dev, "clk-st", + PLATFORM_DEVID_NONE, clk_data, + sizeof(*clk_data)); + return PTR_ERR_OR_ZERO(clkdev); +} + static const struct apd_device_desc cz_i2c_desc = { .setup = acpi_apd_setup, .fixed_clk_rate = 133000000, @@ -94,6 +136,10 @@ static int acpi_apd_setup(struct apd_private_data *pdata) .fixed_clk_rate = 48000000, .properties = uart_properties, }; + +static const struct apd_device_desc st_misc_desc = { + .setup = st_misc_setup, +}; #endif #ifdef CONFIG_ARM64 @@ -179,6 +225,7 @@ static int acpi_apd_create_device(struct acpi_device *adev, { "AMD0020", APD_ADDR(cz_uart_desc) }, { "AMDI0020", APD_ADDR(cz_uart_desc) }, { "AMD0030", }, + { "AMD0040", APD_ADDR(st_misc_desc)}, #endif #ifdef CONFIG_ARM64 { "APMC0D0F", APD_ADDR(xgene_i2c_desc) },