2 * Board-specific setup code for the MIMC200
4 * Copyright (C) 2008 Mercury IMC Ltd
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.
11 extern struct atmel_lcdfb_info mimc200_lcdc_data
;
13 #include <linux/clk.h>
14 #include <linux/etherdevice.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/leds.h>
21 #include <linux/spi/spi.h>
22 #include <linux/spi/eeprom.h>
24 #include <video/atmel_lcdc.h>
27 #include <linux/atmel-mci.h>
29 #include <asm/setup.h>
31 #include <mach/at32ap700x.h>
32 #include <mach/board.h>
33 #include <mach/init.h>
34 #include <mach/portmux.h>
36 /* Oscillator frequencies. These are board-specific */
37 unsigned long at32_board_osc_rates
[3] = {
38 [0] = 32768, /* 32.768 kHz on RTC osc */
39 [1] = 10000000, /* 10 MHz on osc0 */
40 [2] = 12000000, /* 12 MHz on osc1 */
43 /* Initialized by bootloader-specific startup code. */
44 struct tag
*bootloader_tags __initdata
;
46 static struct fb_videomode __initdata tx14d14_modes
[] = {
48 .name
= "640x480 @ 60",
50 .xres
= 640, .yres
= 480,
51 .pixclock
= KHZ2PICOS(11666),
53 .left_margin
= 80, .right_margin
= 1,
54 .upper_margin
= 13, .lower_margin
= 2,
55 .hsync_len
= 64, .vsync_len
= 1,
58 .vmode
= FB_VMODE_NONINTERLACED
,
62 static struct fb_monspecs __initdata mimc200_default_monspecs
= {
63 .manufacturer
= "HIT",
64 .monitor
= "TX14D14VM1BAB",
65 .modedb
= tx14d14_modes
,
66 .modedb_len
= ARRAY_SIZE(tx14d14_modes
),
74 struct atmel_lcdfb_info __initdata mimc200_lcdc_data
= {
76 .default_dmacon
= ATMEL_LCDC_DMAEN
| ATMEL_LCDC_DMA2DEN
,
77 .default_lcdcon2
= (ATMEL_LCDC_DISTYPE_TFT
79 | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE
80 | ATMEL_LCDC_MEMOR_BIG
),
81 .default_monspecs
= &mimc200_default_monspecs
,
88 static struct eth_addr __initdata hw_addr
[2];
89 static struct eth_platform_data __initdata eth_data
[2];
91 static struct spi_eeprom eeprom_25lc010
= {
98 static struct spi_board_info spi0_board_info
[] __initdata
= {
100 .modalias
= "rtc-ds1390",
101 .max_speed_hz
= 4000000,
106 .max_speed_hz
= 1000000,
109 .platform_data
= &eeprom_25lc010
,
113 static struct mci_platform_data __initdata mci0_data
= {
116 .detect_pin
= GPIO_PIN_PA(26),
117 .wp_pin
= GPIO_PIN_PA(27),
122 * The next two functions should go away as the boot loader is
123 * supposed to initialize the macb address registers with a valid
124 * ethernet address. But we need to keep it around for a while until
125 * we can be reasonably sure the boot loader does this.
127 * The phy_id is ignored as the driver will probe for it.
129 static int __init
parse_tag_ethernet(struct tag
*tag
)
133 i
= tag
->u
.ethernet
.mac_index
;
134 if (i
< ARRAY_SIZE(hw_addr
))
135 memcpy(hw_addr
[i
].addr
, tag
->u
.ethernet
.hw_address
,
136 sizeof(hw_addr
[i
].addr
));
140 __tagtable(ATAG_ETHERNET
, parse_tag_ethernet
);
142 static void __init
set_hw_addr(struct platform_device
*pdev
)
144 struct resource
*res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
151 if (pdev
->id
>= ARRAY_SIZE(hw_addr
))
154 addr
= hw_addr
[pdev
->id
].addr
;
155 if (!is_valid_ether_addr(addr
))
159 * Since this is board-specific code, we'll cheat and use the
160 * physical address directly as we happen to know that it's
161 * the same as the virtual address.
163 regs
= (void __iomem __force
*)res
->start
;
164 pclk
= clk_get(&pdev
->dev
, "pclk");
169 __raw_writel((addr
[3] << 24) | (addr
[2] << 16)
170 | (addr
[1] << 8) | addr
[0], regs
+ 0x98);
171 __raw_writel((addr
[5] << 8) | addr
[4], regs
+ 0x9c);
176 void __init
setup_board(void)
178 at32_map_usart(0, 0); /* USART 0: /dev/ttyS0 (TTL --> Altera) */
179 at32_map_usart(1, 1); /* USART 1: /dev/ttyS1 (RS232) */
180 at32_map_usart(2, 2); /* USART 2: /dev/ttyS2 (RS485) */
181 at32_map_usart(3, 3); /* USART 3: /dev/ttyS3 (RS422 Multidrop) */
184 static struct i2c_gpio_platform_data i2c_gpio_data
= {
185 .sda_pin
= GPIO_PIN_PA(6),
186 .scl_pin
= GPIO_PIN_PA(7),
187 .sda_is_open_drain
= 1,
188 .scl_is_open_drain
= 1,
189 .udelay
= 2, /* close to 100 kHz */
192 static struct platform_device i2c_gpio_device
= {
196 .platform_data
= &i2c_gpio_data
,
200 static struct i2c_board_info __initdata i2c_info
[] = {
203 static int __init
mimc200_init(void)
206 * MIMC200 uses 16-bit SDRAM interface, so we don't need to
207 * reserve any pins for it.
210 at32_add_device_usart(0);
211 at32_add_device_usart(1);
212 at32_add_device_usart(2);
213 at32_add_device_usart(3);
215 set_hw_addr(at32_add_device_eth(0, ð_data
[0]));
216 set_hw_addr(at32_add_device_eth(1, ð_data
[1]));
218 at32_add_device_spi(0, spi0_board_info
, ARRAY_SIZE(spi0_board_info
));
219 at32_add_device_mci(0, &mci0_data
);
220 at32_add_device_usba(0, NULL
);
222 at32_select_periph(GPIO_PIOB_BASE
, 1 << 28, 0, AT32_GPIOF_PULLUP
);
223 at32_select_gpio(i2c_gpio_data
.sda_pin
,
224 AT32_GPIOF_MULTIDRV
| AT32_GPIOF_OUTPUT
| AT32_GPIOF_HIGH
);
225 at32_select_gpio(i2c_gpio_data
.scl_pin
,
226 AT32_GPIOF_MULTIDRV
| AT32_GPIOF_OUTPUT
| AT32_GPIOF_HIGH
);
227 platform_device_register(&i2c_gpio_device
);
228 i2c_register_board_info(0, i2c_info
, ARRAY_SIZE(i2c_info
));
230 at32_add_device_lcdc(0, &mimc200_lcdc_data
,
231 fbmem_start
, fbmem_size
, 1);
235 postcore_initcall(mimc200_init
);