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