1 /*
2  * linux/arch/arm/mach-pxa/income.c
3  *
4  * Support for Income s.r.o. SH-Dmaster PXA270 SBC
5  *
6  * Copyright (C) 2010
7  * Marek Vasut <marek.vasut@gmail.com>
8  * Pavel Revak <palo@bielyvlk.sk>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License version 2 as
12  * published by the Free Software Foundation.
13  */
14 
15 #include <linux/bitops.h>
16 #include <linux/delay.h>
17 #include <linux/gpio.h>
18 #include <linux/init.h>
19 #include <linux/interrupt.h>
20 #include <linux/ioport.h>
21 #include <linux/kernel.h>
22 #include <linux/platform_device.h>
23 #include <linux/pwm_backlight.h>
24 #include <linux/i2c/pxa-i2c.h>
25 #include <linux/sysdev.h>
26 
27 #include <asm/irq.h>
28 #include <asm/mach-types.h>
29 
30 #include <mach/hardware.h>
31 #include <mach/mmc.h>
32 #include <mach/ohci.h>
33 #include <mach/pxa27x.h>
34 #include <mach/pxa27x-udc.h>
35 #include <mach/pxafb.h>
36 
37 #include "devices.h"
38 #include "generic.h"
39 
40 #define GPIO114_INCOME_ETH_IRQ  (114)
41 #define GPIO0_INCOME_SD_DETECT  (0)
42 #define GPIO0_INCOME_SD_RO      (1)
43 #define GPIO54_INCOME_LED_A     (54)
44 #define GPIO55_INCOME_LED_B     (55)
45 #define GPIO113_INCOME_TS_IRQ   (113)
46 
47 /******************************************************************************
48  * SD/MMC card controller
49  ******************************************************************************/
50 #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
51 static struct pxamci_platform_data income_mci_platform_data = {
52 	.ocr_mask		= MMC_VDD_32_33 | MMC_VDD_33_34,
53 	.gpio_power		= -1,
54 	.gpio_card_detect	= GPIO0_INCOME_SD_DETECT,
55 	.gpio_card_ro		= GPIO0_INCOME_SD_RO,
56 	.detect_delay_ms	= 200,
57 };
58 
income_mmc_init(void)59 static void __init income_mmc_init(void)
60 {
61 	pxa_set_mci_info(&income_mci_platform_data);
62 }
63 #else
income_mmc_init(void)64 static inline void income_mmc_init(void) {}
65 #endif
66 
67 /******************************************************************************
68  * USB Host
69  ******************************************************************************/
70 #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
71 static struct pxaohci_platform_data income_ohci_info = {
72 	.port_mode	= PMM_PERPORT_MODE,
73 	.flags		= ENABLE_PORT1 | POWER_CONTROL_LOW | POWER_SENSE_LOW,
74 };
75 
income_uhc_init(void)76 static void __init income_uhc_init(void)
77 {
78 	pxa_set_ohci_info(&income_ohci_info);
79 }
80 #else
income_uhc_init(void)81 static inline void income_uhc_init(void) {}
82 #endif
83 
84 /******************************************************************************
85  * LED
86  ******************************************************************************/
87 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
88 struct gpio_led income_gpio_leds[] = {
89 	{
90 		.name			= "income:green:leda",
91 		.default_trigger	= "none",
92 		.gpio			= GPIO54_INCOME_LED_A,
93 		.active_low		= 1,
94 	},
95 	{
96 		.name			= "income:green:ledb",
97 		.default_trigger	= "none",
98 		.gpio			= GPIO55_INCOME_LED_B,
99 		.active_low		= 1,
100 	}
101 };
102 
103 static struct gpio_led_platform_data income_gpio_led_info = {
104 	.leds		= income_gpio_leds,
105 	.num_leds	= ARRAY_SIZE(income_gpio_leds),
106 };
107 
108 static struct platform_device income_leds = {
109 	.name	= "leds-gpio",
110 	.id	= -1,
111 	.dev	= {
112 		.platform_data	= &income_gpio_led_info,
113 	}
114 };
115 
income_led_init(void)116 static void __init income_led_init(void)
117 {
118 	platform_device_register(&income_leds);
119 }
120 #else
income_led_init(void)121 static inline void income_led_init(void) {}
122 #endif
123 
124 /******************************************************************************
125  * I2C
126  ******************************************************************************/
127 #if defined(CONFIG_I2C_PXA) || defined(CONFIG_I2C_PXA_MODULE)
128 static struct i2c_board_info __initdata income_i2c_devs[] = {
129 	{
130 		I2C_BOARD_INFO("ds1340", 0x68),
131 	}, {
132 		I2C_BOARD_INFO("lm75", 0x4f),
133 	},
134 };
135 
income_i2c_init(void)136 static void __init income_i2c_init(void)
137 {
138 	pxa_set_i2c_info(NULL);
139 	pxa27x_set_i2c_power_info(NULL);
140 	i2c_register_board_info(0, ARRAY_AND_SIZE(income_i2c_devs));
141 }
142 #else
income_i2c_init(void)143 static inline void income_i2c_init(void) {}
144 #endif
145 
146 /******************************************************************************
147  * Framebuffer
148  ******************************************************************************/
149 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
150 static struct pxafb_mode_info income_lcd_modes[] = {
151 {
152 	.pixclock	= 144700,
153 	.xres		= 320,
154 	.yres		= 240,
155 	.bpp		= 32,
156 	.depth		= 18,
157 
158 	.left_margin	= 10,
159 	.right_margin	= 10,
160 	.upper_margin	= 7,
161 	.lower_margin	= 8,
162 
163 	.hsync_len	= 20,
164 	.vsync_len	= 2,
165 
166 	.sync		= FB_SYNC_VERT_HIGH_ACT,
167 },
168 };
169 
170 static struct pxafb_mach_info income_lcd_screen = {
171 	.modes		= income_lcd_modes,
172 	.num_modes	= ARRAY_SIZE(income_lcd_modes),
173 	.lcd_conn	= LCD_COLOR_TFT_18BPP | LCD_PCLK_EDGE_FALL,
174 };
175 
income_lcd_init(void)176 static void __init income_lcd_init(void)
177 {
178 	pxa_set_fb_info(NULL, &income_lcd_screen);
179 }
180 #else
income_lcd_init(void)181 static inline void income_lcd_init(void) {}
182 #endif
183 
184 /******************************************************************************
185  * Backlight
186  ******************************************************************************/
187 #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM__MODULE)
188 static struct platform_pwm_backlight_data income_backlight_data = {
189 	.pwm_id		= 0,
190 	.max_brightness	= 0x3ff,
191 	.dft_brightness	= 0x1ff,
192 	.pwm_period_ns	= 1000000,
193 };
194 
195 static struct platform_device income_backlight = {
196 	.name	= "pwm-backlight",
197 	.dev	= {
198 		.parent		= &pxa27x_device_pwm0.dev,
199 		.platform_data	= &income_backlight_data,
200 	},
201 };
202 
income_pwm_init(void)203 static void __init income_pwm_init(void)
204 {
205 	platform_device_register(&income_backlight);
206 }
207 #else
income_pwm_init(void)208 static inline void income_pwm_init(void) {}
209 #endif
210 
colibri_pxa270_income_boardinit(void)211 void __init colibri_pxa270_income_boardinit(void)
212 {
213 	pxa_set_ffuart_info(NULL);
214 	pxa_set_btuart_info(NULL);
215 	pxa_set_stuart_info(NULL);
216 
217 	income_mmc_init();
218 	income_uhc_init();
219 	income_led_init();
220 	income_i2c_init();
221 	income_lcd_init();
222 	income_pwm_init();
223 }
224 
225