aboutsummaryrefslogtreecommitdiffstats
path: root/arch/avr32/boards
diff options
context:
space:
mode:
authorJonas Larsson <jonas.larsson@martinsson.se>2009-03-27 05:18:14 -0400
committerHaavard Skinnemoen <haavard.skinnemoen@atmel.com>2009-03-27 10:02:34 -0400
commita16fffdd8eb95ebab7dc22414896fe6493951e0e (patch)
tree242e481f52bf05a684b362eeba8a1c5095ed6713 /arch/avr32/boards
parent9477ab2b2ae098423af2ed4fb1f7b864abfc14fc (diff)
Add Merisc board support
Merisc is the family name for a range of AVR32-based boards. The boards are designed to be used in a man-machine interfacing environment, utilizing a touch-based graphical user interface. They host a vast range of I/O peripherals as well as a large SDRAM & Flash memory bank. For more information see: http://www.martinsson.se/merisc Signed-off-by: Jonas Larsson <jonas.larsson@martinsson.se> Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
Diffstat (limited to 'arch/avr32/boards')
-rw-r--r--arch/avr32/boards/merisc/Kconfig5
-rw-r--r--arch/avr32/boards/merisc/Makefile1
-rw-r--r--arch/avr32/boards/merisc/display.c65
-rw-r--r--arch/avr32/boards/merisc/flash.c139
-rw-r--r--arch/avr32/boards/merisc/merisc.h18
-rw-r--r--arch/avr32/boards/merisc/merisc_sysfs.c65
-rw-r--r--arch/avr32/boards/merisc/setup.c289
7 files changed, 582 insertions, 0 deletions
diff --git a/arch/avr32/boards/merisc/Kconfig b/arch/avr32/boards/merisc/Kconfig
new file mode 100644
index 000000000000..7e043275d5a9
--- /dev/null
+++ b/arch/avr32/boards/merisc/Kconfig
@@ -0,0 +1,5 @@
1# Merisc customization
2
3if BOARD_MERISC
4
5endif # BOARD_MERISC
diff --git a/arch/avr32/boards/merisc/Makefile b/arch/avr32/boards/merisc/Makefile
new file mode 100644
index 000000000000..d24c78729bd1
--- /dev/null
+++ b/arch/avr32/boards/merisc/Makefile
@@ -0,0 +1 @@
obj-y += setup.o flash.o display.o merisc_sysfs.o
diff --git a/arch/avr32/boards/merisc/display.c b/arch/avr32/boards/merisc/display.c
new file mode 100644
index 000000000000..85a543cd4abc
--- /dev/null
+++ b/arch/avr32/boards/merisc/display.c
@@ -0,0 +1,65 @@
1/*
2 * Display setup code for the Merisc board
3 *
4 * Copyright (C) 2008 Martinsson Elektronik AB
5 *
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.
9 */
10#include <linux/init.h>
11#include <linux/platform_device.h>
12#include <linux/fb.h>
13#include <video/atmel_lcdc.h>
14#include <asm/setup.h>
15#include <mach/board.h>
16#include "merisc.h"
17
18static struct fb_videomode merisc_fb_videomode[] = {
19 {
20 .refresh = 44,
21 .xres = 640,
22 .yres = 480,
23 .left_margin = 96,
24 .right_margin = 96,
25 .upper_margin = 34,
26 .lower_margin = 8,
27 .hsync_len = 64,
28 .vsync_len = 64,
29 .name = "640x480 @ 44",
30 .pixclock = KHZ2PICOS(25180),
31 .sync = 0,
32 .vmode = FB_VMODE_NONINTERLACED,
33 },
34};
35
36static struct fb_monspecs merisc_fb_monspecs = {
37 .manufacturer = "Kyo",
38 .monitor = "TCG075VG2AD",
39 .modedb = merisc_fb_videomode,
40 .modedb_len = ARRAY_SIZE(merisc_fb_videomode),
41 .hfmin = 30000,
42 .hfmax = 33333,
43 .vfmin = 60,
44 .vfmax = 90,
45 .dclkmax = 30000000,
46};
47
48struct atmel_lcdfb_info merisc_lcdc_data = {
49 .default_bpp = 24,
50 .default_dmacon = ATMEL_LCDC_DMAEN | ATMEL_LCDC_DMA2DEN,
51 .default_lcdcon2 = (ATMEL_LCDC_DISTYPE_TFT
52 | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE
53 | ATMEL_LCDC_MEMOR_BIG),
54 .default_monspecs = &merisc_fb_monspecs,
55 .guard_time = 2,
56};
57
58static int __init merisc_display_init(void)
59{
60 at32_add_device_lcdc(0, &merisc_lcdc_data, fbmem_start,
61 fbmem_size, 0);
62
63 return 0;
64}
65device_initcall(merisc_display_init);
diff --git a/arch/avr32/boards/merisc/flash.c b/arch/avr32/boards/merisc/flash.c
new file mode 100644
index 000000000000..8e856fd6f013
--- /dev/null
+++ b/arch/avr32/boards/merisc/flash.c
@@ -0,0 +1,139 @@
1/*
2 * Merisc board-specific flash initialization
3 *
4 * Copyright (C) 2008 Martinsson Elektronik AB
5 *
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.
9 */
10#include <linux/init.h>
11#include <linux/platform_device.h>
12#include <linux/mtd/mtd.h>
13#include <linux/mtd/partitions.h>
14#include <linux/mtd/physmap.h>
15#include <mach/smc.h>
16
17/* Will be translated to units of 14.3 ns, rounded up */
18static struct smc_timing flash_timing __initdata = {
19 .ncs_read_setup = 1 * 14,
20 .nrd_setup = 5 * 14,
21 .ncs_write_setup = 1 * 14,
22 .nwe_setup = 2 * 14,
23
24 .ncs_read_pulse = 12 * 14,
25 .nrd_pulse = 7 * 14,
26 .ncs_write_pulse = 8 * 14,
27 .nwe_pulse = 4 * 14,
28
29 .read_cycle = 14 * 14,
30 .write_cycle = 10 * 14,
31};
32
33static struct smc_config flash_config __initdata = {
34 .bus_width = 2,
35 .nrd_controlled = 1,
36 .nwe_controlled = 1,
37 .byte_write = 1,
38 .tdf_cycles = 3,
39};
40
41static struct mtd_partition flash_0_parts[] = {
42 {
43 .name = "boot",
44 .offset = 0x00000000,
45 .size = 0x00060000,
46 .mask_flags = 0,
47 },
48 {
49 .name = "kernel",
50 .offset = 0x00060000,
51 .size = 0x00200000,
52 .mask_flags = 0,
53 },
54 {
55 .name = "root",
56 .offset = 0x00260000,
57 .size = MTDPART_SIZ_FULL,
58 .mask_flags = 0,
59 },
60};
61
62static struct mtd_partition flash_1_parts[] = {
63 {
64 .name = "2ndflash",
65 .offset = 0x00000000,
66 .size = MTDPART_SIZ_FULL,
67 .mask_flags = 0,
68 },
69};
70
71static struct physmap_flash_data flash_data[] = {
72 {
73 .width = 2,
74 .nr_parts = ARRAY_SIZE(flash_0_parts),
75 .parts = flash_0_parts,
76 },
77 {
78 .width = 2,
79 .nr_parts = ARRAY_SIZE(flash_1_parts),
80 .parts = flash_1_parts,
81 }
82};
83
84static struct resource flash_resource[] = {
85 {
86 .start = 0x00000000,
87 .end = 0x03ffffff,
88 .flags = IORESOURCE_MEM,
89 },
90 {
91 .start = 0x04000000,
92 .end = 0x07ffffff,
93 .flags = IORESOURCE_MEM,
94 },
95};
96
97static struct platform_device flash_device[] = {
98 {
99 .name = "physmap-flash",
100 .id = 0,
101 .resource = &flash_resource[0],
102 .num_resources = 1,
103 .dev = {
104 .platform_data = &flash_data[0],
105 },
106 },
107 {
108 .name = "physmap-flash",
109 .id = 1,
110 .resource = &flash_resource[1],
111 .num_resources = 1,
112 .dev = {
113 .platform_data = &flash_data[1],
114 },
115 },
116};
117
118static int __init merisc_flash_init(void)
119{
120 int ret;
121 smc_set_timing(&flash_config, &flash_timing);
122
123 ret = smc_set_configuration(0, &flash_config);
124 if (ret < 0) {
125 printk(KERN_ERR "Merisc: failed to set NOR flash timing #0\n");
126 return ret;
127 }
128
129 ret = smc_set_configuration(4, &flash_config);
130 if (ret < 0) {
131 printk(KERN_ERR "Merisc: failed to set NOR flash timing #1\n");
132 return ret;
133 }
134
135 platform_device_register(&flash_device[0]);
136 platform_device_register(&flash_device[1]);
137 return 0;
138}
139device_initcall(merisc_flash_init);
diff --git a/arch/avr32/boards/merisc/merisc.h b/arch/avr32/boards/merisc/merisc.h
new file mode 100644
index 000000000000..50ffb2f3fcbf
--- /dev/null
+++ b/arch/avr32/boards/merisc/merisc.h
@@ -0,0 +1,18 @@
1/*
2 * Merisc exports
3 *
4 * Copyright (C) 2008 Martinsson Elektronik AB
5 *
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.
9 */
10#ifndef __ARCH_AVR32_BOARDS_MERISC_MERISC_H
11#define __ARCH_AVR32_BOARDS_MERISC_MERISC_H
12
13const char *merisc_revision(void);
14const char *merisc_model(void);
15
16extern struct class merisc_class;
17
18#endif /* __ARCH_AVR32_BOARDS_MERISC_MERISC_H */
diff --git a/arch/avr32/boards/merisc/merisc_sysfs.c b/arch/avr32/boards/merisc/merisc_sysfs.c
new file mode 100644
index 000000000000..df431fdba9ad
--- /dev/null
+++ b/arch/avr32/boards/merisc/merisc_sysfs.c
@@ -0,0 +1,65 @@
1/*
2 * Merisc sysfs exports
3 *
4 * Copyright (C) 2008 Martinsson Elektronik AB
5 *
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.
9 */
10#include <linux/module.h>
11#include <linux/kernel.h>
12#include <linux/init.h>
13#include <linux/list.h>
14#include <linux/spinlock.h>
15#include <linux/device.h>
16#include <linux/sysdev.h>
17#include <linux/timer.h>
18#include <linux/err.h>
19#include <linux/ctype.h>
20#include "merisc.h"
21
22static ssize_t merisc_model_show(struct class *class, char *buf)
23{
24 ssize_t ret = 0;
25
26 sprintf(buf, "%s\n", merisc_model());
27 ret = strlen(buf) + 1;
28
29 return ret;
30}
31
32static ssize_t merisc_revision_show(struct class *class, char *buf)
33{
34 ssize_t ret = 0;
35
36 sprintf(buf, "%s\n", merisc_revision());
37 ret = strlen(buf) + 1;
38
39 return ret;
40}
41
42static struct class_attribute merisc_class_attrs[] = {
43 __ATTR(model, S_IRUGO, merisc_model_show, NULL),
44 __ATTR(revision, S_IRUGO, merisc_revision_show, NULL),
45 __ATTR_NULL,
46};
47
48struct class merisc_class = {
49 .name = "merisc",
50 .owner = THIS_MODULE,
51 .class_attrs = merisc_class_attrs,
52};
53
54static int __init merisc_sysfs_init(void)
55{
56 int status;
57
58 status = class_register(&merisc_class);
59 if (status < 0)
60 return status;
61
62 return 0;
63}
64
65postcore_initcall(merisc_sysfs_init);
diff --git a/arch/avr32/boards/merisc/setup.c b/arch/avr32/boards/merisc/setup.c
new file mode 100644
index 000000000000..2dbca46337af
--- /dev/null
+++ b/arch/avr32/boards/merisc/setup.c
@@ -0,0 +1,289 @@
1/*
2 * Board-specific setup code for the Merisc
3 *
4 * Copyright (C) 2008 Martinsson Elektronik AB
5 *
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.
9 */
10#include <linux/clk.h>
11#include <linux/etherdevice.h>
12#include <linux/i2c.h>
13#include <linux/i2c-gpio.h>
14#include <linux/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/leds.h>
20#include <linux/spi/spi.h>
21#include <linux/spi/ads7846.h>
22#include <linux/irq.h>
23#include <linux/fb.h>
24#include <linux/atmel-mci.h>
25
26#include <asm/io.h>
27#include <asm/setup.h>
28#include <asm/gpio.h>
29
30#include <mach/at32ap700x.h>
31#include <mach/board.h>
32#include <mach/init.h>
33#include <mach/portmux.h>
34
35#include "merisc.h"
36
37/* Holds the autodetected board model and revision */
38static int merisc_board_id;
39
40/* Initialized by bootloader-specific startup code. */
41struct tag *bootloader_tags __initdata;
42
43/* Oscillator frequencies. These are board specific */
44unsigned long at32_board_osc_rates[3] = {
45 [0] = 32768, /* 32.768 kHz on RTC osc */
46 [1] = 20000000, /* 20 MHz on osc0 */
47 [2] = 12000000, /* 12 MHz on osc1 */
48};
49
50struct eth_addr {
51 u8 addr[6];
52};
53
54static struct eth_addr __initdata hw_addr[2];
55static struct eth_platform_data __initdata eth_data[2];
56
57static int ads7846_get_pendown_state_PB26(void)
58{
59 return !gpio_get_value(GPIO_PIN_PB(26));
60}
61
62static int ads7846_get_pendown_state_PB28(void)
63{
64 return !gpio_get_value(GPIO_PIN_PB(28));
65}
66
67static struct ads7846_platform_data __initdata ads7846_data = {
68 .model = 7846,
69 .vref_delay_usecs = 100,
70 .vref_mv = 0,
71 .keep_vref_on = 0,
72 .settle_delay_usecs = 150,
73 .penirq_recheck_delay_usecs = 1,
74 .x_plate_ohms = 800,
75 .debounce_rep = 4,
76 .debounce_max = 10,
77 .debounce_tol = 50,
78 .get_pendown_state = ads7846_get_pendown_state_PB26,
79 .filter_init = NULL,
80 .filter = NULL,
81 .filter_cleanup = NULL,
82};
83
84static struct spi_board_info __initdata spi0_board_info[] = {
85 {
86 .modalias = "ads7846",
87 .max_speed_hz = 3250000,
88 .chip_select = 0,
89 .bus_num = 0,
90 .platform_data = &ads7846_data,
91 .mode = SPI_MODE_0,
92 },
93};
94
95static struct mci_platform_data __initdata mci0_data = {
96 .slot[0] = {
97 .bus_width = 4,
98 .detect_pin = GPIO_PIN_PE(19),
99 .wp_pin = GPIO_PIN_PE(20),
100 },
101};
102
103static int __init parse_tag_ethernet(struct tag *tag)
104{
105 int i;
106
107 i = tag->u.ethernet.mac_index;
108 if (i < ARRAY_SIZE(hw_addr)) {
109 memcpy(hw_addr[i].addr, tag->u.ethernet.hw_address,
110 sizeof(hw_addr[i].addr));
111 }
112
113 return 0;
114}
115__tagtable(ATAG_ETHERNET, parse_tag_ethernet);
116
117static void __init set_hw_addr(struct platform_device *pdev)
118{
119 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
120 const u8 *addr;
121 void __iomem *regs;
122 struct clk *pclk;
123
124 if (!res)
125 return;
126
127 if (pdev->id >= ARRAY_SIZE(hw_addr))
128 return;
129
130 addr = hw_addr[pdev->id].addr;
131 if (!is_valid_ether_addr(addr))
132 return;
133
134 regs = (void __iomem __force *)res->start;
135 pclk = clk_get(&pdev->dev, "pclk");
136 if (!pclk)
137 return;
138
139 clk_enable(pclk);
140 __raw_writel((addr[3] << 24) | (addr[2] << 16)
141 | (addr[1] << 8) | addr[0], regs + 0x98);
142 __raw_writel((addr[5] << 8) | addr[4], regs + 0x9c);
143 clk_disable(pclk);
144 clk_put(pclk);
145}
146
147static struct i2c_gpio_platform_data i2c_gpio_data = {
148 .sda_pin = GPIO_PIN_PA(6),
149 .scl_pin = GPIO_PIN_PA(7),
150 .sda_is_open_drain = 1,
151 .scl_is_open_drain = 1,
152 .udelay = 2,
153};
154
155static struct platform_device i2c_gpio_device = {
156 .name = "i2c-gpio",
157 .id = 0,
158 .dev = {
159 .platform_data = &i2c_gpio_data,
160 },
161};
162
163#ifdef CONFIG_LEDS_ATMEL_PWM
164static struct gpio_led stk_pwm_led[] = {
165 {
166 .name = "backlight",
167 .gpio = 0, /* PWM channel 0 (LCD backlight) */
168 },
169};
170
171static struct gpio_led_platform_data stk_pwm_led_data = {
172 .num_leds = ARRAY_SIZE(stk_pwm_led),
173 .leds = stk_pwm_led,
174};
175
176static struct platform_device stk_pwm_led_dev = {
177 .name = "leds-atmel-pwm",
178 .id = -1,
179 .dev = {
180 .platform_data = &stk_pwm_led_data,
181 },
182};
183#endif
184
185const char *merisc_model(void)
186{
187 switch (merisc_board_id) {
188 case 0:
189 case 1:
190 return "500-01";
191 case 2:
192 return "BT";
193 default:
194 return "Unknown";
195 }
196}
197
198const char *merisc_revision(void)
199{
200 switch (merisc_board_id) {
201 case 0:
202 return "B";
203 case 1:
204 return "D";
205 case 2:
206 return "A";
207 default:
208 return "Unknown";
209 }
210}
211
212static void detect_merisc_board_id(void)
213{
214 /* Board ID pins MUST be set as input or the board may be damaged */
215 at32_select_gpio(GPIO_PIN_PA(24), AT32_GPIOF_PULLUP);
216 at32_select_gpio(GPIO_PIN_PA(25), AT32_GPIOF_PULLUP);
217 at32_select_gpio(GPIO_PIN_PA(26), AT32_GPIOF_PULLUP);
218 at32_select_gpio(GPIO_PIN_PA(27), AT32_GPIOF_PULLUP);
219
220 merisc_board_id = !gpio_get_value(GPIO_PIN_PA(24)) +
221 !gpio_get_value(GPIO_PIN_PA(25)) * 2 +
222 !gpio_get_value(GPIO_PIN_PA(26)) * 4 +
223 !gpio_get_value(GPIO_PIN_PA(27)) * 8;
224}
225
226void __init setup_board(void)
227{
228 at32_map_usart(0, 0);
229 at32_map_usart(1, 1);
230 at32_map_usart(3, 3);
231 at32_setup_serial_console(1);
232}
233
234static int __init merisc_init(void)
235{
236 detect_merisc_board_id();
237
238 printk(KERN_NOTICE "BOARD: Merisc %s revision %s\n", merisc_model(),
239 merisc_revision());
240
241 /* Reserve pins for SDRAM */
242 at32_reserve_pin(GPIO_PIOE_BASE, ATMEL_EBI_PE_DATA_ALL | (1 << 26));
243
244 if (merisc_board_id >= 1)
245 at32_map_usart(2, 2);
246
247 at32_add_device_usart(0);
248 at32_add_device_usart(1);
249 if (merisc_board_id >= 1)
250 at32_add_device_usart(2);
251 at32_add_device_usart(3);
252 set_hw_addr(at32_add_device_eth(0, &eth_data[0]));
253
254 /* ADS7846 PENIRQ */
255 if (merisc_board_id == 0) {
256 ads7846_data.get_pendown_state = ads7846_get_pendown_state_PB26;
257 at32_select_periph(GPIO_PIOB_BASE, 1 << 26,
258 GPIO_PERIPH_A, AT32_GPIOF_PULLUP);
259 spi0_board_info[0].irq = AT32_EXTINT(1);
260 } else {
261 ads7846_data.get_pendown_state = ads7846_get_pendown_state_PB28;
262 at32_select_periph(GPIO_PIOB_BASE, 1 << 28, GPIO_PERIPH_A,
263 AT32_GPIOF_PULLUP);
264 spi0_board_info[0].irq = AT32_EXTINT(3);
265 }
266
267 /* ADS7846 busy pin */
268 at32_select_gpio(GPIO_PIN_PA(4), AT32_GPIOF_PULLUP);
269
270 at32_add_device_spi(0, spi0_board_info, ARRAY_SIZE(spi0_board_info));
271
272 at32_add_device_mci(0, &mci0_data);
273
274#ifdef CONFIG_LEDS_ATMEL_PWM
275 at32_add_device_pwm((1 << 0) | (1 << 2));
276 platform_device_register(&stk_pwm_led_dev);
277#else
278 at32_add_device_pwm((1 << 2));
279#endif
280
281 at32_select_gpio(i2c_gpio_data.sda_pin,
282 AT32_GPIOF_MULTIDRV | AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
283 at32_select_gpio(i2c_gpio_data.scl_pin,
284 AT32_GPIOF_MULTIDRV | AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
285 platform_device_register(&i2c_gpio_device);
286
287 return 0;
288}
289postcore_initcall(merisc_init);