From patchwork Fri Dec 4 03:24:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Hongcheng X-Patchwork-Id: 7765491 Return-Path: X-Original-To: patchwork-dmaengine@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5A2AD9F39B for ; Fri, 4 Dec 2015 03:42:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4179E205CA for ; Fri, 4 Dec 2015 03:42:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0A62C203EC for ; Fri, 4 Dec 2015 03:42:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755184AbbLDDl7 (ORCPT ); Thu, 3 Dec 2015 22:41:59 -0500 Received: from mail-by2on0088.outbound.protection.outlook.com ([207.46.100.88]:47232 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750831AbbLDDlm (ORCPT ); Thu, 3 Dec 2015 22:41:42 -0500 Received: from BY2PR12CA0033.namprd12.prod.outlook.com (10.160.121.43) by CY1PR12MB0714.namprd12.prod.outlook.com (10.163.238.20) with Microsoft SMTP Server (TLS) id 15.1.337.19; Fri, 4 Dec 2015 03:25:50 +0000 Received: from CO1NAM03FT009.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::203) by BY2PR12CA0033.outlook.office365.com (2a01:111:e400:2c84::43) with Microsoft SMTP Server (TLS) id 15.1.337.19 via Frontend Transport; Fri, 4 Dec 2015 03:25:50 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.221) smtp.mailfrom=amd.com; 8bytes.org; dkim=none (message not signed) header.d=none; 8bytes.org; dmarc=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from atltwp01.amd.com (165.204.84.221) by CO1NAM03FT009.mail.protection.outlook.com (10.152.80.67) with Microsoft SMTP Server id 15.1.346.13 via Frontend Transport; Fri, 4 Dec 2015 03:25:48 +0000 X-WSS-ID: 0NYTDIY-07-25W-02 X-M-MSG: Received: from satlvexedge01.amd.com (satlvexedge01.amd.com [10.177.96.28]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by atltwp01.amd.com (Axway MailGate 5.3.1) with ESMTPS id 29F4FCAF028; Thu, 3 Dec 2015 22:25:46 -0500 (EST) Received: from SATLEXDAG06.amd.com (10.181.40.13) by satlvexedge01.amd.com (10.177.96.28) with Microsoft SMTP Server (TLS) id 14.3.195.1; Thu, 3 Dec 2015 21:26:06 -0600 Received: from SCYBEXDAG03.amd.com (10.34.11.13) by satlexdag06.amd.com (10.181.40.13) with Microsoft SMTP Server (TLS) id 14.3.266.1; Thu, 3 Dec 2015 22:25:45 -0500 Received: from annwang-Gardenia.amd.com (10.237.75.242) by SCYBEXDAG03.amd.com (10.34.11.13) with Microsoft SMTP Server id 14.3.266.1; Fri, 4 Dec 2015 11:25:41 +0800 From: Wang Hongcheng To: Vinod Koul , Mika Westerberg , Joerg Roedel , "Greg Kroah-Hartman" , "Rafael J. Wysocki" CC: , , , , , Borislav Petkov , Huang Rui , Wan Zongshun , Ken Xue , Tony Li , Wang Hongcheng Subject: [PATCH 3/9] ACPI: add struct acpi_amba_quirk for AMD pl330 specific device config Date: Fri, 4 Dec 2015 11:24:20 +0800 Message-ID: <1449199466-6081-4-git-send-email-annie.wang@amd.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1449199466-6081-1-git-send-email-annie.wang@amd.com> References: <1449199466-6081-1-git-send-email-annie.wang@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:165.204.84.221; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(428002)(199003)(189002)(77096005)(106466001)(19580395003)(5003600100002)(50466002)(11100500001)(101416001)(229853001)(48376002)(33646002)(105586002)(36756003)(19580405001)(53416004)(5890100001)(586003)(50226001)(86362001)(47776003)(5003940100001)(1096002)(50986999)(97736004)(5001770100001)(76176999)(1220700001)(5008740100001)(92566002)(87936001)(2950100001)(189998001)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR12MB0714; H:atltwp01.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0714; 2:QR3qm1oJDOtdzfPx0P0xnT5J+e/ASwayUmc+1zUkSn1qyILEfYrk2674JO5yv2I3vrSbYmReUNOqauJAlMTqf86rOiM4RozfABWn5AL3IES3QQBp1usrMIjBR6xBRop/4uj/Ds5QesLbiCc/ltUz4w==; 3:cOV59JY9AzEHL7GtUhXl8XL8fgcye3t9P79V9LbSudnfufZjqIA4PDKHS64dkycrDk166+uK4ftTVDpAKaRcq5DAo2jjaUCaO8eALfBsKeY8RIBBu9Ro3/qby/ngkSvMW2V6IuhQ9eNg8X8LIzJQT3lKdLuhPFK0oSpGqrhIgQlQWbRTtpCyJadXfb6Xu9JmBDnlVYJt1c3z/5k2pQQDAUpqPZCVodtMsRne3MGYBag=; 25:rpwvWFROpEpKXpWUotxFH3l/tXyiEZFsg4O/7FZW3FKXH8pdooxFzJuKjVJpY4HN1/o2BYNZP2JF831tIo9+LOU7v7GRUkrwQxeVfIMepcjlpezLY/j0O8xAxWC8yPkE5LRZEMT91g3yyzuTYOek7rqMG2x/sm1OC9IWXNh24kl//W08t3Z2c813ak+QuANl/bOxBTHmIHudmfpIhTikQ9wpImlqxAZu4ipVJHted3B+nfdvtFVlmWHd0HuRHQtJroOK0haFlv5R0kA9MAs7pQ== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR12MB0714; X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0714; 20:2zN1yix/8zZdo3oBYhCRfiBHolEjlXuEuxkKg3SYkXOqN3oq+y3bwUD3VRRNdJafthqzss2H8MXTyHzdA/Oo6u79IbYN9CuCNu4FyiDCDHl1MEbSO3UoF459nSmVSqFjDh1OHvKkIOVGmUKc04m2W+PZintDLs+OO9VdS79obU3NIavxmjcgcd7QufVDW4GBlDLpNRCQ3loaDYV5NayFaUkJSkCCvhQtGtI3lxGuaos37SNjZIFv6Gs+0Fns6AdAMBguzpEx0sOKQVOQlpFrbSx56TGmgggZzQ7Dr/YQwtKaxVEZT8BL695L/tqb+UN6uDoBjUfD2k++8kW/jsC+vpLwQFNgu22ilvrn65LN9hZ1NYM5Ss2IbPwRMNKPJl7dv5v6Q1K81PhOnqjFTwGfneXqlAwoEgrzUqwbWXdGUVBDJgcK3ZCv9VgVJ9F2uJyD6I8pHJkFNUtZcnPlvRzQeShvHHNmrlH2i1S5F9DemDJXeTiSxeLZfBhd6rdzpb4J X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(130843839470238); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(520078)(8121501046)(5005006)(10201501046)(3002001); SRVR:CY1PR12MB0714; BCL:0; PCL:0; RULEID:; SRVR:CY1PR12MB0714; X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0714; 4:yXCvJKCGApAmLHiWofE0Szs/3jyUpGlTN77z6ecBFUKWU+r31S66zi6tUfui07nGYD8qOQTrjpik+nkwKqIB8kzTaBPoOL8MI5i3Va6yF77npPHPeI3MZg9uDnEPsBlOXP3OKJJw9m3yDZTS8eWRvEFSrr/J5qDV69PuTuihdOkavSX0aN+bOGn+JYPUAmw2LvnbGhQvA4fQ200qZfaunaluZb0uSUMN20TgnOrEOWk05Z1DUXylASiz+gIFbA3DbA1Ej6sHLDGrB1P3ag3NlzVRJBdslCJ0EMMOQ8DrZo59TzC2CFNhB0HzUbehfNAl+OjQaaPaP+J6iLeOMy+Txd5extEKeNj4FV9kca1eqYDKAan+N306fQnf3rvYLBLYWLwEryhmw2kafXeBU/EHyRwiHoOsOFqz8Qt4mlQprUMESW7K9vaQhsMpR/wv3WIXMhu4EF3oSfqQEglQLSq2kA== X-Forefront-PRVS: 07807C55DC X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR12MB0714; 23:gw2R1h+NLgCR6sWh4zQb365e3sHladBvqLv+fAyRh?= =?us-ascii?Q?4D5eaielrHiBwTF3Bi45mhSCm5s3oevfaUnYYbt/8u67qrK4/wePg/7ymFWy?= =?us-ascii?Q?5PPl1CVqLr9dIZvMLHWuRUG4Ou2lOXIY/N3tcLUtgQYZO1hVKTZyjMkg3/NR?= =?us-ascii?Q?Lf5q31X99hJcLfYzYsznyJV7IvrDszzpbOZKI2p7DhSN5nEX7MbgwhNHMmCC?= =?us-ascii?Q?Z7rUlU8OY+svYwc9og8jxOy+faOvJLLBIunc8pqY5gW+Js+LYVPquV548lzz?= =?us-ascii?Q?Wn7AjVmYL9BTyRMOvtCls4Uli2vWkMtlBF4U0AmrfWqbaki/zi7UmOLexolF?= =?us-ascii?Q?tQMKHJzuuA6mJAN2ONt3sqKL1XgH+XqcYmed1x1i1s8WedolZkn5K6IusUGi?= =?us-ascii?Q?1OcKr6ZOPlRpgKmFzFtFPsJ/0G/CuesLTHQ39B8lqAD1GuNkgGIvpa3WGGb4?= =?us-ascii?Q?ilaM+G3+o6a9LDzmEJg8A/h4hX9GeHQX0rBlmyZn56aY7gvkFCWqSe94fqUF?= =?us-ascii?Q?mYLqptupHtPgH+r3MpezQYV0TP10JrKQY9BpCcJjlnpx9TJNOj6vzYNky0kL?= =?us-ascii?Q?WArnWzXvx7ihA+b6908vCsIb3mSttdMrK31S3KcKxKOYr4MSmvbThLx+aFqa?= =?us-ascii?Q?lnAC8WSozLU5GLgW8JTzu/wE5QmNUY0o4xHY9OtAj3OYE5BOAcqTPAIJW20I?= =?us-ascii?Q?nwva66ndxtiDM6qI0MBM6KsYGnZpqH2cTpTNYVOxvCiXKsd5xc3+wmJMD8x1?= =?us-ascii?Q?vQMiAzXLLctk2Obqjlng70CtET9KTfkiFHAPM5u/JQdXH7Qm7FMrfp+nJZnI?= =?us-ascii?Q?2p4TI3npXznTedqBTKGY8bAw8MAzZAmmhuOnHWlCi946bZaJaVPizlUUtZQm?= =?us-ascii?Q?lPi5FpmfO7+ToKXv3UNB/AGFOwnz70mIZmGesJU3IyL/DC8aVCOO1UgWuV9J?= =?us-ascii?Q?Sa58+vCyrQPeMuKLdTzc2Ka6E0Fqte0HVHZYt2ouj7WNjeN2keb4UcRagKpp?= =?us-ascii?Q?Tj9qXppfLsmMiX229gGbKsI?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0714; 5:yiMEus+IKB48SNEBz4vSR4ZoVfhS98v2wAKXWZ30KwAh2Y85r6yrRU9TrSGGYU7FZUfnWxLuYlfzGuHFbKZbr/3aFwjUrGD15YqCS/bF0+NwNq31p6dnQkmWLRiGbR/L2VFnW5Dt2LeqlG0/egAz6A==; 24:fDDSZovJVsz75pBYgsNH8ixeQQZGDz3LH8xI5la+F1xQVsUdWNo/nk2Cxpb3/cdReBYR4Zm3+RiXR63VgBN28apLZg2i92tYnsYudqjjgo4=; 20:vH13P0fiLzlBHki/FCeJ4ibJVZ8uXJ5xceY1dXbquoQg7/+hXHzMKvXVSeUAjczY8gg06Qf1kbDRLIQZ1nS5ekjDs7/3/fNfXb6ZnguBYOYWw7C9cx/fKXG8ijdzRMuTQ7xm36H8y7tVHDXhmGHtTlaOn+e2Oh+oKgnmAd6PhHsTQcFdLku5DGMMYLWAhDqwECjWORoCPAEBXwoLbnewigearg5c4TKyP3XedanHkzagr2sxCXh2UdIX6bdIrOlU SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2015 03:25:48.8478 (UTC) X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.221]; Helo=[atltwp01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR12MB0714 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP AMD pl330 is a UART DMA device, it shares one ACPI item with UART. So a platform device and an acpi device will be created according to AMD0020 ACPI dev. And its mem base address must have an offset. As a result, MULTI_ATTACHED_QUIRK and MULTI_ATTACHED_QUIRK are used. Signed-off-by: Wang Hongcheng --- drivers/acpi/acpi_amba.c | 31 +++++++++++++++++++++++---- drivers/acpi/acpi_apd.c | 56 +++++++++++++++++++++++++++++++++++++----------- include/linux/acpi.h | 13 +++++++++-- 3 files changed, 81 insertions(+), 19 deletions(-) diff --git a/drivers/acpi/acpi_amba.c b/drivers/acpi/acpi_amba.c index 4f0366a..8a5269c 100644 --- a/drivers/acpi/acpi_amba.c +++ b/drivers/acpi/acpi_amba.c @@ -31,6 +31,8 @@ ACPI_MODULE_NAME("amba"); * @periphid: AMBA device periphid. * @fixed_rate: Clock frequency. * @pdata: Platform data specific to the device. + * @quirk: Specific device config, including device multiattach. + * and mem base offset. * * Check if the given @adev can be represented as an AMBA device and, if * that's the case, create and register an AMBA device, populate its @@ -42,7 +44,8 @@ ACPI_MODULE_NAME("amba"); struct amba_device *acpi_create_amba_device(struct acpi_device *adev, unsigned int periphid, unsigned long fixed_rate, - void *pdata) + void *pdata, + struct acpi_amba_quirk *quirk) { struct amba_device *amba_dev = NULL; struct device *parent; @@ -54,12 +57,14 @@ struct amba_device *acpi_create_amba_device(struct acpi_device *adev, unsigned int i; unsigned int irq[AMBA_NR_IRQS]; struct clk *clk = ERR_PTR(-ENODEV); + char amba_devname[100]; /* * If the ACPI node already has a physical device attached, - * skip it. + * skip it. Except some special devices such as AMD0020 which + * needs attach physical devices two times. */ - if (adev->physical_node_count) + if (adev->physical_node_count && !(quirk->quirk & MULTI_ATTACHED_QUIRK)) return NULL; INIT_LIST_HEAD(&resource_list); @@ -85,7 +90,24 @@ struct amba_device *acpi_create_amba_device(struct acpi_device *adev, memcpy(resource, rentry->res, sizeof(struct resource)); } - amba_dev = amba_device_alloc(dev_name(&adev->dev), + /* + * The memory address of AMD pl330 has an offset of ACPI + * mem resource. + */ + if (quirk->quirk & BASE_OFFSET_QUIRK) + resource->start += quirk->base_offset; + + /* + * If the ACPI device already has a node attached. It must be + * renamed. + */ + if (quirk->quirk & MULTI_ATTACHED_QUIRK) + sprintf(amba_devname, "%s%s", dev_name(&adev->dev), "DMA"); + else + memcpy(amba_devname, dev_name(&adev->dev), + strlen(dev_name(&adev->dev))); + + amba_dev = amba_device_alloc(amba_devname, resource->start, resource_size(resource)); @@ -136,6 +158,7 @@ struct amba_device *acpi_create_amba_device(struct acpi_device *adev, if (ret) goto amba_register_err; + amba_dev->dev.init_name = NULL; ret = amba_device_add(amba_dev, resource); if (ret) goto amba_register_err; diff --git a/drivers/acpi/acpi_apd.c b/drivers/acpi/acpi_apd.c index a450e7a..eb3316a 100644 --- a/drivers/acpi/acpi_apd.c +++ b/drivers/acpi/acpi_apd.c @@ -3,7 +3,8 @@ * * Copyright (c) 2014,2015 AMD Corporation. * Authors: Ken Xue - * Wu, Jeff + * Jeff Wu <15618388108@163.com> + * Wang Hongcheng * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -17,6 +18,10 @@ #include #include #include +#include +#include +#include +#include #include "internal.h" @@ -31,14 +36,15 @@ struct apd_private_data; #define ACPI_APD_PM BIT(1) /** - * struct apd_device_desc - a descriptor for apd device - * @flags: device flags like %ACPI_APD_SYSFS, %ACPI_APD_PM + * struct apd_device_desc - a descriptor for apd device. + * @flags: device flags like %ACPI_APD_SYSFS, %ACPI_APD_PM; * @fixed_clk_rate: fixed rate input clock source for acpi device; - * 0 means no fixed rate input clock source - * @setup: a hook routine to set device resource during create platform device + *0 means no fixed rate input clock source; + * @clk_con_id: name of input clock source; + * @setup: a hook routine to set device resource during create platform device. * - * Device description defined as acpi_device_id.driver_data - */ + * Device description defined as acpi_device_id.driver_data. +*/ struct apd_device_desc { unsigned int flags; unsigned int fixed_clk_rate; @@ -71,6 +77,15 @@ static int acpi_apd_setup(struct apd_private_data *pdata) return 0; } +static void setup_quirks(struct platform_device *pdev, + struct acpi_amba_quirk *quirk) +{ + if (!strncmp(pdev->name, "AMD0020", 7)) { + quirk->quirk |= MULTI_ATTACHED_QUIRK | BASE_OFFSET_QUIRK; + quirk->base_offset = SZ_4K; + } +} + static struct apd_device_desc cz_i2c_desc = { .setup = acpi_apd_setup, .fixed_clk_rate = 133000000, @@ -88,15 +103,17 @@ static struct apd_device_desc cz_uart_desc = { #endif /* CONFIG_X86_AMD_PLATFORM_DEVICE */ /** -* Create platform device during acpi scan attach handle. -* Return value > 0 on success of creating device. -*/ + * Create platform device during acpi scan attach handle. + * Return value > 0 on success of creating device. + */ static int acpi_apd_create_device(struct acpi_device *adev, - const struct acpi_device_id *id) + const struct acpi_device_id *id) { const struct apd_device_desc *dev_desc = (void *)id->driver_data; struct apd_private_data *pdata; struct platform_device *pdev; + struct amba_device *amba_dev; + struct acpi_amba_quirk amba_quirks; int ret; if (!dev_desc) { @@ -118,9 +135,22 @@ static int acpi_apd_create_device(struct acpi_device *adev, } adev->driver_data = pdata; + pdev = acpi_create_platform_device(adev); - if (!IS_ERR_OR_NULL(pdev)) - return 1; + if (IS_ERR_OR_NULL(pdev)) + goto err_out; + + if (!strncmp(pdev->name, "AMD0020", 7)) { + memset(&amba_quirks, 0, sizeof(amba_quirks)); + setup_quirks(pdev, &amba_quirks); + + amba_dev = acpi_create_amba_device(pdata->adev, 0x00041330, + 48000000, + NULL, + &amba_quirks); + if (IS_ERR_OR_NULL(amba_dev)) + goto err_out; + } ret = PTR_ERR(pdev); adev->driver_data = NULL; diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 04827d8..50961a5 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -468,19 +468,28 @@ void acpi_walk_dep_device_list(acpi_handle handle); struct platform_device *acpi_create_platform_device(struct acpi_device *); +struct acpi_amba_quirk { + u32 quirk; +#define MULTI_ATTACHED_QUIRK BIT(0) +#define BASE_OFFSET_QUIRK BIT(1) + u32 base_offset; +}; + #ifdef CONFIG_ARM_AMBA struct amba_device *acpi_create_amba_device(struct acpi_device *adev, unsigned int periphid, unsigned long fixed_rate, - void *pdata); + void *pdata, + struct acpi_amba_quirk *quirk); #else /* !CONFIG_ARM_AMBA */ static inline struct amba_device *acpi_create_amba_device(struct acpi_device *adev, unsigned int periphid, unsigned long fixed_rate, - void *pdata) + void *pdata, + struct acpi_amba_quirk *quirk) { return NULL; }