Path: blob/master/arch/avr32/boards/atstk1000/atstk1003.c
10819 views
/*1* ATSTK1003 daughterboard-specific init code2*3* Copyright (C) 2007 Atmel Corporation4*5* This program is free software; you can redistribute it and/or modify6* it under the terms of the GNU General Public License version 2 as7* published by the Free Software Foundation.8*/9#include <linux/clk.h>10#include <linux/err.h>11#include <linux/init.h>12#include <linux/kernel.h>13#include <linux/platform_device.h>14#include <linux/string.h>15#include <linux/types.h>1617#include <linux/spi/at73c213.h>18#include <linux/spi/spi.h>19#include <linux/atmel-mci.h>2021#include <asm/setup.h>2223#include <mach/at32ap700x.h>24#include <mach/board.h>25#include <mach/init.h>26#include <mach/portmux.h>2728#include "atstk1000.h"2930/* Oscillator frequencies. These are board specific */31unsigned long at32_board_osc_rates[3] = {32[0] = 32768, /* 32.768 kHz on RTC osc */33[1] = 20000000, /* 20 MHz on osc0 */34[2] = 12000000, /* 12 MHz on osc1 */35};3637#ifdef CONFIG_BOARD_ATSTK1000_EXTDAC38static struct at73c213_board_info at73c213_data = {39.ssc_id = 0,40.shortname = "AVR32 STK1000 external DAC",41};42#endif4344#ifndef CONFIG_BOARD_ATSTK100X_SW1_CUSTOM45static struct spi_board_info spi0_board_info[] __initdata = {46#ifdef CONFIG_BOARD_ATSTK1000_EXTDAC47{48/* AT73C213 */49.modalias = "at73c213",50.max_speed_hz = 200000,51.chip_select = 0,52.mode = SPI_MODE_1,53.platform_data = &at73c213_data,54},55#endif56/*57* We can control the LTV350QV LCD panel, but it isn't much58* point since we don't have an LCD controller...59*/60};61#endif6263#ifdef CONFIG_BOARD_ATSTK100X_SPI164static struct spi_board_info spi1_board_info[] __initdata = { {65/* patch in custom entries here */66} };67#endif6869#ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM70static struct mci_platform_data __initdata mci0_data = {71.slot[0] = {72.bus_width = 4,73.detect_pin = -ENODEV,74.wp_pin = -ENODEV,75},76};77#endif7879#ifdef CONFIG_BOARD_ATSTK1000_EXTDAC80static void __init atstk1003_setup_extdac(void)81{82struct clk *gclk;83struct clk *pll;8485gclk = clk_get(NULL, "gclk0");86if (IS_ERR(gclk))87goto err_gclk;88pll = clk_get(NULL, "pll0");89if (IS_ERR(pll))90goto err_pll;9192if (clk_set_parent(gclk, pll)) {93pr_debug("STK1000: failed to set pll0 as parent for DAC clock\n");94goto err_set_clk;95}9697at32_select_periph(GPIO_PIOA_BASE, (1 << 30), GPIO_PERIPH_A, 0);98at73c213_data.dac_clk = gclk;99100err_set_clk:101clk_put(pll);102err_pll:103clk_put(gclk);104err_gclk:105return;106}107#else108static void __init atstk1003_setup_extdac(void)109{110111}112#endif /* CONFIG_BOARD_ATSTK1000_EXTDAC */113114void __init setup_board(void)115{116#ifdef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM117at32_map_usart(0, 1, 0); /* USART 0/B: /dev/ttyS1, IRDA */118#else119at32_map_usart(1, 0, 0); /* USART 1/A: /dev/ttyS0, DB9 */120#endif121/* USART 2/unused: expansion connector */122at32_map_usart(3, 2, 0); /* USART 3/C: /dev/ttyS2, DB9 */123124at32_setup_serial_console(0);125}126127static int __init atstk1003_init(void)128{129/*130* ATSTK1000 uses 32-bit SDRAM interface. Reserve the131* SDRAM-specific pins so that nobody messes with them.132*/133at32_reserve_pin(GPIO_PIOE_BASE, ATMEL_EBI_PE_DATA_ALL);134135#ifdef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM136at32_add_device_usart(1);137#else138at32_add_device_usart(0);139#endif140at32_add_device_usart(2);141142#ifndef CONFIG_BOARD_ATSTK100X_SW1_CUSTOM143at32_add_device_spi(0, spi0_board_info, ARRAY_SIZE(spi0_board_info));144#endif145#ifdef CONFIG_BOARD_ATSTK100X_SPI1146at32_add_device_spi(1, spi1_board_info, ARRAY_SIZE(spi1_board_info));147#endif148#ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM149at32_add_device_mci(0, &mci0_data);150#endif151at32_add_device_usba(0, NULL);152#ifndef CONFIG_BOARD_ATSTK100X_SW3_CUSTOM153at32_add_device_ssc(0, ATMEL_SSC_TX);154#endif155156atstk1000_setup_j2_leds();157atstk1003_setup_extdac();158159return 0;160}161postcore_initcall(atstk1003_init);162163164