diff options
Diffstat (limited to 'arch/avr32/boards/atstk1000/atstk1003.c')
-rw-r--r-- | arch/avr32/boards/atstk1000/atstk1003.c | 162 |
1 files changed, 162 insertions, 0 deletions
diff --git a/arch/avr32/boards/atstk1000/atstk1003.c b/arch/avr32/boards/atstk1000/atstk1003.c new file mode 100644 index 000000000000..a0b223df35a2 --- /dev/null +++ b/arch/avr32/boards/atstk1000/atstk1003.c | |||
@@ -0,0 +1,162 @@ | |||
1 | /* | ||
2 | * ATSTK1003 daughterboard-specific init code | ||
3 | * | ||
4 | * Copyright (C) 2007 Atmel Corporation | ||
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 version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | */ | ||
10 | #include <linux/clk.h> | ||
11 | #include <linux/err.h> | ||
12 | #include <linux/init.h> | ||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/platform_device.h> | ||
15 | #include <linux/string.h> | ||
16 | #include <linux/types.h> | ||
17 | |||
18 | #include <linux/spi/at73c213.h> | ||
19 | #include <linux/spi/spi.h> | ||
20 | |||
21 | #include <asm/setup.h> | ||
22 | |||
23 | #include <asm/arch/at32ap700x.h> | ||
24 | #include <asm/arch/board.h> | ||
25 | #include <asm/arch/init.h> | ||
26 | #include <asm/arch/portmux.h> | ||
27 | |||
28 | #include "atstk1000.h" | ||
29 | |||
30 | #ifdef CONFIG_BOARD_ATSTK1000_EXTDAC | ||
31 | static struct at73c213_board_info at73c213_data = { | ||
32 | .ssc_id = 0, | ||
33 | .shortname = "AVR32 STK1000 external DAC", | ||
34 | }; | ||
35 | #endif | ||
36 | |||
37 | #ifndef CONFIG_BOARD_ATSTK100X_SW1_CUSTOM | ||
38 | static struct spi_board_info spi0_board_info[] __initdata = { | ||
39 | #ifdef CONFIG_BOARD_ATSTK1000_EXTDAC | ||
40 | { | ||
41 | /* AT73C213 */ | ||
42 | .modalias = "at73c213", | ||
43 | .max_speed_hz = 200000, | ||
44 | .chip_select = 0, | ||
45 | .mode = SPI_MODE_1, | ||
46 | .platform_data = &at73c213_data, | ||
47 | }, | ||
48 | #endif | ||
49 | /* | ||
50 | * We can control the LTV350QV LCD panel, but it isn't much | ||
51 | * point since we don't have an LCD controller... | ||
52 | */ | ||
53 | }; | ||
54 | #endif | ||
55 | |||
56 | #ifdef CONFIG_BOARD_ATSTK100X_SPI1 | ||
57 | static struct spi_board_info spi1_board_info[] __initdata = { { | ||
58 | /* patch in custom entries here */ | ||
59 | } }; | ||
60 | #endif | ||
61 | |||
62 | #ifdef CONFIG_BOARD_ATSTK1000_EXTDAC | ||
63 | static void __init atstk1003_setup_extdac(void) | ||
64 | { | ||
65 | struct clk *gclk; | ||
66 | struct clk *pll; | ||
67 | |||
68 | gclk = clk_get(NULL, "gclk0"); | ||
69 | if (IS_ERR(gclk)) | ||
70 | goto err_gclk; | ||
71 | pll = clk_get(NULL, "pll0"); | ||
72 | if (IS_ERR(pll)) | ||
73 | goto err_pll; | ||
74 | |||
75 | if (clk_set_parent(gclk, pll)) { | ||
76 | pr_debug("STK1000: failed to set pll0 as parent for DAC clock\n"); | ||
77 | goto err_set_clk; | ||
78 | } | ||
79 | |||
80 | at32_select_periph(GPIO_PIN_PA(30), GPIO_PERIPH_A, 0); | ||
81 | at73c213_data.dac_clk = gclk; | ||
82 | |||
83 | err_set_clk: | ||
84 | clk_put(pll); | ||
85 | err_pll: | ||
86 | clk_put(gclk); | ||
87 | err_gclk: | ||
88 | return; | ||
89 | } | ||
90 | #else | ||
91 | static void __init atstk1003_setup_extdac(void) | ||
92 | { | ||
93 | |||
94 | } | ||
95 | #endif /* CONFIG_BOARD_ATSTK1000_EXTDAC */ | ||
96 | |||
97 | void __init setup_board(void) | ||
98 | { | ||
99 | #ifdef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM | ||
100 | at32_map_usart(0, 1); /* USART 0/B: /dev/ttyS1, IRDA */ | ||
101 | #else | ||
102 | at32_map_usart(1, 0); /* USART 1/A: /dev/ttyS0, DB9 */ | ||
103 | #endif | ||
104 | /* USART 2/unused: expansion connector */ | ||
105 | at32_map_usart(3, 2); /* USART 3/C: /dev/ttyS2, DB9 */ | ||
106 | |||
107 | at32_setup_serial_console(0); | ||
108 | } | ||
109 | |||
110 | static int __init atstk1003_init(void) | ||
111 | { | ||
112 | /* | ||
113 | * ATSTK1000 uses 32-bit SDRAM interface. Reserve the | ||
114 | * SDRAM-specific pins so that nobody messes with them. | ||
115 | */ | ||
116 | at32_reserve_pin(GPIO_PIN_PE(0)); /* DATA[16] */ | ||
117 | at32_reserve_pin(GPIO_PIN_PE(1)); /* DATA[17] */ | ||
118 | at32_reserve_pin(GPIO_PIN_PE(2)); /* DATA[18] */ | ||
119 | at32_reserve_pin(GPIO_PIN_PE(3)); /* DATA[19] */ | ||
120 | at32_reserve_pin(GPIO_PIN_PE(4)); /* DATA[20] */ | ||
121 | at32_reserve_pin(GPIO_PIN_PE(5)); /* DATA[21] */ | ||
122 | at32_reserve_pin(GPIO_PIN_PE(6)); /* DATA[22] */ | ||
123 | at32_reserve_pin(GPIO_PIN_PE(7)); /* DATA[23] */ | ||
124 | at32_reserve_pin(GPIO_PIN_PE(8)); /* DATA[24] */ | ||
125 | at32_reserve_pin(GPIO_PIN_PE(9)); /* DATA[25] */ | ||
126 | at32_reserve_pin(GPIO_PIN_PE(10)); /* DATA[26] */ | ||
127 | at32_reserve_pin(GPIO_PIN_PE(11)); /* DATA[27] */ | ||
128 | at32_reserve_pin(GPIO_PIN_PE(12)); /* DATA[28] */ | ||
129 | at32_reserve_pin(GPIO_PIN_PE(13)); /* DATA[29] */ | ||
130 | at32_reserve_pin(GPIO_PIN_PE(14)); /* DATA[30] */ | ||
131 | at32_reserve_pin(GPIO_PIN_PE(15)); /* DATA[31] */ | ||
132 | at32_reserve_pin(GPIO_PIN_PE(26)); /* SDCS */ | ||
133 | |||
134 | at32_add_system_devices(); | ||
135 | |||
136 | #ifdef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM | ||
137 | at32_add_device_usart(1); | ||
138 | #else | ||
139 | at32_add_device_usart(0); | ||
140 | #endif | ||
141 | at32_add_device_usart(2); | ||
142 | |||
143 | #ifndef CONFIG_BOARD_ATSTK100X_SW1_CUSTOM | ||
144 | at32_add_device_spi(0, spi0_board_info, ARRAY_SIZE(spi0_board_info)); | ||
145 | #endif | ||
146 | #ifdef CONFIG_BOARD_ATSTK100X_SPI1 | ||
147 | at32_add_device_spi(1, spi1_board_info, ARRAY_SIZE(spi1_board_info)); | ||
148 | #endif | ||
149 | #ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM | ||
150 | at32_add_device_mci(0); | ||
151 | #endif | ||
152 | at32_add_device_usba(0, NULL); | ||
153 | #ifndef CONFIG_BOARD_ATSTK100X_SW3_CUSTOM | ||
154 | at32_add_device_ssc(0, ATMEL_SSC_TX); | ||
155 | #endif | ||
156 | |||
157 | atstk1000_setup_j2_leds(); | ||
158 | atstk1003_setup_extdac(); | ||
159 | |||
160 | return 0; | ||
161 | } | ||
162 | postcore_initcall(atstk1003_init); | ||