Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751593AbbGaJ62 (ORCPT ); Fri, 31 Jul 2015 05:58:28 -0400 Received: from mail-by2on0136.outbound.protection.outlook.com ([207.46.100.136]:62178 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750879AbbGaJ6Z (ORCPT ); Fri, 31 Jul 2015 05:58:25 -0400 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; feescale.com; dkim=none (message not signed) header.d=none; From: To: CC: , Tang Yuantian , Chenhui Zhao , Tang Yuantian Subject: [PATCH 1/3] Powerpc: mpc85xx: refactor the PM operations Date: Fri, 31 Jul 2015 17:20:42 +0800 Message-ID: <1438334444-31919-1-git-send-email-b29983@freescale.com> X-Mailer: git-send-email 2.1.0.27.g96db324 X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11OLC001;1:UHtYzZmbGwM7x88Wh+lu0KBeU3UeS1TxeQRtuUvQH9jPEKPSeLFJjy3sKQ+ZpenQOL8byZ6k/y1zYaDiHgjKavWBDK/A5WRJ+v5EaZNvElFsclbLbe3Ntt5iEPbawq7V/mn2g7bzreY6J53qrHE3EY1W3AWRrGXC5X02Lcmq+hmRoY13tNBfo46RrIaRaNukleW2O+ipGgogrO8c260kLIjaJA3PzJM0Y52erxta0T1aTddIIJS/bYlRkee3xrvicIsZ0EuOXhnh2+zB8TKh96OU/PtYyGbR47T1icrwFDWy7copDKY8UJSSIGEJQsK9snbug3zh9p/l9gQo3GMclA== X-Forefront-Antispam-Report: CIP:192.88.158.2;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(339900001)(189002)(199003)(50466002)(87936001)(50986999)(92566002)(85426001)(47776003)(62966003)(46102003)(77096005)(50226001)(77156002)(104016003)(229853001)(33646002)(48376002)(2351001)(19580405001)(19580395003)(6806004)(189998001)(2371004)(110136002)(86152002)(5001960100002)(106466001)(4001450100002)(105606002)(36756003);DIR:OUT;SFP:1102;SCL:1;SRVR:DM2PR03MB301;H:az84smr01.freescale.net;FPR:;SPF:Fail;MLV:sfv;MX:1;A:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;DM2PR03MB301;2:e1CbN2h/LM6tTdwyrgLoWReHpAp75zviRMBmR0HIYa4SfSv5hzZDlcIMFN65Iw1lxGA57imXCzk3pyl6Y9YmgyCM4srjb2l4IPO+C2cDk39QQQI8PXkRJn//9XkDFH0uJVsAO02qSUcIqmmkyg3eUHViGIl+UlQUKgtv31rTpu8=;3:PdkttjaNT5rt0EGMeQMuu9HYMfeiKpVcLv+AaWTtPZcJNHx84VxE4vJ0NyMbZnmCF2RZ+Fh4TaV97GPbHW8pK/pXB5R2ZImcC5GvHxzP4XQLOvlc0I6b5kz7Rb0wXmvp8oLz6TjnWfLXa9TvxZnkgGsiQIHN/D6HQCYKAVNbebSjFzT6lA/9xuezuvdwICPnPlbL/esZuVn9aNOvdYCHRz1ykE00tc5TO1eix6sZQ+A=;25:jP1mHg5sxUo6P8g9ujFIF5o7G0OjPkh//4ns+7HvTuj94GjDuKHbz5TDqgEd4SOVeSZ2YmF1672Qo3Jwm2eI/Ca1ldbKBjmjjWogEd3SXXhlWLVJeeqRn0FignPLcua/O0jC5gBy720AxtaO2KxyidQgOzEWErilQobHsARc83JoE3ATkX9yK24kPZa3fKem28zAJaLGRicw+CSiHY1nRjaR49T8RNgUhwOts+nKLZIB+QcmQ89tKP/8K+rdjCxVl8wxWf4v+dVR+uqLclgbqw== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM2PR03MB301; X-Microsoft-Exchange-Diagnostics: 1;DM2PR03MB301;20:CdDMMst1tW7W+S3MU+y5nqvV7ZPQqclcx0TcnuqEI7l4WX8wXQ5QNJOQzIQKOlrEdETjORjpMvQY8RpU0PWWRBkl5Qh9nLQRlbS0G8b1IMIR7Z49FF3ObmnawRACgAyNnQ6FzD4OWoMuSvVSTMNW7VQPH5+P2/tHtwAh+PeYjyyVveWplSl6ZLpesZhE42P+krO56p2zWUQ4VrmBmPlnFZzfjm/wAg3l8TTvXHjwVrTdC5HHXSmX/S18kWnGGqvboHfPacTeD6kiu3s8tYI59r6dtyg+DzmEDKAQ56Bm0O5Q5+6GECzGRZrE3KGWnKcvb1Nop0BVLKuTrZNhiE765wQxzKaBsC4XbTZK4PPC2w8=;4:xYZuzXN63hWj7J7rSrdXn9rQ6YoDYXgcGnD0NOrB3Wwl1lMbv+pOHnY5OmqtbafXbCuMS8OfNl8wr/WLInJZWWZYRXi7UNzyIAk5O5VwMougpCFE0fRaeEy4FIm3gsM8q67/uWqzxgWWTamBqPuhJvtldQ9jkNNJDAv9OBjPZ9CtbC7s9Rm0zNhOQpBgCLbSnD+JXdc0VflCFVR+H4nCpTZhFx8Cg+kBky6jjs77wfV0zLkifzxzkMSiLKd27e9XJz/7eKduOfvxkAhcRoZ1Td7iqbyGbK/K9EmXf2+hM0Q= DM2PR03MB301: X-MS-Exchange-Organization-RulesExecuted X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:DM2PR03MB301;BCL:0;PCL:0;RULEID:;SRVR:DM2PR03MB301; X-Forefront-PRVS: 0654257CF5 X-Microsoft-Exchange-Diagnostics: 1;DM2PR03MB301;23:8QfzarRimcA5vakzds4KFHLoOkSCtwd4dInr3Ybnk/RzSXgDZ4VZc7idMu7SgMnPxE3iiAracd0IynEt1py9//BX4CCbOEQ03tpjQ2RyaN8lYSIS1Li74OlQwC12oCN1PM3AiF4RF1v41Tjr0YE5nh1Ox3pN4ikTqRulXGMc4Q2WC3CiWUf6G65KyzqcpZR9rujm0AL022FgR6vJuhwHm9cJb4KS1/fSZqUgMNWbVQruv4hqiS0ZjGHut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rivalTime: 31 Jul 2015 09:25:49.4926 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d;Ip=[192.88.158.2];Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR03MB301 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 9376 Lines: 356 From: Tang Yuantian Freescale CoreNet-based and Non-CoreNet-based platforms require different PM operations. This patch extracted existing PM operations on Non-CoreNet-based platforms to a new file which can accommodate both platforms. In this way, PM operation codes are clearer structurally. Signed-off-by: Chenhui Zhao Signed-off-by: Tang Yuantian --- arch/powerpc/platforms/85xx/Makefile | 1 + arch/powerpc/platforms/85xx/common.c | 3 + arch/powerpc/platforms/85xx/mpc85xx_pm_ops.c | 95 ++++++++++++++++++++++++++++ arch/powerpc/platforms/85xx/smp.c | 86 +++++++++---------------- arch/powerpc/sysdev/fsl_rcpm.c | 2 - 5 files changed, 128 insertions(+), 59 deletions(-) create mode 100644 arch/powerpc/platforms/85xx/mpc85xx_pm_ops.c diff --git a/arch/powerpc/platforms/85xx/Makefile b/arch/powerpc/platforms/85xx/Makefile index 1fe7fb9..7bc86da 100644 --- a/arch/powerpc/platforms/85xx/Makefile +++ b/arch/powerpc/platforms/85xx/Makefile @@ -2,6 +2,7 @@ # Makefile for the PowerPC 85xx linux kernel. # obj-$(CONFIG_SMP) += smp.o +obj-$(CONFIG_FSL_PMC) += mpc85xx_pm_ops.o obj-y += common.o diff --git a/arch/powerpc/platforms/85xx/common.c b/arch/powerpc/platforms/85xx/common.c index 7bfb9b1..91475f5 100644 --- a/arch/powerpc/platforms/85xx/common.c +++ b/arch/powerpc/platforms/85xx/common.c @@ -10,10 +10,13 @@ #include #include +#include #include #include "mpc85xx.h" +const struct fsl_pm_ops *qoriq_pm_ops; + static const struct of_device_id mpc85xx_common_ids[] __initconst = { { .type = "soc", }, { .compatible = "soc", }, diff --git a/arch/powerpc/platforms/85xx/mpc85xx_pm_ops.c b/arch/powerpc/platforms/85xx/mpc85xx_pm_ops.c new file mode 100644 index 0000000..e59714e --- /dev/null +++ b/arch/powerpc/platforms/85xx/mpc85xx_pm_ops.c @@ -0,0 +1,95 @@ +/* + * MPC85xx PM operators + * + * Copyright 2015 Freescale Semiconductor Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#include +#include +#include + +#include +#include +#include + +static struct ccsr_guts __iomem *guts; + +static const struct of_device_id mpc85xx_smp_guts_ids[] = { + { .compatible = "fsl,mpc8572-guts", }, + { .compatible = "fsl,p1020-guts", }, + { .compatible = "fsl,p1021-guts", }, + { .compatible = "fsl,p1022-guts", }, + { .compatible = "fsl,p1023-guts", }, + { .compatible = "fsl,p2020-guts", }, + { .compatible = "fsl,bsc9132-guts", }, + {}, +}; + +static void mpc85xx_irq_mask(int cpu) +{ + +} + +static void mpc85xx_irq_unmask(int cpu) +{ + +} + +static void mpc85xx_cpu_die(int cpu) +{ + +} + +static void mpc85xx_cpu_up(int cpu) +{ + +} + +static void mpc85xx_freeze_time_base(bool freeze) +{ + uint32_t mask; + + mask = CCSR_GUTS_DEVDISR_TB0 | CCSR_GUTS_DEVDISR_TB1; + if (freeze) + setbits32(&guts->devdisr, mask); + else + clrbits32(&guts->devdisr, mask); + + in_be32(&guts->devdisr); +} + +static const struct fsl_pm_ops mpc85xx_pm_ops = { + .freeze_time_base = mpc85xx_freeze_time_base, + .irq_mask = mpc85xx_irq_mask, + .irq_unmask = mpc85xx_irq_unmask, + .cpu_die = mpc85xx_cpu_die, + .cpu_up = mpc85xx_cpu_up, +}; + +static int __init mpc85xx_setup_pmc(void) +{ + struct device_node *np; + + np = of_find_matching_node(NULL, mpc85xx_smp_guts_ids); + if (np) { + guts = of_iomap(np, 0); + of_node_put(np); + if (!guts) { + pr_err("%s: Could not map guts node address\n", + __func__); + return -ENOMEM; + } + } + + qoriq_pm_ops = &mpc85xx_pm_ops; + + return 0; +} + +/* need to call this before SMP init */ +early_initcall(mpc85xx_setup_pmc) diff --git a/arch/powerpc/platforms/85xx/smp.c b/arch/powerpc/platforms/85xx/smp.c index 1180f78..6811a5b 100644 --- a/arch/powerpc/platforms/85xx/smp.c +++ b/arch/powerpc/platforms/85xx/smp.c @@ -2,7 +2,7 @@ * Author: Andy Fleming * Kumar Gala * - * Copyright 2006-2008, 2011-2012 Freescale Semiconductor Inc. + * Copyright 2006-2008, 2011-2012, 2015 Freescale Semiconductor Inc. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -26,9 +25,9 @@ #include #include #include -#include #include #include +#include #include #include @@ -43,24 +42,10 @@ struct epapr_spin_table { u32 pir; }; -static struct ccsr_guts __iomem *guts; static u64 timebase; static int tb_req; static int tb_valid; -static void mpc85xx_timebase_freeze(int freeze) -{ - uint32_t mask; - - mask = CCSR_GUTS_DEVDISR_TB0 | CCSR_GUTS_DEVDISR_TB1; - if (freeze) - setbits32(&guts->devdisr, mask); - else - clrbits32(&guts->devdisr, mask); - - in_be32(&guts->devdisr); -} - static void mpc85xx_give_timebase(void) { unsigned long flags; @@ -71,7 +56,7 @@ static void mpc85xx_give_timebase(void) barrier(); tb_req = 0; - mpc85xx_timebase_freeze(1); + qoriq_pm_ops->freeze_time_base(1); #ifdef CONFIG_PPC64 /* * e5500/e6500 have a workaround for erratum A-006958 in place @@ -104,7 +89,7 @@ static void mpc85xx_give_timebase(void) while (tb_valid) barrier(); - mpc85xx_timebase_freeze(0); + qoriq_pm_ops->freeze_time_base(0); local_irq_restore(flags); } @@ -127,20 +112,10 @@ static void mpc85xx_take_timebase(void) } #ifdef CONFIG_HOTPLUG_CPU -static void smp_85xx_mach_cpu_die(void) +static void e500_cpu_idle(void) { - unsigned int cpu = smp_processor_id(); u32 tmp; - local_irq_disable(); - idle_task_exit(); - generic_set_cpu_dead(cpu); - mb(); - - mtspr(SPRN_TCR, 0); - - cur_cpu_spec->cpu_down_flush(); - tmp = (mfspr(SPRN_HID0) & ~(HID0_DOZE|HID0_SLEEP)) | HID0_NAP; mtspr(SPRN_HID0, tmp); isync(); @@ -151,6 +126,25 @@ static void smp_85xx_mach_cpu_die(void) mb(); mtmsr(tmp); isync(); +} + +static void qoriq_cpu_dying(void) +{ + unsigned int cpu = smp_processor_id(); + + hard_irq_disable(); + /* mask all irqs to prevent cpu wakeup */ + qoriq_pm_ops->irq_mask(cpu); + idle_task_exit(); + + mtspr(SPRN_TCR, 0); + mtspr(SPRN_TSR, mfspr(SPRN_TSR)); + + cur_cpu_spec->cpu_down_flush(); + + generic_set_cpu_dead(cpu); + + e500_cpu_idle(); while (1) ; @@ -332,9 +326,9 @@ struct smp_ops_t smp_85xx_ops = { .cpu_disable = generic_cpu_disable, .cpu_die = generic_cpu_die, #endif -#ifdef CONFIG_KEXEC - .give_timebase = smp_generic_give_timebase, - .take_timebase = smp_generic_take_timebase, +#if defined(CONFIG_KEXEC) || defined(CONFIG_HOTPLUG_CPU) + .give_timebase = mpc85xx_give_timebase, + .take_timebase = mpc85xx_take_timebase, #endif }; @@ -346,7 +340,7 @@ void mpc85xx_smp_kexec_cpu_down(int crash_shutdown, int secondary) local_irq_disable(); if (secondary) { - __flush_disable_L1(); + cur_cpu_spec->cpu_down_flush(); atomic_inc(&kexec_down_cpus); /* loop forever */ while (1); @@ -398,16 +392,6 @@ static void smp_85xx_setup_cpu(int cpu_nr) smp_85xx_basic_setup(cpu_nr); } -static const struct of_device_id mpc85xx_smp_guts_ids[] = { - { .compatible = "fsl,mpc8572-guts", }, - { .compatible = "fsl,p1020-guts", }, - { .compatible = "fsl,p1021-guts", }, - { .compatible = "fsl,p1022-guts", }, - { .compatible = "fsl,p1023-guts", }, - { .compatible = "fsl,p2020-guts", }, - {}, -}; - void __init mpc85xx_smp_init(void) { struct device_node *np; @@ -431,21 +415,9 @@ void __init mpc85xx_smp_init(void) smp_85xx_ops.probe = NULL; } - np = of_find_matching_node(NULL, mpc85xx_smp_guts_ids); - if (np) { - guts = of_iomap(np, 0); - of_node_put(np); - if (!guts) { - pr_err("%s: Could not map guts node address\n", - __func__); - return; - } - smp_85xx_ops.give_timebase = mpc85xx_give_timebase; - smp_85xx_ops.take_timebase = mpc85xx_take_timebase; #ifdef CONFIG_HOTPLUG_CPU - ppc_md.cpu_die = smp_85xx_mach_cpu_die; + ppc_md.cpu_die = qoriq_cpu_dying; #endif - } smp_ops = &smp_85xx_ops; diff --git a/arch/powerpc/sysdev/fsl_rcpm.c b/arch/powerpc/sysdev/fsl_rcpm.c index acf3f94..e6ae678 100644 --- a/arch/powerpc/sysdev/fsl_rcpm.c +++ b/arch/powerpc/sysdev/fsl_rcpm.c @@ -20,8 +20,6 @@ #include #include -const struct fsl_pm_ops *qoriq_pm_ops; - static struct ccsr_rcpm_v1 __iomem *rcpm_v1_regs; static struct ccsr_rcpm_v2 __iomem *rcpm_v2_regs; static unsigned int fsl_supported_pm_modes; -- 2.1.0.27.g96db324 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/