diff options
author | Shawn Guo <shawn.guo@linaro.org> | 2012-09-15 02:26:14 -0400 |
---|---|---|
committer | Shawn Guo <shawn.guo@linaro.org> | 2012-10-14 22:03:16 -0400 |
commit | bb1d34a20d537e2f2342db8b5918512f05b0f852 (patch) | |
tree | f98a0ccfd5a959a4638715df601cdd9561765771 | |
parent | 4d62435f0601ecec379fdc48749a10353fee8217 (diff) |
rtc: mxc_rtc: remove cpu_is_xxx by using platform_device_id
It changes the driver to use platform_device_id rather than cpu_is_xxx
to determine the controller type, and updates the platform code
accordingly.
As the result, mach/hardware.h inclusion gets removed from the driver.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Acked-by: Sascha Hauer <s.hauer@pengutronix.de>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: rtc-linux@googlegroups.com
-rw-r--r-- | arch/arm/mach-imx/clk-imx1.c | 2 | ||||
-rw-r--r-- | arch/arm/mach-imx/clk-imx27.c | 2 | ||||
-rw-r--r-- | arch/arm/mach-imx/clk-imx31.c | 2 | ||||
-rw-r--r-- | arch/arm/mach-imx/devices/devices-common.h | 1 | ||||
-rw-r--r-- | arch/arm/mach-imx/devices/platform-mxc_rtc.c | 9 | ||||
-rw-r--r-- | drivers/rtc/rtc-mxc.c | 34 |
6 files changed, 40 insertions, 10 deletions
diff --git a/arch/arm/mach-imx/clk-imx1.c b/arch/arm/mach-imx/clk-imx1.c index 198238859446..1cc7a735ed19 100644 --- a/arch/arm/mach-imx/clk-imx1.c +++ b/arch/arm/mach-imx/clk-imx1.c | |||
@@ -106,7 +106,7 @@ int __init mx1_clocks_init(unsigned long fref) | |||
106 | clk_register_clkdev(clk[dummy], "ahb", "imx-fb.0"); | 106 | clk_register_clkdev(clk[dummy], "ahb", "imx-fb.0"); |
107 | clk_register_clkdev(clk[hclk], "mshc", NULL); | 107 | clk_register_clkdev(clk[hclk], "mshc", NULL); |
108 | clk_register_clkdev(clk[per3], "ssi", NULL); | 108 | clk_register_clkdev(clk[per3], "ssi", NULL); |
109 | clk_register_clkdev(clk[clk32], NULL, "mxc_rtc.0"); | 109 | clk_register_clkdev(clk[clk32], NULL, "imx1-rtc.0"); |
110 | clk_register_clkdev(clk[clko], "clko", NULL); | 110 | clk_register_clkdev(clk[clko], "clko", NULL); |
111 | 111 | ||
112 | mxc_timer_init(MX1_IO_ADDRESS(MX1_TIM1_BASE_ADDR), MX1_TIM1_INT); | 112 | mxc_timer_init(MX1_IO_ADDRESS(MX1_TIM1_BASE_ADDR), MX1_TIM1_INT); |
diff --git a/arch/arm/mach-imx/clk-imx27.c b/arch/arm/mach-imx/clk-imx27.c index 100e38c48f9f..86a0c4262471 100644 --- a/arch/arm/mach-imx/clk-imx27.c +++ b/arch/arm/mach-imx/clk-imx27.c | |||
@@ -259,7 +259,7 @@ int __init mx27_clocks_init(unsigned long fref) | |||
259 | clk_register_clkdev(clk[gpio_ipg_gate], "gpio", NULL); | 259 | clk_register_clkdev(clk[gpio_ipg_gate], "gpio", NULL); |
260 | clk_register_clkdev(clk[brom_ahb_gate], "brom", NULL); | 260 | clk_register_clkdev(clk[brom_ahb_gate], "brom", NULL); |
261 | clk_register_clkdev(clk[ata_ahb_gate], "ata", NULL); | 261 | clk_register_clkdev(clk[ata_ahb_gate], "ata", NULL); |
262 | clk_register_clkdev(clk[rtc_ipg_gate], NULL, "mxc_rtc"); | 262 | clk_register_clkdev(clk[rtc_ipg_gate], NULL, "imx21-rtc"); |
263 | clk_register_clkdev(clk[scc_ipg_gate], "scc", NULL); | 263 | clk_register_clkdev(clk[scc_ipg_gate], "scc", NULL); |
264 | clk_register_clkdev(clk[cpu_div], "cpu", NULL); | 264 | clk_register_clkdev(clk[cpu_div], "cpu", NULL); |
265 | clk_register_clkdev(clk[emi_ahb_gate], "emi_ahb" , NULL); | 265 | clk_register_clkdev(clk[emi_ahb_gate], "emi_ahb" , NULL); |
diff --git a/arch/arm/mach-imx/clk-imx31.c b/arch/arm/mach-imx/clk-imx31.c index 729d1a9dbf6a..d9ff16e2b1e2 100644 --- a/arch/arm/mach-imx/clk-imx31.c +++ b/arch/arm/mach-imx/clk-imx31.c | |||
@@ -124,7 +124,7 @@ int __init mx31_clocks_init(unsigned long fref) | |||
124 | clk_register_clkdev(clk[cspi3_gate], NULL, "imx31-cspi.2"); | 124 | clk_register_clkdev(clk[cspi3_gate], NULL, "imx31-cspi.2"); |
125 | clk_register_clkdev(clk[pwm_gate], "pwm", NULL); | 125 | clk_register_clkdev(clk[pwm_gate], "pwm", NULL); |
126 | clk_register_clkdev(clk[wdog_gate], NULL, "imx2-wdt.0"); | 126 | clk_register_clkdev(clk[wdog_gate], NULL, "imx2-wdt.0"); |
127 | clk_register_clkdev(clk[rtc_gate], NULL, "mxc_rtc"); | 127 | clk_register_clkdev(clk[rtc_gate], NULL, "imx21-rtc"); |
128 | clk_register_clkdev(clk[epit1_gate], "epit", NULL); | 128 | clk_register_clkdev(clk[epit1_gate], "epit", NULL); |
129 | clk_register_clkdev(clk[epit2_gate], "epit", NULL); | 129 | clk_register_clkdev(clk[epit2_gate], "epit", NULL); |
130 | clk_register_clkdev(clk[nfc], NULL, "imx27-nand.0"); | 130 | clk_register_clkdev(clk[nfc], NULL, "imx27-nand.0"); |
diff --git a/arch/arm/mach-imx/devices/devices-common.h b/arch/arm/mach-imx/devices/devices-common.h index 30a842ffc553..1472f0fc325c 100644 --- a/arch/arm/mach-imx/devices/devices-common.h +++ b/arch/arm/mach-imx/devices/devices-common.h | |||
@@ -292,6 +292,7 @@ struct platform_device *__init imx_add_mxc_pwm( | |||
292 | 292 | ||
293 | /* mxc_rtc */ | 293 | /* mxc_rtc */ |
294 | struct imx_mxc_rtc_data { | 294 | struct imx_mxc_rtc_data { |
295 | const char *devid; | ||
295 | resource_size_t iobase; | 296 | resource_size_t iobase; |
296 | resource_size_t irq; | 297 | resource_size_t irq; |
297 | }; | 298 | }; |
diff --git a/arch/arm/mach-imx/devices/platform-mxc_rtc.c b/arch/arm/mach-imx/devices/platform-mxc_rtc.c index daaf9795db18..f35f848b0d5a 100644 --- a/arch/arm/mach-imx/devices/platform-mxc_rtc.c +++ b/arch/arm/mach-imx/devices/platform-mxc_rtc.c | |||
@@ -9,20 +9,21 @@ | |||
9 | #include <mach/hardware.h> | 9 | #include <mach/hardware.h> |
10 | #include "devices-common.h" | 10 | #include "devices-common.h" |
11 | 11 | ||
12 | #define imx_mxc_rtc_data_entry_single(soc) \ | 12 | #define imx_mxc_rtc_data_entry_single(soc, _devid) \ |
13 | { \ | 13 | { \ |
14 | .devid = _devid, \ | ||
14 | .iobase = soc ## _RTC_BASE_ADDR, \ | 15 | .iobase = soc ## _RTC_BASE_ADDR, \ |
15 | .irq = soc ## _INT_RTC, \ | 16 | .irq = soc ## _INT_RTC, \ |
16 | } | 17 | } |
17 | 18 | ||
18 | #ifdef CONFIG_SOC_IMX31 | 19 | #ifdef CONFIG_SOC_IMX31 |
19 | const struct imx_mxc_rtc_data imx31_mxc_rtc_data __initconst = | 20 | const struct imx_mxc_rtc_data imx31_mxc_rtc_data __initconst = |
20 | imx_mxc_rtc_data_entry_single(MX31); | 21 | imx_mxc_rtc_data_entry_single(MX31, "imx21-rtc"); |
21 | #endif /* ifdef CONFIG_SOC_IMX31 */ | 22 | #endif /* ifdef CONFIG_SOC_IMX31 */ |
22 | 23 | ||
23 | #ifdef CONFIG_SOC_IMX35 | 24 | #ifdef CONFIG_SOC_IMX35 |
24 | const struct imx_mxc_rtc_data imx35_mxc_rtc_data __initconst = | 25 | const struct imx_mxc_rtc_data imx35_mxc_rtc_data __initconst = |
25 | imx_mxc_rtc_data_entry_single(MX35); | 26 | imx_mxc_rtc_data_entry_single(MX35, "imx21-rtc"); |
26 | #endif /* ifdef CONFIG_SOC_IMX35 */ | 27 | #endif /* ifdef CONFIG_SOC_IMX35 */ |
27 | 28 | ||
28 | struct platform_device *__init imx_add_mxc_rtc( | 29 | struct platform_device *__init imx_add_mxc_rtc( |
@@ -40,6 +41,6 @@ struct platform_device *__init imx_add_mxc_rtc( | |||
40 | }, | 41 | }, |
41 | }; | 42 | }; |
42 | 43 | ||
43 | return imx_add_platform_device("mxc_rtc", -1, | 44 | return imx_add_platform_device(data->devid, -1, |
44 | res, ARRAY_SIZE(res), NULL, 0); | 45 | res, ARRAY_SIZE(res), NULL, 0); |
45 | } | 46 | } |
diff --git a/drivers/rtc/rtc-mxc.c b/drivers/rtc/rtc-mxc.c index cd0106293a49..7304139934aa 100644 --- a/drivers/rtc/rtc-mxc.c +++ b/drivers/rtc/rtc-mxc.c | |||
@@ -17,8 +17,6 @@ | |||
17 | #include <linux/platform_device.h> | 17 | #include <linux/platform_device.h> |
18 | #include <linux/clk.h> | 18 | #include <linux/clk.h> |
19 | 19 | ||
20 | #include <mach/hardware.h> | ||
21 | |||
22 | #define RTC_INPUT_CLK_32768HZ (0x00 << 5) | 20 | #define RTC_INPUT_CLK_32768HZ (0x00 << 5) |
23 | #define RTC_INPUT_CLK_32000HZ (0x01 << 5) | 21 | #define RTC_INPUT_CLK_32000HZ (0x01 << 5) |
24 | #define RTC_INPUT_CLK_38400HZ (0x02 << 5) | 22 | #define RTC_INPUT_CLK_38400HZ (0x02 << 5) |
@@ -72,14 +70,38 @@ static const u32 PIE_BIT_DEF[MAX_PIE_NUM][2] = { | |||
72 | #define RTC_TEST2 0x2C /* 32bit rtc test reg 2 */ | 70 | #define RTC_TEST2 0x2C /* 32bit rtc test reg 2 */ |
73 | #define RTC_TEST3 0x30 /* 32bit rtc test reg 3 */ | 71 | #define RTC_TEST3 0x30 /* 32bit rtc test reg 3 */ |
74 | 72 | ||
73 | enum imx_rtc_type { | ||
74 | IMX1_RTC, | ||
75 | IMX21_RTC, | ||
76 | }; | ||
77 | |||
75 | struct rtc_plat_data { | 78 | struct rtc_plat_data { |
76 | struct rtc_device *rtc; | 79 | struct rtc_device *rtc; |
77 | void __iomem *ioaddr; | 80 | void __iomem *ioaddr; |
78 | int irq; | 81 | int irq; |
79 | struct clk *clk; | 82 | struct clk *clk; |
80 | struct rtc_time g_rtc_alarm; | 83 | struct rtc_time g_rtc_alarm; |
84 | enum imx_rtc_type devtype; | ||
81 | }; | 85 | }; |
82 | 86 | ||
87 | static struct platform_device_id imx_rtc_devtype[] = { | ||
88 | { | ||
89 | .name = "imx1-rtc", | ||
90 | .driver_data = IMX1_RTC, | ||
91 | }, { | ||
92 | .name = "imx21-rtc", | ||
93 | .driver_data = IMX21_RTC, | ||
94 | }, { | ||
95 | /* sentinel */ | ||
96 | } | ||
97 | }; | ||
98 | MODULE_DEVICE_TABLE(platform, imx_rtc_devtype); | ||
99 | |||
100 | static inline int is_imx1_rtc(struct rtc_plat_data *data) | ||
101 | { | ||
102 | return data->devtype == IMX1_RTC; | ||
103 | } | ||
104 | |||
83 | /* | 105 | /* |
84 | * This function is used to obtain the RTC time or the alarm value in | 106 | * This function is used to obtain the RTC time or the alarm value in |
85 | * second. | 107 | * second. |
@@ -278,10 +300,13 @@ static int mxc_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
278 | */ | 300 | */ |
279 | static int mxc_rtc_set_mmss(struct device *dev, unsigned long time) | 301 | static int mxc_rtc_set_mmss(struct device *dev, unsigned long time) |
280 | { | 302 | { |
303 | struct platform_device *pdev = to_platform_device(dev); | ||
304 | struct rtc_plat_data *pdata = platform_get_drvdata(pdev); | ||
305 | |||
281 | /* | 306 | /* |
282 | * TTC_DAYR register is 9-bit in MX1 SoC, save time and day of year only | 307 | * TTC_DAYR register is 9-bit in MX1 SoC, save time and day of year only |
283 | */ | 308 | */ |
284 | if (cpu_is_mx1()) { | 309 | if (is_imx1_rtc(pdata)) { |
285 | struct rtc_time tm; | 310 | struct rtc_time tm; |
286 | 311 | ||
287 | rtc_time_to_tm(time, &tm); | 312 | rtc_time_to_tm(time, &tm); |
@@ -360,6 +385,8 @@ static int __devinit mxc_rtc_probe(struct platform_device *pdev) | |||
360 | if (!pdata) | 385 | if (!pdata) |
361 | return -ENOMEM; | 386 | return -ENOMEM; |
362 | 387 | ||
388 | pdata->devtype = pdev->id_entry->driver_data; | ||
389 | |||
363 | if (!devm_request_mem_region(&pdev->dev, res->start, | 390 | if (!devm_request_mem_region(&pdev->dev, res->start, |
364 | resource_size(res), pdev->name)) | 391 | resource_size(res), pdev->name)) |
365 | return -EBUSY; | 392 | return -EBUSY; |
@@ -480,6 +507,7 @@ static struct platform_driver mxc_rtc_driver = { | |||
480 | #endif | 507 | #endif |
481 | .owner = THIS_MODULE, | 508 | .owner = THIS_MODULE, |
482 | }, | 509 | }, |
510 | .id_table = imx_rtc_devtype, | ||
483 | .probe = mxc_rtc_probe, | 511 | .probe = mxc_rtc_probe, |
484 | .remove = __devexit_p(mxc_rtc_remove), | 512 | .remove = __devexit_p(mxc_rtc_remove), |
485 | }; | 513 | }; |