]> git.karo-electronics.de Git - karo-tx-linux.git/blob - arch/arm/mach-clps711x/devices.c
Merge tag 'dt-for-3.17' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
[karo-tx-linux.git] / arch / arm / mach-clps711x / devices.c
1 /*
2  *  CLPS711X common devices definitions
3  *
4  *  Author: Alexander Shiyan <shc_work@mail.ru>, 2013
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  */
11
12 #include <linux/platform_device.h>
13 #include <linux/sizes.h>
14
15 #include <mach/hardware.h>
16
17 static const struct resource clps711x_cpuidle_res __initconst =
18         DEFINE_RES_MEM(CLPS711X_PHYS_BASE + HALT, SZ_128);
19
20 static void __init clps711x_add_cpuidle(void)
21 {
22         platform_device_register_simple("clps711x-cpuidle", PLATFORM_DEVID_NONE,
23                                         &clps711x_cpuidle_res, 1);
24 }
25
26 static const phys_addr_t clps711x_gpios[][2] __initconst = {
27         { PADR, PADDR },
28         { PBDR, PBDDR },
29         { PCDR, PCDDR },
30         { PDDR, PDDDR },
31         { PEDR, PEDDR },
32 };
33
34 static void __init clps711x_add_gpio(void)
35 {
36         unsigned i;
37         struct resource gpio_res[2];
38
39         memset(gpio_res, 0, sizeof(gpio_res));
40
41         gpio_res[0].flags = IORESOURCE_MEM;
42         gpio_res[1].flags = IORESOURCE_MEM;
43
44         for (i = 0; i < ARRAY_SIZE(clps711x_gpios); i++) {
45                 gpio_res[0].start = CLPS711X_PHYS_BASE + clps711x_gpios[i][0];
46                 gpio_res[0].end = gpio_res[0].start;
47                 gpio_res[1].start = CLPS711X_PHYS_BASE + clps711x_gpios[i][1];
48                 gpio_res[1].end = gpio_res[1].start;
49
50                 platform_device_register_simple("clps711x-gpio", i,
51                                                 gpio_res, ARRAY_SIZE(gpio_res));
52         }
53 }
54
55 const struct resource clps711x_syscon_res[] __initconst = {
56         /* SYSCON1, SYSFLG1 */
57         DEFINE_RES_MEM(CLPS711X_PHYS_BASE + SYSCON1, SZ_128),
58         /* SYSCON2, SYSFLG2 */
59         DEFINE_RES_MEM(CLPS711X_PHYS_BASE + SYSCON2, SZ_128),
60         /* SYSCON3 */
61         DEFINE_RES_MEM(CLPS711X_PHYS_BASE + SYSCON3, SZ_64),
62 };
63
64 static void __init clps711x_add_syscon(void)
65 {
66         unsigned i;
67
68         for (i = 0; i < ARRAY_SIZE(clps711x_syscon_res); i++)
69                 platform_device_register_simple("syscon", i + 1,
70                                                 &clps711x_syscon_res[i], 1);
71 }
72
73 static const struct resource clps711x_uart1_res[] __initconst = {
74         DEFINE_RES_MEM(CLPS711X_PHYS_BASE + UARTDR1, SZ_128),
75         DEFINE_RES_IRQ(IRQ_UTXINT1),
76         DEFINE_RES_IRQ(IRQ_URXINT1),
77 };
78
79 static const struct resource clps711x_uart2_res[] __initconst = {
80         DEFINE_RES_MEM(CLPS711X_PHYS_BASE + UARTDR2, SZ_128),
81         DEFINE_RES_IRQ(IRQ_UTXINT2),
82         DEFINE_RES_IRQ(IRQ_URXINT2),
83 };
84
85 static void __init clps711x_add_uart(void)
86 {
87         platform_device_register_simple("clps711x-uart", 0, clps711x_uart1_res,
88                                         ARRAY_SIZE(clps711x_uart1_res));
89         platform_device_register_simple("clps711x-uart", 1, clps711x_uart2_res,
90                                         ARRAY_SIZE(clps711x_uart2_res));
91 };
92
93 void __init clps711x_devices_init(void)
94 {
95         clps711x_add_cpuidle();
96         clps711x_add_gpio();
97         clps711x_add_syscon();
98         clps711x_add_uart();
99 }