From patchwork Mon Aug 13 12:33:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafael Wysocki X-Patchwork-Id: 1312441 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id B9BC1DF223 for ; Mon, 13 Aug 2012 12:28:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752153Ab2HMM2n (ORCPT ); Mon, 13 Aug 2012 08:28:43 -0400 Received: from ogre.sisk.pl ([193.178.161.156]:35560 "EHLO ogre.sisk.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751630Ab2HMM2m (ORCPT ); Mon, 13 Aug 2012 08:28:42 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by ogre.sisk.pl (Postfix) with ESMTP id ACD361DBD93; Mon, 13 Aug 2012 14:33:00 +0200 (CEST) Received: from ogre.sisk.pl ([127.0.0.1]) by localhost (ogre.sisk.pl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 21270-03; Mon, 13 Aug 2012 14:32:45 +0200 (CEST) Received: from ferrari.rjw.lan (89-67-90-11.dynamic.chello.pl [89.67.90.11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ogre.sisk.pl (Postfix) with ESMTP id 7651C1DBE49; Mon, 13 Aug 2012 14:32:45 +0200 (CEST) From: "Rafael J. Wysocki" To: "Linux-sh list" Subject: [PATCH 1/2] ARM: shmobile: Rework adding devices to PM domains on Mackerel Date: Mon, 13 Aug 2012 14:33:44 +0200 User-Agent: KMail/1.13.6 (Linux/3.5.0+; KDE/4.6.0; x86_64; ; ) Cc: Linux PM list , Magnus Damm References: <201208131432.43768.rjw@sisk.pl> In-Reply-To: <201208131432.43768.rjw@sisk.pl> MIME-Version: 1.0 Message-Id: <201208131433.45102.rjw@sisk.pl> X-Virus-Scanned: amavisd-new at ogre.sisk.pl using MkS_Vir for Linux Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org On SH7372 and Mackerel devices are added to PM domains through a series of rmobile_add_device_to_domain_td() calls where the last argument is always the same. This is quite inefficient, so add a common function for adding devices to PM domains that reads the domain-device pairs information from a table and use it during SH7372 and Mackerel initialization. Signed-off-by: Rafael J. Wysocki --- arch/arm/mach-shmobile/board-mackerel.c | 37 ++++++-------- arch/arm/mach-shmobile/include/mach/pm-rmobile.h | 12 ++++ arch/arm/mach-shmobile/pm-rmobile.c | 16 ++++++ arch/arm/mach-shmobile/setup-sh7372.c | 58 ++++++++++------------- 4 files changed, 72 insertions(+), 51 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux/arch/arm/mach-shmobile/include/mach/pm-rmobile.h =================================================================== --- linux.orig/arch/arm/mach-shmobile/include/mach/pm-rmobile.h +++ linux/arch/arm/mach-shmobile/include/mach/pm-rmobile.h @@ -12,6 +12,8 @@ #include +#define DEFAULT_DEV_LATENCY_NS 250000 + struct platform_device; struct rmobile_pm_domain { @@ -29,6 +31,11 @@ struct rmobile_pm_domain *to_rmobile_pd( return container_of(d, struct rmobile_pm_domain, genpd); } +struct pm_domain_device { + const char *domain_name; + struct platform_device *pdev; +}; + #ifdef CONFIG_PM extern void rmobile_init_domains(struct rmobile_pm_domain domains[], int num); extern void rmobile_add_device_to_domain_td(const char *domain_name, @@ -41,11 +48,16 @@ static inline void rmobile_add_device_to rmobile_add_device_to_domain_td(domain_name, pdev, NULL); } +extern void rmobile_add_devices_to_domains(struct pm_domain_device data[], + int size); #else #define rmobile_init_domains(domains, num) do { } while (0) #define rmobile_add_device_to_domain_td(name, pdev, td) do { } while (0) #define rmobile_add_device_to_domain(name, pdev) do { } while (0) + +static inline void rmobile_add_devices_to_domains(struct pm_domain_device d[], + int size) {} #endif /* CONFIG_PM */ #endif /* PM_RMOBILE_H */ Index: linux/arch/arm/mach-shmobile/setup-sh7372.c =================================================================== --- linux.orig/arch/arm/mach-shmobile/setup-sh7372.c +++ linux/arch/arm/mach-shmobile/setup-sh7372.c @@ -999,15 +999,33 @@ static struct platform_device *sh7372_la &spu1_device, }; -#define DEV_LATENCY_NS 250000 - void __init sh7372_add_standard_devices(void) { - struct gpd_timing_data latencies = { - .stop_latency_ns = DEV_LATENCY_NS, - .start_latency_ns = DEV_LATENCY_NS, - .save_state_latency_ns = DEV_LATENCY_NS, - .restore_state_latency_ns = DEV_LATENCY_NS, + struct pm_domain_device domain_devices[] = { + { "A3RV", &vpu_device, }, + { "A4MP", &spu0_device, }, + { "A4MP", &spu1_device, }, + { "A3SP", &scif0_device, }, + { "A3SP", &scif1_device, }, + { "A3SP", &scif2_device, }, + { "A3SP", &scif3_device, }, + { "A3SP", &scif4_device, }, + { "A3SP", &scif5_device, }, + { "A3SP", &scif6_device, }, + { "A3SP", &iic1_device, }, + { "A3SP", &dma0_device, }, + { "A3SP", &dma1_device, }, + { "A3SP", &dma2_device, }, + { "A3SP", &usb_dma0_device, }, + { "A3SP", &usb_dma1_device, }, + { "A4R", &iic0_device, }, + { "A4R", &veu0_device, }, + { "A4R", &veu1_device, }, + { "A4R", &veu2_device, }, + { "A4R", &veu3_device, }, + { "A4R", &jpu_device, }, + { "A4R", &tmu00_device, }, + { "A4R", &tmu01_device, }, }; sh7372_init_pm_domains(); @@ -1018,30 +1036,8 @@ void __init sh7372_add_standard_devices( platform_add_devices(sh7372_late_devices, ARRAY_SIZE(sh7372_late_devices)); - rmobile_add_device_to_domain_td("A3RV", &vpu_device, &latencies); - rmobile_add_device_to_domain_td("A4MP", &spu0_device, &latencies); - rmobile_add_device_to_domain_td("A4MP", &spu1_device, &latencies); - rmobile_add_device_to_domain_td("A3SP", &scif0_device, &latencies); - rmobile_add_device_to_domain_td("A3SP", &scif1_device, &latencies); - rmobile_add_device_to_domain_td("A3SP", &scif2_device, &latencies); - rmobile_add_device_to_domain_td("A3SP", &scif3_device, &latencies); - rmobile_add_device_to_domain_td("A3SP", &scif4_device, &latencies); - rmobile_add_device_to_domain_td("A3SP", &scif5_device, &latencies); - rmobile_add_device_to_domain_td("A3SP", &scif6_device, &latencies); - rmobile_add_device_to_domain_td("A3SP", &iic1_device, &latencies); - rmobile_add_device_to_domain_td("A3SP", &dma0_device, &latencies); - rmobile_add_device_to_domain_td("A3SP", &dma1_device, &latencies); - rmobile_add_device_to_domain_td("A3SP", &dma2_device, &latencies); - rmobile_add_device_to_domain_td("A3SP", &usb_dma0_device, &latencies); - rmobile_add_device_to_domain_td("A3SP", &usb_dma1_device, &latencies); - rmobile_add_device_to_domain_td("A4R", &iic0_device, &latencies); - rmobile_add_device_to_domain_td("A4R", &veu0_device, &latencies); - rmobile_add_device_to_domain_td("A4R", &veu1_device, &latencies); - rmobile_add_device_to_domain_td("A4R", &veu2_device, &latencies); - rmobile_add_device_to_domain_td("A4R", &veu3_device, &latencies); - rmobile_add_device_to_domain_td("A4R", &jpu_device, &latencies); - rmobile_add_device_to_domain_td("A4R", &tmu00_device, &latencies); - rmobile_add_device_to_domain_td("A4R", &tmu01_device, &latencies); + rmobile_add_devices_to_domains(domain_devices, + ARRAY_SIZE(domain_devices)); } static void __init sh7372_earlytimer_init(void) Index: linux/arch/arm/mach-shmobile/pm-rmobile.c =================================================================== --- linux.orig/arch/arm/mach-shmobile/pm-rmobile.c +++ linux/arch/arm/mach-shmobile/pm-rmobile.c @@ -167,4 +167,20 @@ void rmobile_add_device_to_domain_td(con if (pm_clk_no_clocks(dev)) pm_clk_add(dev, NULL); } + +void rmobile_add_devices_to_domains(struct pm_domain_device data[], + int size) +{ + struct gpd_timing_data latencies = { + .stop_latency_ns = DEFAULT_DEV_LATENCY_NS, + .start_latency_ns = DEFAULT_DEV_LATENCY_NS, + .save_state_latency_ns = DEFAULT_DEV_LATENCY_NS, + .restore_state_latency_ns = DEFAULT_DEV_LATENCY_NS, + }; + int j; + + for (j = 0; j < size; j++) + rmobile_add_device_to_domain_td(data[j].domain_name, + data[j].pdev, &latencies); +} #endif /* CONFIG_PM */ Index: linux/arch/arm/mach-shmobile/board-mackerel.c =================================================================== --- linux.orig/arch/arm/mach-shmobile/board-mackerel.c +++ linux/arch/arm/mach-shmobile/board-mackerel.c @@ -1407,14 +1407,23 @@ static struct i2c_board_info i2c1_device #define GPIO_PORT168CR 0xE60520A8 #define SRCR4 0xe61580bc #define USCCR1 0xE6058144 -#define DEV_LATENCY_NS 250000 static void __init mackerel_init(void) { - struct gpd_timing_data latencies = { - .stop_latency_ns = DEV_LATENCY_NS, - .start_latency_ns = DEV_LATENCY_NS, - .save_state_latency_ns = DEV_LATENCY_NS, - .restore_state_latency_ns = DEV_LATENCY_NS, + struct pm_domain_device domain_devices[] = { + { "A4LC", &lcdc_device, }, + { "A4LC", &hdmi_lcdc_device, }, + { "A4LC", &meram_device, }, + { "A4MP", &fsi_device, }, + { "A3SP", &usbhs0_device, }, + { "A3SP", &usbhs1_device, }, + { "A3SP", &nand_flash_device, }, + { "A3SP", &sh_mmcif_device, }, + { "A3SP", &sdhi0_device, }, +#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE) + { "A3SP", &sdhi1_device, }, +#endif + { "A3SP", &sdhi2_device, }, + { "A4R", &ceu_device, }, }; u32 srcr4; struct clk *clk; @@ -1630,20 +1639,8 @@ static void __init mackerel_init(void) platform_add_devices(mackerel_devices, ARRAY_SIZE(mackerel_devices)); - rmobile_add_device_to_domain_td("A4LC", &lcdc_device, &latencies); - rmobile_add_device_to_domain_td("A4LC", &hdmi_lcdc_device, &latencies); - rmobile_add_device_to_domain_td("A4LC", &meram_device, &latencies); - rmobile_add_device_to_domain_td("A4MP", &fsi_device, &latencies); - rmobile_add_device_to_domain_td("A3SP", &usbhs0_device, &latencies); - rmobile_add_device_to_domain_td("A3SP", &usbhs1_device, &latencies); - rmobile_add_device_to_domain_td("A3SP", &nand_flash_device, &latencies); - rmobile_add_device_to_domain_td("A3SP", &sh_mmcif_device, &latencies); - rmobile_add_device_to_domain_td("A3SP", &sdhi0_device, &latencies); -#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE) - rmobile_add_device_to_domain_td("A3SP", &sdhi1_device, &latencies); -#endif - rmobile_add_device_to_domain_td("A3SP", &sdhi2_device, &latencies); - rmobile_add_device_to_domain_td("A4R", &ceu_device, &latencies); + rmobile_add_devices_to_domains(domain_devices, + ARRAY_SIZE(domain_devices)); hdmi_init_pm_clock(); sh7372_pm_init();