blob: d7cf47d0361882dfe810ce325d5d433718ea0682 [file] [log] [blame]
Marek Vasut403d2972010-05-22 00:29:39 +02001/*
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>
Ulf Hansson40d727a2017-01-13 14:14:02 +010020#include <linux/leds.h>
Marek Vasut403d2972010-05-22 00:29:39 +020021#include <linux/ioport.h>
22#include <linux/kernel.h>
23#include <linux/platform_device.h>
Thierry Redingbd2e2b32015-10-05 10:49:42 +020024#include <linux/pwm.h>
Marek Vasut403d2972010-05-22 00:29:39 +020025#include <linux/pwm_backlight.h>
Sebastian Andrzej Siewiorb4593962011-02-23 12:38:16 +010026#include <linux/i2c/pxa-i2c.h>
Marek Vasut403d2972010-05-22 00:29:39 +020027
28#include <asm/irq.h>
29#include <asm/mach-types.h>
30
31#include <mach/hardware.h>
Arnd Bergmann293b2da2012-08-24 15:16:48 +020032#include <linux/platform_data/mmc-pxamci.h>
33#include <linux/platform_data/usb-ohci-pxa27x.h>
Arnd Bergmann4c25c5d2015-01-30 10:45:33 +010034#include "pxa27x.h"
35#include "pxa27x-udc.h"
Arnd Bergmann293b2da2012-08-24 15:16:48 +020036#include <linux/platform_data/video-pxafb.h>
Marek Vasut403d2972010-05-22 00:29:39 +020037
Marek Vasut403d2972010-05-22 00:29:39 +020038#include "devices.h"
39#include "generic.h"
40
41#define GPIO114_INCOME_ETH_IRQ (114)
42#define GPIO0_INCOME_SD_DETECT (0)
43#define GPIO0_INCOME_SD_RO (1)
44#define GPIO54_INCOME_LED_A (54)
45#define GPIO55_INCOME_LED_B (55)
46#define GPIO113_INCOME_TS_IRQ (113)
47
48/******************************************************************************
Marek Vasut403d2972010-05-22 00:29:39 +020049 * SD/MMC card controller
50 ******************************************************************************/
51#if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
52static struct pxamci_platform_data income_mci_platform_data = {
53 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
54 .gpio_power = -1,
55 .gpio_card_detect = GPIO0_INCOME_SD_DETECT,
56 .gpio_card_ro = GPIO0_INCOME_SD_RO,
57 .detect_delay_ms = 200,
58};
59
60static void __init income_mmc_init(void)
61{
62 pxa_set_mci_info(&income_mci_platform_data);
63}
64#else
65static inline void income_mmc_init(void) {}
66#endif
67
68/******************************************************************************
69 * USB Host
70 ******************************************************************************/
71#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
72static struct pxaohci_platform_data income_ohci_info = {
73 .port_mode = PMM_PERPORT_MODE,
74 .flags = ENABLE_PORT1 | POWER_CONTROL_LOW | POWER_SENSE_LOW,
75};
76
77static void __init income_uhc_init(void)
78{
79 pxa_set_ohci_info(&income_ohci_info);
80}
81#else
82static inline void income_uhc_init(void) {}
83#endif
84
85/******************************************************************************
86 * LED
87 ******************************************************************************/
88#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
89struct gpio_led income_gpio_leds[] = {
90 {
91 .name = "income:green:leda",
92 .default_trigger = "none",
93 .gpio = GPIO54_INCOME_LED_A,
94 .active_low = 1,
95 },
96 {
97 .name = "income:green:ledb",
98 .default_trigger = "none",
99 .gpio = GPIO55_INCOME_LED_B,
100 .active_low = 1,
101 }
102};
103
104static struct gpio_led_platform_data income_gpio_led_info = {
105 .leds = income_gpio_leds,
106 .num_leds = ARRAY_SIZE(income_gpio_leds),
107};
108
109static struct platform_device income_leds = {
110 .name = "leds-gpio",
111 .id = -1,
112 .dev = {
113 .platform_data = &income_gpio_led_info,
114 }
115};
116
117static void __init income_led_init(void)
118{
119 platform_device_register(&income_leds);
120}
121#else
122static inline void income_led_init(void) {}
123#endif
124
125/******************************************************************************
126 * I2C
127 ******************************************************************************/
128#if defined(CONFIG_I2C_PXA) || defined(CONFIG_I2C_PXA_MODULE)
129static struct i2c_board_info __initdata income_i2c_devs[] = {
130 {
131 I2C_BOARD_INFO("ds1340", 0x68),
132 }, {
133 I2C_BOARD_INFO("lm75", 0x4f),
134 },
135};
136
137static void __init income_i2c_init(void)
138{
139 pxa_set_i2c_info(NULL);
140 pxa27x_set_i2c_power_info(NULL);
141 i2c_register_board_info(0, ARRAY_AND_SIZE(income_i2c_devs));
142}
143#else
144static inline void income_i2c_init(void) {}
145#endif
146
147/******************************************************************************
148 * Framebuffer
149 ******************************************************************************/
150#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
151static struct pxafb_mode_info income_lcd_modes[] = {
152{
153 .pixclock = 144700,
154 .xres = 320,
155 .yres = 240,
156 .bpp = 32,
157 .depth = 18,
158
159 .left_margin = 10,
160 .right_margin = 10,
161 .upper_margin = 7,
162 .lower_margin = 8,
163
164 .hsync_len = 20,
165 .vsync_len = 2,
166
167 .sync = FB_SYNC_VERT_HIGH_ACT,
168},
169};
170
171static struct pxafb_mach_info income_lcd_screen = {
172 .modes = income_lcd_modes,
173 .num_modes = ARRAY_SIZE(income_lcd_modes),
174 .lcd_conn = LCD_COLOR_TFT_18BPP | LCD_PCLK_EDGE_FALL,
175};
176
177static void __init income_lcd_init(void)
178{
Russell King - ARM Linux4321e1a2011-02-15 15:37:30 +0800179 pxa_set_fb_info(NULL, &income_lcd_screen);
Marek Vasut403d2972010-05-22 00:29:39 +0200180}
181#else
182static inline void income_lcd_init(void) {}
183#endif
184
185/******************************************************************************
186 * Backlight
187 ******************************************************************************/
Paul Bolleeeb31512011-10-11 17:31:55 +0200188#if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
Thierry Redingbd2e2b32015-10-05 10:49:42 +0200189static struct pwm_lookup income_pwm_lookup[] = {
190 PWM_LOOKUP("pxa27x-pwm.0", 0, "pwm-backlight.0", NULL, 1000000,
191 PWM_POLARITY_NORMAL),
192};
193
Marek Vasut403d2972010-05-22 00:29:39 +0200194static struct platform_pwm_backlight_data income_backlight_data = {
Marek Vasut403d2972010-05-22 00:29:39 +0200195 .max_brightness = 0x3ff,
196 .dft_brightness = 0x1ff,
Thierry Redingdb011202013-08-30 12:15:24 +0200197 .enable_gpio = -1,
Marek Vasut403d2972010-05-22 00:29:39 +0200198};
199
200static struct platform_device income_backlight = {
201 .name = "pwm-backlight",
202 .dev = {
203 .parent = &pxa27x_device_pwm0.dev,
204 .platform_data = &income_backlight_data,
205 },
206};
207
208static void __init income_pwm_init(void)
209{
Thierry Redingbd2e2b32015-10-05 10:49:42 +0200210 pwm_add_table(income_pwm_lookup, ARRAY_SIZE(income_pwm_lookup));
Marek Vasut403d2972010-05-22 00:29:39 +0200211 platform_device_register(&income_backlight);
212}
213#else
214static inline void income_pwm_init(void) {}
215#endif
216
217void __init colibri_pxa270_income_boardinit(void)
218{
Marek Vasut403d2972010-05-22 00:29:39 +0200219 pxa_set_ffuart_info(NULL);
220 pxa_set_btuart_info(NULL);
221 pxa_set_stuart_info(NULL);
222
223 income_mmc_init();
224 income_uhc_init();
225 income_led_init();
226 income_i2c_init();
227 income_lcd_init();
228 income_pwm_init();
229}
230