aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2012-08-15 14:56:26 -0400
committerRafael J. Wysocki <rjw@sisk.pl>2012-09-03 19:45:00 -0400
commitac18e02dc022a5413219f41d000bc637c7c5d957 (patch)
treeef974a4084f0536fe8aec27f382b3e81f49f61a0 /arch
parentb42879e2e9b130e9ea0df3f076a0742df46e143a (diff)
ARM: shmobile: Rework adding devices to PM domains on Mackerel
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 <rjw@sisk.pl> Acked-by: Magnus Damm <damm@opensource.se>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-shmobile/board-mackerel.c37
-rw-r--r--arch/arm/mach-shmobile/include/mach/pm-rmobile.h12
-rw-r--r--arch/arm/mach-shmobile/pm-rmobile.c16
-rw-r--r--arch/arm/mach-shmobile/setup-sh7372.c58
4 files changed, 72 insertions, 51 deletions
diff --git a/arch/arm/mach-shmobile/board-mackerel.c b/arch/arm/mach-shmobile/board-mackerel.c
index c64fc40351d..d1e8fe83588 100644
--- a/arch/arm/mach-shmobile/board-mackerel.c
+++ b/arch/arm/mach-shmobile/board-mackerel.c
@@ -1407,14 +1407,23 @@ static struct i2c_board_info i2c1_devices[] = {
1407#define GPIO_PORT168CR 0xE60520A8 1407#define GPIO_PORT168CR 0xE60520A8
1408#define SRCR4 0xe61580bc 1408#define SRCR4 0xe61580bc
1409#define USCCR1 0xE6058144 1409#define USCCR1 0xE6058144
1410#define DEV_LATENCY_NS 250000
1411static void __init mackerel_init(void) 1410static void __init mackerel_init(void)
1412{ 1411{
1413 struct gpd_timing_data latencies = { 1412 struct pm_domain_device domain_devices[] = {
1414 .stop_latency_ns = DEV_LATENCY_NS, 1413 { "A4LC", &lcdc_device, },
1415 .start_latency_ns = DEV_LATENCY_NS, 1414 { "A4LC", &hdmi_lcdc_device, },
1416 .save_state_latency_ns = DEV_LATENCY_NS, 1415 { "A4LC", &meram_device, },
1417 .restore_state_latency_ns = DEV_LATENCY_NS, 1416 { "A4MP", &fsi_device, },
1417 { "A3SP", &usbhs0_device, },
1418 { "A3SP", &usbhs1_device, },
1419 { "A3SP", &nand_flash_device, },
1420 { "A3SP", &sh_mmcif_device, },
1421 { "A3SP", &sdhi0_device, },
1422#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
1423 { "A3SP", &sdhi1_device, },
1424#endif
1425 { "A3SP", &sdhi2_device, },
1426 { "A4R", &ceu_device, },
1418 }; 1427 };
1419 u32 srcr4; 1428 u32 srcr4;
1420 struct clk *clk; 1429 struct clk *clk;
@@ -1630,20 +1639,8 @@ static void __init mackerel_init(void)
1630 1639
1631 platform_add_devices(mackerel_devices, ARRAY_SIZE(mackerel_devices)); 1640 platform_add_devices(mackerel_devices, ARRAY_SIZE(mackerel_devices));
1632 1641
1633 rmobile_add_device_to_domain_td("A4LC", &lcdc_device, &latencies); 1642 rmobile_add_devices_to_domains(domain_devices,
1634 rmobile_add_device_to_domain_td("A4LC", &hdmi_lcdc_device, &latencies); 1643 ARRAY_SIZE(domain_devices));
1635 rmobile_add_device_to_domain_td("A4LC", &meram_device, &latencies);
1636 rmobile_add_device_to_domain_td("A4MP", &fsi_device, &latencies);
1637 rmobile_add_device_to_domain_td("A3SP", &usbhs0_device, &latencies);
1638 rmobile_add_device_to_domain_td("A3SP", &usbhs1_device, &latencies);
1639 rmobile_add_device_to_domain_td("A3SP", &nand_flash_device, &latencies);
1640 rmobile_add_device_to_domain_td("A3SP", &sh_mmcif_device, &latencies);
1641 rmobile_add_device_to_domain_td("A3SP", &sdhi0_device, &latencies);
1642#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
1643 rmobile_add_device_to_domain_td("A3SP", &sdhi1_device, &latencies);
1644#endif
1645 rmobile_add_device_to_domain_td("A3SP", &sdhi2_device, &latencies);
1646 rmobile_add_device_to_domain_td("A4R", &ceu_device, &latencies);
1647 1644
1648 hdmi_init_pm_clock(); 1645 hdmi_init_pm_clock();
1649 sh7372_pm_init(); 1646 sh7372_pm_init();
diff --git a/arch/arm/mach-shmobile/include/mach/pm-rmobile.h b/arch/arm/mach-shmobile/include/mach/pm-rmobile.h
index 4d02f7488dd..690553a0688 100644
--- a/arch/arm/mach-shmobile/include/mach/pm-rmobile.h
+++ b/arch/arm/mach-shmobile/include/mach/pm-rmobile.h
@@ -12,6 +12,8 @@
12 12
13#include <linux/pm_domain.h> 13#include <linux/pm_domain.h>
14 14
15#define DEFAULT_DEV_LATENCY_NS 250000
16
15struct platform_device; 17struct platform_device;
16 18
17struct rmobile_pm_domain { 19struct rmobile_pm_domain {
@@ -29,6 +31,11 @@ struct rmobile_pm_domain *to_rmobile_pd(struct generic_pm_domain *d)
29 return container_of(d, struct rmobile_pm_domain, genpd); 31 return container_of(d, struct rmobile_pm_domain, genpd);
30} 32}
31 33
34struct pm_domain_device {
35 const char *domain_name;
36 struct platform_device *pdev;
37};
38
32#ifdef CONFIG_PM 39#ifdef CONFIG_PM
33extern void rmobile_init_domains(struct rmobile_pm_domain domains[], int num); 40extern void rmobile_init_domains(struct rmobile_pm_domain domains[], int num);
34extern void rmobile_add_device_to_domain_td(const char *domain_name, 41extern void rmobile_add_device_to_domain_td(const char *domain_name,
@@ -41,11 +48,16 @@ static inline void rmobile_add_device_to_domain(const char *domain_name,
41 rmobile_add_device_to_domain_td(domain_name, pdev, NULL); 48 rmobile_add_device_to_domain_td(domain_name, pdev, NULL);
42} 49}
43 50
51extern void rmobile_add_devices_to_domains(struct pm_domain_device data[],
52 int size);
44#else 53#else
45 54
46#define rmobile_init_domains(domains, num) do { } while (0) 55#define rmobile_init_domains(domains, num) do { } while (0)
47#define rmobile_add_device_to_domain_td(name, pdev, td) do { } while (0) 56#define rmobile_add_device_to_domain_td(name, pdev, td) do { } while (0)
48#define rmobile_add_device_to_domain(name, pdev) do { } while (0) 57#define rmobile_add_device_to_domain(name, pdev) do { } while (0)
58
59static inline void rmobile_add_devices_to_domains(struct pm_domain_device d[],
60 int size) {}
49#endif /* CONFIG_PM */ 61#endif /* CONFIG_PM */
50 62
51#endif /* PM_RMOBILE_H */ 63#endif /* PM_RMOBILE_H */
diff --git a/arch/arm/mach-shmobile/pm-rmobile.c b/arch/arm/mach-shmobile/pm-rmobile.c
index 682575a2243..d37d368434d 100644
--- a/arch/arm/mach-shmobile/pm-rmobile.c
+++ b/arch/arm/mach-shmobile/pm-rmobile.c
@@ -167,4 +167,20 @@ void rmobile_add_device_to_domain_td(const char *domain_name,
167 if (pm_clk_no_clocks(dev)) 167 if (pm_clk_no_clocks(dev))
168 pm_clk_add(dev, NULL); 168 pm_clk_add(dev, NULL);
169} 169}
170
171void rmobile_add_devices_to_domains(struct pm_domain_device data[],
172 int size)
173{
174 struct gpd_timing_data latencies = {
175 .stop_latency_ns = DEFAULT_DEV_LATENCY_NS,
176 .start_latency_ns = DEFAULT_DEV_LATENCY_NS,
177 .save_state_latency_ns = DEFAULT_DEV_LATENCY_NS,
178 .restore_state_latency_ns = DEFAULT_DEV_LATENCY_NS,
179 };
180 int j;
181
182 for (j = 0; j < size; j++)
183 rmobile_add_device_to_domain_td(data[j].domain_name,
184 data[j].pdev, &latencies);
185}
170#endif /* CONFIG_PM */ 186#endif /* CONFIG_PM */
diff --git a/arch/arm/mach-shmobile/setup-sh7372.c b/arch/arm/mach-shmobile/setup-sh7372.c
index 5bcde8a79c5..a07954fbcd2 100644
--- a/arch/arm/mach-shmobile/setup-sh7372.c
+++ b/arch/arm/mach-shmobile/setup-sh7372.c
@@ -999,15 +999,33 @@ static struct platform_device *sh7372_late_devices[] __initdata = {
999 &spu1_device, 999 &spu1_device,
1000}; 1000};
1001 1001
1002#define DEV_LATENCY_NS 250000
1003
1004void __init sh7372_add_standard_devices(void) 1002void __init sh7372_add_standard_devices(void)
1005{ 1003{
1006 struct gpd_timing_data latencies = { 1004 struct pm_domain_device domain_devices[] = {
1007 .stop_latency_ns = DEV_LATENCY_NS, 1005 { "A3RV", &vpu_device, },
1008 .start_latency_ns = DEV_LATENCY_NS, 1006 { "A4MP", &spu0_device, },
1009 .save_state_latency_ns = DEV_LATENCY_NS, 1007 { "A4MP", &spu1_device, },
1010 .restore_state_latency_ns = DEV_LATENCY_NS, 1008 { "A3SP", &scif0_device, },
1009 { "A3SP", &scif1_device, },
1010 { "A3SP", &scif2_device, },
1011 { "A3SP", &scif3_device, },
1012 { "A3SP", &scif4_device, },
1013 { "A3SP", &scif5_device, },
1014 { "A3SP", &scif6_device, },
1015 { "A3SP", &iic1_device, },
1016 { "A3SP", &dma0_device, },
1017 { "A3SP", &dma1_device, },
1018 { "A3SP", &dma2_device, },
1019 { "A3SP", &usb_dma0_device, },
1020 { "A3SP", &usb_dma1_device, },
1021 { "A4R", &iic0_device, },
1022 { "A4R", &veu0_device, },
1023 { "A4R", &veu1_device, },
1024 { "A4R", &veu2_device, },
1025 { "A4R", &veu3_device, },
1026 { "A4R", &jpu_device, },
1027 { "A4R", &tmu00_device, },
1028 { "A4R", &tmu01_device, },
1011 }; 1029 };
1012 1030
1013 sh7372_init_pm_domains(); 1031 sh7372_init_pm_domains();
@@ -1018,30 +1036,8 @@ void __init sh7372_add_standard_devices(void)
1018 platform_add_devices(sh7372_late_devices, 1036 platform_add_devices(sh7372_late_devices,
1019 ARRAY_SIZE(sh7372_late_devices)); 1037 ARRAY_SIZE(sh7372_late_devices));
1020 1038
1021 rmobile_add_device_to_domain_td("A3RV", &vpu_device, &latencies); 1039 rmobile_add_devices_to_domains(domain_devices,
1022 rmobile_add_device_to_domain_td("A4MP", &spu0_device, &latencies); 1040 ARRAY_SIZE(domain_devices));
1023 rmobile_add_device_to_domain_td("A4MP", &spu1_device, &latencies);
1024 rmobile_add_device_to_domain_td("A3SP", &scif0_device, &latencies);
1025 rmobile_add_device_to_domain_td("A3SP", &scif1_device, &latencies);
1026 rmobile_add_device_to_domain_td("A3SP", &scif2_device, &latencies);
1027 rmobile_add_device_to_domain_td("A3SP", &scif3_device, &latencies);
1028 rmobile_add_device_to_domain_td("A3SP", &scif4_device, &latencies);
1029 rmobile_add_device_to_domain_td("A3SP", &scif5_device, &latencies);
1030 rmobile_add_device_to_domain_td("A3SP", &scif6_device, &latencies);
1031 rmobile_add_device_to_domain_td("A3SP", &iic1_device, &latencies);
1032 rmobile_add_device_to_domain_td("A3SP", &dma0_device, &latencies);
1033 rmobile_add_device_to_domain_td("A3SP", &dma1_device, &latencies);
1034 rmobile_add_device_to_domain_td("A3SP", &dma2_device, &latencies);
1035 rmobile_add_device_to_domain_td("A3SP", &usb_dma0_device, &latencies);
1036 rmobile_add_device_to_domain_td("A3SP", &usb_dma1_device, &latencies);
1037 rmobile_add_device_to_domain_td("A4R", &iic0_device, &latencies);
1038 rmobile_add_device_to_domain_td("A4R", &veu0_device, &latencies);
1039 rmobile_add_device_to_domain_td("A4R", &veu1_device, &latencies);
1040 rmobile_add_device_to_domain_td("A4R", &veu2_device, &latencies);
1041 rmobile_add_device_to_domain_td("A4R", &veu3_device, &latencies);
1042 rmobile_add_device_to_domain_td("A4R", &jpu_device, &latencies);
1043 rmobile_add_device_to_domain_td("A4R", &tmu00_device, &latencies);
1044 rmobile_add_device_to_domain_td("A4R", &tmu01_device, &latencies);
1045} 1041}
1046 1042
1047static void __init sh7372_earlytimer_init(void) 1043static void __init sh7372_earlytimer_init(void)