2 * ATSTK1003 daughterboard-specific init code
4 * Copyright (C) 2007 Atmel Corporation
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.
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>
18 #include <linux/spi/at73c213.h>
19 #include <linux/spi/spi.h>
21 #include <video/atmel_lcdc.h>
23 #include <asm/setup.h>
25 #include <mach/at32ap700x.h>
26 #include <mach/board.h>
27 #include <mach/init.h>
28 #include <mach/portmux.h>
30 #include "atstk1000.h"
32 /* Oscillator frequencies. These are board specific */
33 unsigned long at32_board_osc_rates[3] = {
34 [0] = 32768, /* 32.768 kHz on RTC osc */
35 [1] = 20000000, /* 20 MHz on osc0 */
36 [2] = 12000000, /* 12 MHz on osc1 */
39 #ifdef CONFIG_BOARD_ATSTK1000_EXTDAC
40 static struct at73c213_board_info at73c213_data = {
42 .shortname = "AVR32 STK1000 external DAC",
46 #ifndef CONFIG_BOARD_ATSTK100X_SW1_CUSTOM
47 static struct spi_board_info spi0_board_info[] __initdata = {
48 #ifdef CONFIG_BOARD_ATSTK1000_EXTDAC
51 .modalias = "at73c213",
52 .max_speed_hz = 200000,
55 .platform_data = &at73c213_data,
60 .modalias = "ltv350qv",
61 .max_speed_hz = 16000000,
68 #ifdef CONFIG_BOARD_ATSTK100X_SPI1
69 static struct spi_board_info spi1_board_info[] __initdata = { {
70 /* patch in custom entries here */
74 #ifdef CONFIG_BOARD_ATSTK1000_EXTDAC
75 static void __init atstk1004_setup_extdac(void)
80 gclk = clk_get(NULL, "gclk0");
83 pll = clk_get(NULL, "pll0");
87 if (clk_set_parent(gclk, pll)) {
88 pr_debug("STK1000: failed to set pll0 as parent for DAC clock\n");
92 at32_select_periph(GPIO_PIN_PA(30), GPIO_PERIPH_A, 0);
93 at73c213_data.dac_clk = gclk;
103 static void __init atstk1004_setup_extdac(void)
107 #endif /* CONFIG_BOARD_ATSTK1000_EXTDAC */
109 void __init setup_board(void)
111 #ifdef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
112 at32_map_usart(0, 1); /* USART 0/B: /dev/ttyS1, IRDA */
114 at32_map_usart(1, 0); /* USART 1/A: /dev/ttyS0, DB9 */
116 /* USART 2/unused: expansion connector */
117 at32_map_usart(3, 2); /* USART 3/C: /dev/ttyS2, DB9 */
119 at32_setup_serial_console(0);
122 static int __init atstk1004_init(void)
124 at32_add_system_devices();
126 #ifdef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
127 at32_add_device_usart(1);
129 at32_add_device_usart(0);
131 at32_add_device_usart(2);
133 #ifndef CONFIG_BOARD_ATSTK100X_SW1_CUSTOM
134 at32_add_device_spi(0, spi0_board_info, ARRAY_SIZE(spi0_board_info));
136 #ifdef CONFIG_BOARD_ATSTK100X_SPI1
137 at32_add_device_spi(1, spi1_board_info, ARRAY_SIZE(spi1_board_info));
139 #ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
140 at32_add_device_mci(0, NULL);
142 at32_add_device_lcdc(0, &atstk1000_lcdc_data,
143 fbmem_start, fbmem_size, 0);
144 at32_add_device_usba(0, NULL);
145 #ifndef CONFIG_BOARD_ATSTK100X_SW3_CUSTOM
146 at32_add_device_ssc(0, ATMEL_SSC_TX);
149 atstk1000_setup_j2_leds();
150 atstk1004_setup_extdac();
154 postcore_initcall(atstk1004_init);