Path: blob/master/arch/arm/mach-at91/board-pcontrol-g20.c
10817 views
/*1* Copyright (C) 2010 Christian Glindkamp <[email protected]>2* taskit GmbH3*4* This program is free software; you can redistribute it and/or modify5* it under the terms of the GNU General Public License as published by6* the Free Software Foundation; either version 2 of the License, or7* (at your option) any later version.8*9* This program is distributed in the hope that it will be useful,10* but WITHOUT ANY WARRANTY; without even the implied warranty of11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12* GNU General Public License for more details.13*14* You should have received a copy of the GNU General Public License15* along with this program; if not, write to the Free Software16* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA17*/18/*19* copied and adjusted from board-stamp9g20.c20* by Peter Gsellmann <[email protected]>21*/2223#include <linux/mm.h>24#include <linux/platform_device.h>25#include <linux/gpio.h>26#include <linux/w1-gpio.h>2728#include <asm/mach-types.h>29#include <asm/mach/arch.h>3031#include <mach/board.h>32#include <mach/at91sam9_smc.h>33#include <mach/stamp9g20.h>3435#include "sam9_smc.h"36#include "generic.h"373839static void __init pcontrol_g20_init_early(void)40{41stamp9g20_init_early();4243/* USART0 on ttyS1. (Rx, Tx, CTS, RTS) piggyback A2 */44at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS45| ATMEL_UART_RTS);4647/* USART1 on ttyS2. (Rx, Tx, CTS, RTS) isolated RS485 X5 */48at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS49| ATMEL_UART_RTS);5051/* USART2 on ttyS3. (Rx, Tx) 9bit-Bus Multidrop-mode X4 */52at91_register_uart(AT91SAM9260_ID_US4, 3, 0);53}545556static void __init init_irq(void)57{58at91sam9260_init_interrupts(NULL);59}606162static struct sam9_smc_config __initdata pcontrol_smc_config[2] = { {63.ncs_read_setup = 16,64.nrd_setup = 18,65.ncs_write_setup = 16,66.nwe_setup = 18,6768.ncs_read_pulse = 63,69.nrd_pulse = 55,70.ncs_write_pulse = 63,71.nwe_pulse = 55,7273.read_cycle = 127,74.write_cycle = 127,7576.mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE77| AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_SELECT78| AT91_SMC_DBW_8 | AT91_SMC_PS_479| AT91_SMC_TDFMODE,80.tdf_cycles = 3,81}, {82.ncs_read_setup = 0,83.nrd_setup = 0,84.ncs_write_setup = 0,85.nwe_setup = 1,8687.ncs_read_pulse = 8,88.nrd_pulse = 8,89.ncs_write_pulse = 5,90.nwe_pulse = 4,9192.read_cycle = 8,93.write_cycle = 7,9495.mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE96| AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_SELECT97| AT91_SMC_DBW_16 | AT91_SMC_PS_898| AT91_SMC_TDFMODE,99.tdf_cycles = 1,100} };101102static void __init add_device_pcontrol(void)103{104/* configure chip-select 4 (IO compatible to 8051 X4 ) */105sam9_smc_configure(4, &pcontrol_smc_config[0]);106/* configure chip-select 7 (FerroRAM 256KiBx16bit MR2A16A D4 ) */107sam9_smc_configure(7, &pcontrol_smc_config[1]);108}109110111/*112* USB Host port113*/114static struct at91_usbh_data __initdata usbh_data = {115.ports = 2,116};117118119/*120* USB Device port121*/122static struct at91_udc_data __initdata pcontrol_g20_udc_data = {123.vbus_pin = AT91_PIN_PA22, /* Detect +5V bus voltage */124.pullup_pin = AT91_PIN_PA4, /* K-state, active low */125};126127128/*129* MACB Ethernet device130*/131static struct at91_eth_data __initdata macb_data = {132.phy_irq_pin = AT91_PIN_PA28,133.is_rmii = 1,134};135136137/*138* I2C devices: eeprom and phy/switch139*/140static struct i2c_board_info __initdata pcontrol_g20_i2c_devices[] = {141{ /* D7 address width=2, 8KiB */142I2C_BOARD_INFO("24c64", 0x50)143}, { /* D8 address width=1, 1 byte has 32 bits! */144I2C_BOARD_INFO("lan9303", 0x0a)145}, };146147148/*149* LEDs150*/151static struct gpio_led pcontrol_g20_leds[] = {152{153.name = "LED1", /* red H5 */154.gpio = AT91_PIN_PB18,155.active_low = 1,156.default_trigger = "none", /* supervisor */157}, {158.name = "LED2", /* yellow H7 */159.gpio = AT91_PIN_PB19,160.active_low = 1,161.default_trigger = "mmc0", /* SD-card activity */162}, {163.name = "LED3", /* green H2 */164.gpio = AT91_PIN_PB20,165.active_low = 1,166.default_trigger = "heartbeat", /* blinky */167}, {168.name = "LED4", /* red H3 */169.gpio = AT91_PIN_PC6,170.active_low = 1,171.default_trigger = "none", /* connection lost */172}, {173.name = "LED5", /* yellow H6 */174.gpio = AT91_PIN_PC7,175.active_low = 1,176.default_trigger = "none", /* unsent data */177}, {178.name = "LED6", /* green H1 */179.gpio = AT91_PIN_PC9,180.active_low = 1,181.default_trigger = "none", /* snafu */182}183};184185186/*187* SPI devices188*/189static struct spi_board_info pcontrol_g20_spi_devices[] = {190{191.modalias = "spidev", /* HMI port X4 */192.chip_select = 1,193.max_speed_hz = 50 * 1000 * 1000,194.bus_num = 0,195}, {196.modalias = "spidev", /* piggyback A2 */197.chip_select = 0,198.max_speed_hz = 50 * 1000 * 1000,199.bus_num = 1,200},201};202203204static void __init pcontrol_g20_board_init(void)205{206stamp9g20_board_init();207at91_add_device_usbh(&usbh_data);208at91_add_device_eth(&macb_data);209at91_add_device_i2c(pcontrol_g20_i2c_devices,210ARRAY_SIZE(pcontrol_g20_i2c_devices));211add_device_pcontrol();212at91_add_device_spi(pcontrol_g20_spi_devices,213ARRAY_SIZE(pcontrol_g20_spi_devices));214at91_add_device_udc(&pcontrol_g20_udc_data);215at91_gpio_leds(pcontrol_g20_leds,216ARRAY_SIZE(pcontrol_g20_leds));217/* piggyback A2 */218at91_set_gpio_output(AT91_PIN_PB31, 1);219}220221222MACHINE_START(PCONTROL_G20, "PControl G20")223/* Maintainer: [email protected] */224.timer = &at91sam926x_timer,225.map_io = at91sam9260_map_io,226.init_early = pcontrol_g20_init_early,227.init_irq = init_irq,228.init_machine = pcontrol_g20_board_init,229MACHINE_END230231232