diff options
author | Tero Jaasko <tero.jaasko@gmail.com> | 2012-10-26 11:56:16 -0400 |
---|---|---|
committer | Jason Cooper <jason@lakedaemon.net> | 2012-11-21 15:59:30 -0500 |
commit | afcad884252b171ff6f2ac78eb43c2f5db612dd0 (patch) | |
tree | 6013519c908237795b4ab546234829ae969e6295 /arch | |
parent | 767fc1ea92f70b5a97d43b79c146c2bee3eb6e83 (diff) |
arm: kirkwood: add support for ZyXEL NSA310
Hello, Andrew
> > +#define NSA310_GPIO_LED_ESATA_GREEN 12
> > <..>
> > +#define NSA310_GPIO_POWER_OFF 48
>
> It looks like most of these are not used. Please remove them.
True. Fixed.
> > +static struct mtd_partition nsa310_mtd_parts[] = {
> > + {
> > + .name = "uboot",
> > + .offset = 0,
> > + .size = 0x100000,
> > + .mask_flags = MTD_WRITEABLE,
> > + }, {
> > <..>
> You should be able to put all that into DT. Take a look at
Correct. I did the conversion and tested that the partitions
can be read with dd and produce exactly the same data before and
after conversion. So, the partition offsets at least should be fine.
> > +static struct i2c_board_info __initdata nsa310_i2c_info[] = {
> > + { I2C_BOARD_INFO("adt7476", 0x2e) },
> > +};
>
> You can also do this in DT as well. kirkwood-ts219.dtsi has
>
> i2c@11000 {
> status = "okay";
> clock-frequency = <400000>;
Ok, I did convert the i2c definition to use the devicetree.
The adt7476 device itself is not at reach of device tree,
AFAIK and requires more work at there?
Thanks for your valuable comments. Following is a new patch that
should address the problems and mistakes you pointed and also
some of the pointed by Jason Cooper. The nand and i2c are now
defined at DT and I also removed the pointless defines and
ARM_APPENDED_DTB. It is based against the Linus' official
3.6 version.
Best regards,
Tero
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/boot/dts/Makefile | 1 | ||||
-rw-r--r-- | arch/arm/boot/dts/kirkwood-nsa310.dts | 144 | ||||
-rw-r--r-- | arch/arm/mach-kirkwood/Kconfig | 8 | ||||
-rw-r--r-- | arch/arm/mach-kirkwood/Makefile | 1 | ||||
-rw-r--r-- | arch/arm/mach-kirkwood/board-dt.c | 4 | ||||
-rw-r--r-- | arch/arm/mach-kirkwood/board-nsa310.c | 105 | ||||
-rw-r--r-- | arch/arm/mach-kirkwood/common.h | 6 |
7 files changed, 269 insertions, 0 deletions
diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile index df3a8ae9224f..c5eb41c4b767 100644 --- a/arch/arm/boot/dts/Makefile +++ b/arch/arm/boot/dts/Makefile | |||
@@ -44,6 +44,7 @@ dtb-$(CONFIG_ARCH_KIRKWOOD) += kirkwood-dns320.dtb \ | |||
44 | kirkwood-ns2lite.dtb \ | 44 | kirkwood-ns2lite.dtb \ |
45 | kirkwood-ns2max.dtb \ | 45 | kirkwood-ns2max.dtb \ |
46 | kirkwood-ns2mini.dtb \ | 46 | kirkwood-ns2mini.dtb \ |
47 | kirkwood-nsa310.dtb \ | ||
47 | kirkwood-topkick.dtb \ | 48 | kirkwood-topkick.dtb \ |
48 | kirkwood-ts219-6281.dtb \ | 49 | kirkwood-ts219-6281.dtb \ |
49 | kirkwood-ts219-6282.dtb | 50 | kirkwood-ts219-6282.dtb |
diff --git a/arch/arm/boot/dts/kirkwood-nsa310.dts b/arch/arm/boot/dts/kirkwood-nsa310.dts new file mode 100644 index 000000000000..5509f9659546 --- /dev/null +++ b/arch/arm/boot/dts/kirkwood-nsa310.dts | |||
@@ -0,0 +1,144 @@ | |||
1 | /dts-v1/; | ||
2 | |||
3 | /include/ "kirkwood.dtsi" | ||
4 | |||
5 | / { | ||
6 | model = "ZyXEL NSA310"; | ||
7 | compatible = "zyxel,nsa310", "marvell,kirkwood-88f6281", "marvell,kirkwood"; | ||
8 | |||
9 | memory { | ||
10 | device_type = "memory"; | ||
11 | reg = <0x00000000 0x10000000>; | ||
12 | }; | ||
13 | |||
14 | chosen { | ||
15 | bootargs = "console=ttyS0,115200"; | ||
16 | }; | ||
17 | |||
18 | ocp@f1000000 { | ||
19 | |||
20 | serial@12000 { | ||
21 | clock-frequency = <200000000>; | ||
22 | status = "ok"; | ||
23 | }; | ||
24 | |||
25 | sata@80000 { | ||
26 | status = "okay"; | ||
27 | nr-ports = <2>; | ||
28 | }; | ||
29 | |||
30 | i2c@11000 { | ||
31 | status = "okay"; | ||
32 | }; | ||
33 | |||
34 | nand@3000000 { | ||
35 | status = "okay"; | ||
36 | chip-delay = <35>; | ||
37 | |||
38 | partition@0 { | ||
39 | label = "uboot"; | ||
40 | reg = <0x0000000 0x0100000>; | ||
41 | read-only; | ||
42 | }; | ||
43 | partition@100000 { | ||
44 | label = "uboot_env"; | ||
45 | reg = <0x0100000 0x0080000>; | ||
46 | }; | ||
47 | partition@180000 { | ||
48 | label = "key_store"; | ||
49 | reg = <0x0180000 0x0080000>; | ||
50 | }; | ||
51 | partition@200000 { | ||
52 | label = "info"; | ||
53 | reg = <0x0200000 0x0080000>; | ||
54 | }; | ||
55 | partition@280000 { | ||
56 | label = "etc"; | ||
57 | reg = <0x0280000 0x0a00000>; | ||
58 | }; | ||
59 | partition@c80000 { | ||
60 | label = "kernel_1"; | ||
61 | reg = <0x0c80000 0x0a00000>; | ||
62 | }; | ||
63 | partition@1680000 { | ||
64 | label = "rootfs1"; | ||
65 | reg = <0x1680000 0x2fc0000>; | ||
66 | }; | ||
67 | partition@4640000 { | ||
68 | label = "kernel_2"; | ||
69 | reg = <0x4640000 0x0a00000>; | ||
70 | }; | ||
71 | partition@5040000 { | ||
72 | label = "rootfs2"; | ||
73 | reg = <0x5040000 0x2fc0000>; | ||
74 | }; | ||
75 | }; | ||
76 | }; | ||
77 | |||
78 | gpio_keys { | ||
79 | compatible = "gpio-keys"; | ||
80 | #address-cells = <1>; | ||
81 | #size-cells = <0>; | ||
82 | |||
83 | button@1 { | ||
84 | label = "Power Button"; | ||
85 | linux,code = <116>; | ||
86 | gpios = <&gpio1 14 0>; | ||
87 | }; | ||
88 | button@2 { | ||
89 | label = "Copy Button"; | ||
90 | linux,code = <133>; | ||
91 | gpios = <&gpio1 5 1>; | ||
92 | }; | ||
93 | button@3 { | ||
94 | label = "Reset Button"; | ||
95 | linux,code = <0x198>; | ||
96 | gpios = <&gpio1 4 1>; | ||
97 | }; | ||
98 | }; | ||
99 | |||
100 | gpio-leds { | ||
101 | compatible = "gpio-leds"; | ||
102 | |||
103 | green-sys { | ||
104 | label = "nsa310:green:sys"; | ||
105 | gpios = <&gpio0 28 0>; | ||
106 | }; | ||
107 | red-sys { | ||
108 | label = "nsa310:red:sys"; | ||
109 | gpios = <&gpio0 29 0>; | ||
110 | }; | ||
111 | green-hdd { | ||
112 | label = "nsa310:green:hdd"; | ||
113 | gpios = <&gpio1 9 0>; | ||
114 | }; | ||
115 | red-hdd { | ||
116 | label = "nsa310:red:hdd"; | ||
117 | gpios = <&gpio1 10 0>; | ||
118 | }; | ||
119 | green-esata { | ||
120 | label = "nsa310:green:esata"; | ||
121 | gpios = <&gpio0 12 0>; | ||
122 | }; | ||
123 | red-esata { | ||
124 | label = "nsa310:red:esata"; | ||
125 | gpios = <&gpio0 13 0>; | ||
126 | }; | ||
127 | green-usb { | ||
128 | label = "nsa310:green:usb"; | ||
129 | gpios = <&gpio0 15 0>; | ||
130 | }; | ||
131 | red-usb { | ||
132 | label = "nsa310:red:usb"; | ||
133 | gpios = <&gpio0 16 0>; | ||
134 | }; | ||
135 | green-copy { | ||
136 | label = "nsa310:green:copy"; | ||
137 | gpios = <&gpio1 7 0>; | ||
138 | }; | ||
139 | red-copy { | ||
140 | label = "nsa310:red:copy"; | ||
141 | gpios = <&gpio1 8 0>; | ||
142 | }; | ||
143 | }; | ||
144 | }; | ||
diff --git a/arch/arm/mach-kirkwood/Kconfig b/arch/arm/mach-kirkwood/Kconfig index 1d5283fad014..a5b766e13304 100644 --- a/arch/arm/mach-kirkwood/Kconfig +++ b/arch/arm/mach-kirkwood/Kconfig | |||
@@ -259,6 +259,14 @@ config MACH_T5325 | |||
259 | Say 'Y' here if you want your kernel to support the | 259 | Say 'Y' here if you want your kernel to support the |
260 | HP t5325 Thin Client. | 260 | HP t5325 Thin Client. |
261 | 261 | ||
262 | config MACH_NSA310_DT | ||
263 | bool "ZyXEL NSA-310 (Flattened Device Tree)" | ||
264 | select ARCH_KIRKWOOD_DT | ||
265 | select ARM_ATAG_DTB_COMPAT | ||
266 | help | ||
267 | Say 'Y' here if you want your kernel to support the | ||
268 | ZyXEL NSA-310 board (Flattened Device Tree). | ||
269 | |||
262 | endmenu | 270 | endmenu |
263 | 271 | ||
264 | endif | 272 | endif |
diff --git a/arch/arm/mach-kirkwood/Makefile b/arch/arm/mach-kirkwood/Makefile index d867b36a39f8..8f7a34040af3 100644 --- a/arch/arm/mach-kirkwood/Makefile +++ b/arch/arm/mach-kirkwood/Makefile | |||
@@ -36,4 +36,5 @@ obj-$(CONFIG_MACH_NETSPACE_V2_DT) += board-ns2.o | |||
36 | obj-$(CONFIG_MACH_NETSPACE_MAX_V2_DT) += board-ns2.o | 36 | obj-$(CONFIG_MACH_NETSPACE_MAX_V2_DT) += board-ns2.o |
37 | obj-$(CONFIG_MACH_NETSPACE_LITE_V2_DT) += board-ns2.o | 37 | obj-$(CONFIG_MACH_NETSPACE_LITE_V2_DT) += board-ns2.o |
38 | obj-$(CONFIG_MACH_NETSPACE_MINI_V2_DT) += board-ns2.o | 38 | obj-$(CONFIG_MACH_NETSPACE_MINI_V2_DT) += board-ns2.o |
39 | obj-$(CONFIG_MACH_NSA310_DT) += board-nsa310.o | ||
39 | obj-$(CONFIG_MACH_TOPKICK_DT) += board-usi_topkick.o | 40 | obj-$(CONFIG_MACH_TOPKICK_DT) += board-usi_topkick.o |
diff --git a/arch/arm/mach-kirkwood/board-dt.c b/arch/arm/mach-kirkwood/board-dt.c index e0bb9ca59245..87c53d175d35 100644 --- a/arch/arm/mach-kirkwood/board-dt.c +++ b/arch/arm/mach-kirkwood/board-dt.c | |||
@@ -106,6 +106,9 @@ static void __init kirkwood_dt_init(void) | |||
106 | if (of_machine_is_compatible("usi,topkick")) | 106 | if (of_machine_is_compatible("usi,topkick")) |
107 | usi_topkick_init(); | 107 | usi_topkick_init(); |
108 | 108 | ||
109 | if (of_machine_is_compatible("zyxel,nsa310")) | ||
110 | nsa310_init(); | ||
111 | |||
109 | of_platform_populate(NULL, kirkwood_dt_match_table, | 112 | of_platform_populate(NULL, kirkwood_dt_match_table, |
110 | kirkwood_auxdata_lookup, NULL); | 113 | kirkwood_auxdata_lookup, NULL); |
111 | } | 114 | } |
@@ -128,6 +131,7 @@ static const char *kirkwood_dt_board_compat[] = { | |||
128 | "lacie,netspace_lite_v2", | 131 | "lacie,netspace_lite_v2", |
129 | "lacie,netspace_mini_v2", | 132 | "lacie,netspace_mini_v2", |
130 | "usi,topkick", | 133 | "usi,topkick", |
134 | "zyxel,nsa310", | ||
131 | NULL | 135 | NULL |
132 | }; | 136 | }; |
133 | 137 | ||
diff --git a/arch/arm/mach-kirkwood/board-nsa310.c b/arch/arm/mach-kirkwood/board-nsa310.c new file mode 100644 index 000000000000..027ce83f3fe5 --- /dev/null +++ b/arch/arm/mach-kirkwood/board-nsa310.c | |||
@@ -0,0 +1,105 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-kirkwood/nsa-310-setup.c | ||
3 | * | ||
4 | * ZyXEL NSA-310 Setup | ||
5 | * | ||
6 | * This file is licensed under the terms of the GNU General Public | ||
7 | * License version 2. This program is licensed "as is" without any | ||
8 | * warranty of any kind, whether express or implied. | ||
9 | */ | ||
10 | |||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/init.h> | ||
13 | #include <linux/i2c.h> | ||
14 | #include <linux/gpio.h> | ||
15 | |||
16 | #include <asm/mach-types.h> | ||
17 | #include <asm/mach/arch.h> | ||
18 | #include <mach/kirkwood.h> | ||
19 | #include "common.h" | ||
20 | #include "mpp.h" | ||
21 | |||
22 | #define NSA310_GPIO_USB_POWER_OFF 21 | ||
23 | #define NSA310_GPIO_POWER_OFF 48 | ||
24 | |||
25 | static unsigned int nsa310_mpp_config[] __initdata = { | ||
26 | MPP12_GPIO, /* led esata green */ | ||
27 | MPP13_GPIO, /* led esata red */ | ||
28 | MPP15_GPIO, /* led usb green */ | ||
29 | MPP16_GPIO, /* led usb red */ | ||
30 | MPP21_GPIO, /* control usb power off */ | ||
31 | MPP28_GPIO, /* led sys green */ | ||
32 | MPP29_GPIO, /* led sys red */ | ||
33 | MPP36_GPIO, /* key reset */ | ||
34 | MPP37_GPIO, /* key copy */ | ||
35 | MPP39_GPIO, /* led copy green */ | ||
36 | MPP40_GPIO, /* led copy red */ | ||
37 | MPP41_GPIO, /* led hdd green */ | ||
38 | MPP42_GPIO, /* led hdd red */ | ||
39 | MPP44_GPIO, /* ?? */ | ||
40 | MPP46_GPIO, /* key power */ | ||
41 | MPP48_GPIO, /* control power off */ | ||
42 | 0 | ||
43 | }; | ||
44 | |||
45 | static struct i2c_board_info __initdata nsa310_i2c_info[] = { | ||
46 | { I2C_BOARD_INFO("adt7476", 0x2e) }, | ||
47 | }; | ||
48 | |||
49 | static void nsa310_power_off(void) | ||
50 | { | ||
51 | gpio_set_value(NSA310_GPIO_POWER_OFF, 1); | ||
52 | } | ||
53 | |||
54 | static int __init nsa310_gpio_request(unsigned int gpio, unsigned long flags, | ||
55 | const char *label) | ||
56 | { | ||
57 | int err; | ||
58 | |||
59 | err = gpio_request_one(gpio, flags, label); | ||
60 | if (err) | ||
61 | pr_err("NSA-310: can't setup GPIO%u (%s), err=%d\n", | ||
62 | gpio, label, err); | ||
63 | |||
64 | return err; | ||
65 | } | ||
66 | |||
67 | static void __init nsa310_gpio_init(void) | ||
68 | { | ||
69 | int err; | ||
70 | |||
71 | err = nsa310_gpio_request(NSA310_GPIO_POWER_OFF, GPIOF_OUT_INIT_LOW, | ||
72 | "Power Off"); | ||
73 | if (!err) | ||
74 | pm_power_off = nsa310_power_off; | ||
75 | |||
76 | nsa310_gpio_request(NSA310_GPIO_USB_POWER_OFF, GPIOF_OUT_INIT_LOW, | ||
77 | "USB Power Off"); | ||
78 | } | ||
79 | |||
80 | void __init nsa310_init(void) | ||
81 | { | ||
82 | u32 dev, rev; | ||
83 | |||
84 | kirkwood_mpp_conf(nsa310_mpp_config); | ||
85 | |||
86 | nsa310_gpio_init(); | ||
87 | |||
88 | /* this can be removed once the mainline kirkwood.dtsi gets | ||
89 | * the ehci configuration by default */ | ||
90 | kirkwood_ehci_init(); | ||
91 | |||
92 | kirkwood_pcie_id(&dev, &rev); | ||
93 | |||
94 | i2c_register_board_info(0, ARRAY_AND_SIZE(nsa310_i2c_info)); | ||
95 | } | ||
96 | |||
97 | static int __init nsa310_pci_init(void) | ||
98 | { | ||
99 | if (of_machine_is_compatible("zyxel,nsa310")) | ||
100 | kirkwood_pcie_init(KW_PCIE0); | ||
101 | |||
102 | return 0; | ||
103 | } | ||
104 | |||
105 | subsys_initcall(nsa310_pci_init); | ||
diff --git a/arch/arm/mach-kirkwood/common.h b/arch/arm/mach-kirkwood/common.h index 276fc01dd6d7..652a7282cdb3 100644 --- a/arch/arm/mach-kirkwood/common.h +++ b/arch/arm/mach-kirkwood/common.h | |||
@@ -122,6 +122,12 @@ void ns2_init(void); | |||
122 | static inline void ns2_init(void) {}; | 122 | static inline void ns2_init(void) {}; |
123 | #endif | 123 | #endif |
124 | 124 | ||
125 | #ifdef CONFIG_MACH_NSA310_DT | ||
126 | void nsa310_init(void); | ||
127 | #else | ||
128 | static inline void nsa310_init(void) {}; | ||
129 | #endif | ||
130 | |||
125 | #ifdef CONFIG_MACH_TOPKICK_DT | 131 | #ifdef CONFIG_MACH_TOPKICK_DT |
126 | void usi_topkick_init(void); | 132 | void usi_topkick_init(void); |
127 | #else | 133 | #else |