2 * Board-specific setup code for the Miromico Hammerhead board
4 * Copyright (C) 2008 Miromico AG
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/atmel-mci.h>
11 #include <linux/clk.h>
13 #include <linux/etherdevice.h>
14 #include <linux/i2c.h>
15 #include <linux/i2c-gpio.h>
16 #include <linux/init.h>
17 #include <linux/linkage.h>
18 #include <linux/platform_device.h>
19 #include <linux/types.h>
20 #include <linux/spi/spi.h>
22 #include <video/atmel_lcdc.h>
25 #include <asm/setup.h>
27 #include <mach/at32ap700x.h>
28 #include <mach/board.h>
29 #include <mach/init.h>
30 #include <mach/portmux.h>
32 #include "../../mach-at32ap/clock.h"
35 /* Oscillator frequencies. These are board-specific */
36 unsigned long at32_board_osc_rates[3] = {
37 [0] = 32768, /* 32.768 kHz on RTC osc */
38 [1] = 25000000, /* 25MHz on osc0 */
39 [2] = 12000000, /* 12 MHz on osc1 */
42 /* Initialized by bootloader-specific startup code. */
43 struct tag *bootloader_tags __initdata;
45 #ifdef CONFIG_BOARD_HAMMERHEAD_LCD
46 static struct fb_videomode __initdata hda350tlv_modes[] = {
48 .name = "320x240 @ 75",
52 .pixclock = KHZ2PICOS(6891),
62 .vmode = FB_VMODE_NONINTERLACED,
66 static struct fb_monspecs __initdata hammerhead_hda350t_monspecs = {
67 .manufacturer = "HAN",
68 .monitor = "HDA350T-LV",
69 .modedb = hda350tlv_modes,
70 .modedb_len = ARRAY_SIZE(hda350tlv_modes),
78 struct atmel_lcdfb_info __initdata hammerhead_lcdc_data = {
80 .default_dmacon = ATMEL_LCDC_DMAEN | ATMEL_LCDC_DMA2DEN,
81 .default_lcdcon2 = (ATMEL_LCDC_DISTYPE_TFT
83 | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE
84 | ATMEL_LCDC_MEMOR_BIG),
85 .default_monspecs = &hammerhead_hda350t_monspecs,
90 static struct mci_platform_data __initdata mci0_data = {
93 .detect_pin = -ENODEV,
102 static struct eth_addr __initdata hw_addr[1];
103 static struct eth_platform_data __initdata eth_data[1];
106 * The next two functions should go away as the boot loader is
107 * supposed to initialize the macb address registers with a valid
108 * ethernet address. But we need to keep it around for a while until
109 * we can be reasonably sure the boot loader does this.
111 * The phy_id is ignored as the driver will probe for it.
113 static int __init parse_tag_ethernet(struct tag *tag)
115 int i = tag->u.ethernet.mac_index;
117 if (i < ARRAY_SIZE(hw_addr))
118 memcpy(hw_addr[i].addr, tag->u.ethernet.hw_address,
119 sizeof(hw_addr[i].addr));
123 __tagtable(ATAG_ETHERNET, parse_tag_ethernet);
125 static void __init set_hw_addr(struct platform_device *pdev)
127 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
135 if (pdev->id >= ARRAY_SIZE(hw_addr))
138 addr = hw_addr[pdev->id].addr;
140 if (!is_valid_ether_addr(addr))
144 * Since this is board-specific code, we'll cheat and use the
145 * physical address directly as we happen to know that it's
146 * the same as the virtual address.
148 regs = (void __iomem __force *)res->start;
149 pclk = clk_get(&pdev->dev, "pclk");
156 __raw_writel((addr[3] << 24) | (addr[2] << 16) | (addr[1] << 8) |
157 addr[0], regs + 0x98);
158 __raw_writel((addr[5] << 8) | addr[4], regs + 0x9c);
164 void __init setup_board(void)
166 at32_map_usart(1, 0); /* USART 1: /dev/ttyS0, DB9 */
167 at32_setup_serial_console(0);
170 static struct i2c_gpio_platform_data i2c_gpio_data = {
171 .sda_pin = GPIO_PIN_PA(6),
172 .scl_pin = GPIO_PIN_PA(7),
173 .sda_is_open_drain = 1,
174 .scl_is_open_drain = 1,
175 .udelay = 2, /* close to 100 kHz */
178 static struct platform_device i2c_gpio_device = {
181 .dev = { .platform_data = &i2c_gpio_data, },
184 static struct i2c_board_info __initdata i2c_info[] = {};
186 #ifdef CONFIG_BOARD_HAMMERHEAD_SND
187 static struct ac97c_platform_data ac97c_data = {
188 .reset_pin = GPIO_PIN_PA(16),
192 static int __init hammerhead_init(void)
195 * Hammerhead uses 32-bit SDRAM interface. Reserve the
196 * SDRAM-specific pins so that nobody messes with them.
198 at32_reserve_pin(GPIO_PIOE_BASE, ATMEL_EBI_PE_DATA_ALL);
200 at32_add_device_usart(0);
202 /* Reserve PB29 (GCLK3). This pin is used as clock source
203 * for ETH PHY (25MHz). GCLK3 setup is done by U-Boot.
205 at32_reserve_pin(GPIO_PIOB_BASE, (1<<29));
208 * Hammerhead uses only one ethernet port, so we don't set
209 * address of second port
211 set_hw_addr(at32_add_device_eth(0, ð_data[0]));
213 #ifdef CONFIG_BOARD_HAMMERHEAD_FPGA
214 at32_add_device_hh_fpga();
216 at32_add_device_mci(0, &mci0_data);
218 #ifdef CONFIG_BOARD_HAMMERHEAD_USB
219 at32_add_device_usba(0, NULL);
221 #ifdef CONFIG_BOARD_HAMMERHEAD_LCD
222 at32_add_device_lcdc(0, &hammerhead_lcdc_data, fbmem_start,
223 fbmem_size, ATMEL_LCDC_PRI_24BIT);
226 at32_select_gpio(i2c_gpio_data.sda_pin,
227 AT32_GPIOF_MULTIDRV | AT32_GPIOF_OUTPUT |
229 at32_select_gpio(i2c_gpio_data.scl_pin,
230 AT32_GPIOF_MULTIDRV | AT32_GPIOF_OUTPUT |
232 platform_device_register(&i2c_gpio_device);
233 i2c_register_board_info(0, i2c_info, ARRAY_SIZE(i2c_info));
235 #ifdef CONFIG_BOARD_HAMMERHEAD_SND
236 at32_add_device_ac97c(0, &ac97c_data);
239 /* Select the Touchscreen interrupt pin mode */
240 at32_select_periph(GPIO_PIOB_BASE, 0x08000000, GPIO_PERIPH_A, 0);
245 postcore_initcall(hammerhead_init);