blob: e6c0a2287eb8afa0052480d88a5721cbc7665711 [file] [log] [blame]
Daniel Mackacb36552009-03-23 02:04:17 +01001/*
2 * arch/arm/mach-pxa/colibri-pxa3xx.c
3 *
4 * Common functions for all Toradex PXA3xx modules
5 *
6 * Daniel Mack <daniel@caiaq.de>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/init.h>
14#include <linux/kernel.h>
15#include <linux/platform_device.h>
16#include <linux/gpio.h>
Daniel Mack22a02002009-04-02 08:33:14 +020017#include <linux/etherdevice.h>
Daniel Mackacb36552009-03-23 02:04:17 +010018#include <asm/mach-types.h>
19#include <mach/hardware.h>
20#include <asm/sizes.h>
21#include <asm/mach/arch.h>
22#include <asm/mach/irq.h>
23#include <mach/pxa3xx-regs.h>
24#include <mach/mfp-pxa300.h>
25#include <mach/colibri.h>
26#include <mach/mmc.h>
Daniel Mack91fcfb92009-03-23 02:04:19 +010027#include <mach/pxafb.h>
Haojian Zhuang82b95ec2009-09-10 13:55:23 +080028#include <plat/pxa3xx_nand.h>
Daniel Mackacb36552009-03-23 02:04:17 +010029
30#include "generic.h"
31#include "devices.h"
32
Daniel Mack22a02002009-04-02 08:33:14 +020033#if defined(CONFIG_AX88796)
34#define ETHER_ADDR_LEN 6
35static u8 ether_mac_addr[ETHER_ADDR_LEN];
36
37void __init colibri_pxa3xx_init_eth(struct ax_plat_data *plat_data)
38{
39 int i;
40 u64 serial = ((u64) system_serial_high << 32) | system_serial_low;
41
42 /*
43 * If the bootloader passed in a serial boot tag, which contains a
44 * valid ethernet MAC, pass it to the interface. Toradex ships the
45 * modules with their own bootloader which provides a valid MAC
46 * this way.
47 */
48
49 for (i = 0; i < ETHER_ADDR_LEN; i++) {
50 ether_mac_addr[i] = serial & 0xff;
51 serial >>= 8;
52 }
53
54 if (is_valid_ether_addr(ether_mac_addr)) {
55 plat_data->flags |= AXFLG_MAC_FROMPLATFORM;
56 plat_data->mac_addr = ether_mac_addr;
57 printk(KERN_INFO "%s(): taking MAC from serial boot tag\n",
58 __func__);
59 } else {
60 plat_data->flags |= AXFLG_MAC_FROMDEV;
61 printk(KERN_INFO "%s(): no valid serial boot tag found, "
62 "taking MAC from device\n", __func__);
63 }
64}
65#endif
66
Daniel Mackacb36552009-03-23 02:04:17 +010067#if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
68static int mmc_detect_pin;
69
70static int colibri_pxa3xx_mci_init(struct device *dev,
71 irq_handler_t colibri_mmc_detect_int,
72 void *data)
73{
74 int ret;
75
76 ret = gpio_request(mmc_detect_pin, "mmc card detect");
77 if (ret)
78 return ret;
79
80 gpio_direction_input(mmc_detect_pin);
81 ret = request_irq(gpio_to_irq(mmc_detect_pin), colibri_mmc_detect_int,
82 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
83 "MMC card detect", data);
84 if (ret) {
85 gpio_free(mmc_detect_pin);
86 return ret;
87 }
88
89 return 0;
90}
91
92static void colibri_pxa3xx_mci_exit(struct device *dev, void *data)
93{
94 free_irq(mmc_detect_pin, data);
95 gpio_free(gpio_to_irq(mmc_detect_pin));
96}
97
98static struct pxamci_platform_data colibri_pxa3xx_mci_platform_data = {
Robert Jarzmik7a648252009-07-06 22:16:42 +020099 .detect_delay = 20,
100 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
101 .init = colibri_pxa3xx_mci_init,
102 .exit = colibri_pxa3xx_mci_exit,
103 .gpio_card_detect = -1,
104 .gpio_card_ro = -1,
105 .gpio_power = -1,
Daniel Mackacb36552009-03-23 02:04:17 +0100106};
107
108void __init colibri_pxa3xx_init_mmc(mfp_cfg_t *pins, int len, int detect_pin)
109{
110 pxa3xx_mfp_config(pins, len);
111 mmc_detect_pin = detect_pin;
112 pxa_set_mci_info(&colibri_pxa3xx_mci_platform_data);
113}
114#endif /* CONFIG_MMC_PXA || CONFIG_MMC_PXA_MODULE */
115
Daniel Mack91fcfb92009-03-23 02:04:19 +0100116#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
117static int lcd_bl_pin;
118
119/*
120 * LCD panel (Sharp LQ043T3DX02)
121 */
122static void colibri_lcd_backlight(int on)
123{
124 gpio_set_value(lcd_bl_pin, !!on);
125}
126
127static struct pxafb_mode_info sharp_lq43_mode = {
128 .pixclock = 101936,
129 .xres = 480,
130 .yres = 272,
131 .bpp = 32,
132 .depth = 18,
133 .hsync_len = 41,
134 .left_margin = 2,
135 .right_margin = 2,
136 .vsync_len = 10,
137 .upper_margin = 2,
138 .lower_margin = 2,
139 .sync = 0,
140 .cmap_greyscale = 0,
141};
142
143static struct pxafb_mach_info sharp_lq43_info = {
144 .modes = &sharp_lq43_mode,
145 .num_modes = 1,
146 .cmap_inverse = 0,
147 .cmap_static = 0,
148 .lcd_conn = LCD_COLOR_TFT_18BPP,
149 .pxafb_backlight_power = colibri_lcd_backlight,
150};
151
152void __init colibri_pxa3xx_init_lcd(int bl_pin)
153{
154 lcd_bl_pin = bl_pin;
155 gpio_request(bl_pin, "lcd backlight");
156 gpio_direction_output(bl_pin, 0);
157 set_pxa_fb_info(&sharp_lq43_info);
158}
159#endif
160
Daniel Mack53740df2009-06-17 10:32:54 +0200161#if defined(CONFIG_MTD_NAND_PXA3xx) || defined(CONFIG_MTD_NAND_PXA3xx_MODULE)
162static struct mtd_partition colibri_nand_partitions[] = {
163 {
164 .name = "bootloader",
165 .offset = 0,
166 .size = SZ_512K,
167 .mask_flags = MTD_WRITEABLE, /* force read-only */
168 },
169 {
170 .name = "kernel",
171 .offset = MTDPART_OFS_APPEND,
172 .size = SZ_4M,
173 .mask_flags = MTD_WRITEABLE, /* force read-only */
174 },
175 {
176 .name = "reserved",
177 .offset = MTDPART_OFS_APPEND,
178 .size = SZ_1M,
179 .mask_flags = MTD_WRITEABLE, /* force read-only */
180 },
181 {
182 .name = "fs",
183 .offset = MTDPART_OFS_APPEND,
184 .size = MTDPART_SIZ_FULL,
185 },
186};
187
188static struct pxa3xx_nand_platform_data colibri_nand_info = {
189 .enable_arbiter = 1,
190 .keep_config = 1,
191 .parts = colibri_nand_partitions,
192 .nr_parts = ARRAY_SIZE(colibri_nand_partitions),
193};
194
195void __init colibri_pxa3xx_init_nand(void)
196{
197 pxa3xx_set_nand_info(&colibri_nand_info);
198}
199#endif
200