Path: blob/master/arch/avr32/boards/hammerhead/setup.c
10819 views
/*1* Board-specific setup code for the Miromico Hammerhead board2*3* Copyright (C) 2008 Miromico AG4*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/atmel-mci.h>10#include <linux/clk.h>11#include <linux/fb.h>12#include <linux/etherdevice.h>13#include <linux/i2c.h>14#include <linux/i2c-gpio.h>15#include <linux/init.h>16#include <linux/linkage.h>17#include <linux/platform_device.h>18#include <linux/types.h>19#include <linux/spi/spi.h>2021#include <video/atmel_lcdc.h>2223#include <linux/io.h>24#include <asm/setup.h>2526#include <mach/at32ap700x.h>27#include <mach/board.h>28#include <mach/init.h>29#include <mach/portmux.h>3031#include <sound/atmel-ac97c.h>3233#include "../../mach-at32ap/clock.h"34#include "flash.h"3536/* Oscillator frequencies. These are board-specific */37unsigned long at32_board_osc_rates[3] = {38[0] = 32768, /* 32.768 kHz on RTC osc */39[1] = 25000000, /* 25MHz on osc0 */40[2] = 12000000, /* 12 MHz on osc1 */41};4243/* Initialized by bootloader-specific startup code. */44struct tag *bootloader_tags __initdata;4546#ifdef CONFIG_BOARD_HAMMERHEAD_LCD47static struct fb_videomode __initdata hda350tlv_modes[] = {48{49.name = "320x240 @ 75",50.refresh = 75,51.xres = 320,52.yres = 240,53.pixclock = KHZ2PICOS(6891),5455.left_margin = 48,56.right_margin = 18,57.upper_margin = 18,58.lower_margin = 4,59.hsync_len = 20,60.vsync_len = 2,6162.sync = 0,63.vmode = FB_VMODE_NONINTERLACED,64},65};6667static struct fb_monspecs __initdata hammerhead_hda350t_monspecs = {68.manufacturer = "HAN",69.monitor = "HDA350T-LV",70.modedb = hda350tlv_modes,71.modedb_len = ARRAY_SIZE(hda350tlv_modes),72.hfmin = 14900,73.hfmax = 22350,74.vfmin = 60,75.vfmax = 90,76.dclkmax = 10000000,77};7879struct atmel_lcdfb_info __initdata hammerhead_lcdc_data = {80.default_bpp = 24,81.default_dmacon = ATMEL_LCDC_DMAEN | ATMEL_LCDC_DMA2DEN,82.default_lcdcon2 = (ATMEL_LCDC_DISTYPE_TFT83| ATMEL_LCDC_INVCLK84| ATMEL_LCDC_CLKMOD_ALWAYSACTIVE85| ATMEL_LCDC_MEMOR_BIG),86.default_monspecs = &hammerhead_hda350t_monspecs,87.guard_time = 2,88};89#endif9091static struct mci_platform_data __initdata mci0_data = {92.slot[0] = {93.bus_width = 4,94.detect_pin = -ENODEV,95.wp_pin = -ENODEV,96},97};9899struct eth_addr {100u8 addr[6];101};102103static struct eth_addr __initdata hw_addr[1];104static struct eth_platform_data __initdata eth_data[1];105106/*107* The next two functions should go away as the boot loader is108* supposed to initialize the macb address registers with a valid109* ethernet address. But we need to keep it around for a while until110* we can be reasonably sure the boot loader does this.111*112* The phy_id is ignored as the driver will probe for it.113*/114static int __init parse_tag_ethernet(struct tag *tag)115{116int i = tag->u.ethernet.mac_index;117118if (i < ARRAY_SIZE(hw_addr))119memcpy(hw_addr[i].addr, tag->u.ethernet.hw_address,120sizeof(hw_addr[i].addr));121122return 0;123}124__tagtable(ATAG_ETHERNET, parse_tag_ethernet);125126static void __init set_hw_addr(struct platform_device *pdev)127{128struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);129const u8 *addr;130void __iomem *regs;131struct clk *pclk;132133if (!res)134return;135136if (pdev->id >= ARRAY_SIZE(hw_addr))137return;138139addr = hw_addr[pdev->id].addr;140141if (!is_valid_ether_addr(addr))142return;143144/*145* Since this is board-specific code, we'll cheat and use the146* physical address directly as we happen to know that it's147* the same as the virtual address.148*/149regs = (void __iomem __force *)res->start;150pclk = clk_get(&pdev->dev, "pclk");151152if (IS_ERR(pclk))153return;154155clk_enable(pclk);156157__raw_writel((addr[3] << 24) | (addr[2] << 16) | (addr[1] << 8) |158addr[0], regs + 0x98);159__raw_writel((addr[5] << 8) | addr[4], regs + 0x9c);160161clk_disable(pclk);162clk_put(pclk);163}164165void __init setup_board(void)166{167at32_map_usart(1, 0, 0); /* USART 1: /dev/ttyS0, DB9 */168at32_setup_serial_console(0);169}170171static struct i2c_gpio_platform_data i2c_gpio_data = {172.sda_pin = GPIO_PIN_PA(6),173.scl_pin = GPIO_PIN_PA(7),174.sda_is_open_drain = 1,175.scl_is_open_drain = 1,176.udelay = 2, /* close to 100 kHz */177};178179static struct platform_device i2c_gpio_device = {180.name = "i2c-gpio",181.id = 0,182.dev = { .platform_data = &i2c_gpio_data, },183};184185static struct i2c_board_info __initdata i2c_info[] = {};186187#ifdef CONFIG_BOARD_HAMMERHEAD_SND188static struct ac97c_platform_data ac97c_data = {189.reset_pin = GPIO_PIN_PA(16),190};191#endif192193static int __init hammerhead_init(void)194{195/*196* Hammerhead uses 32-bit SDRAM interface. Reserve the197* SDRAM-specific pins so that nobody messes with them.198*/199at32_reserve_pin(GPIO_PIOE_BASE, ATMEL_EBI_PE_DATA_ALL);200201at32_add_device_usart(0);202203/* Reserve PB29 (GCLK3). This pin is used as clock source204* for ETH PHY (25MHz). GCLK3 setup is done by U-Boot.205*/206at32_reserve_pin(GPIO_PIOB_BASE, (1<<29));207208/*209* Hammerhead uses only one ethernet port, so we don't set210* address of second port211*/212set_hw_addr(at32_add_device_eth(0, ð_data[0]));213214#ifdef CONFIG_BOARD_HAMMERHEAD_FPGA215at32_add_device_hh_fpga();216#endif217at32_add_device_mci(0, &mci0_data);218219#ifdef CONFIG_BOARD_HAMMERHEAD_USB220at32_add_device_usba(0, NULL);221#endif222#ifdef CONFIG_BOARD_HAMMERHEAD_LCD223at32_add_device_lcdc(0, &hammerhead_lcdc_data, fbmem_start,224fbmem_size, ATMEL_LCDC_PRI_24BIT);225#endif226227at32_select_gpio(i2c_gpio_data.sda_pin,228AT32_GPIOF_MULTIDRV | AT32_GPIOF_OUTPUT |229AT32_GPIOF_HIGH);230at32_select_gpio(i2c_gpio_data.scl_pin,231AT32_GPIOF_MULTIDRV | AT32_GPIOF_OUTPUT |232AT32_GPIOF_HIGH);233platform_device_register(&i2c_gpio_device);234i2c_register_board_info(0, i2c_info, ARRAY_SIZE(i2c_info));235236#ifdef CONFIG_BOARD_HAMMERHEAD_SND237at32_add_device_ac97c(0, &ac97c_data, AC97C_BOTH);238#endif239240/* Select the Touchscreen interrupt pin mode */241at32_select_periph(GPIO_PIOB_BASE, 0x08000000, GPIO_PERIPH_A, 0);242243return 0;244}245246postcore_initcall(hammerhead_init);247248249