1 // SPDX-License-Identifier: GPL-2.0
2 //
3 // Copyright (C) 2010 Maurus Cuelenaere
4 
5 #include <linux/fb.h>
6 #include <linux/gpio.h>
7 #include <linux/gpio_keys.h>
8 #include <linux/init.h>
9 #include <linux/input.h>
10 #include <linux/leds.h>
11 #include <linux/platform_device.h>
12 
13 #include <asm/mach-types.h>
14 #include <asm/mach/arch.h>
15 
16 #include <video/samsung_fimd.h>
17 #include <mach/irqs.h>
18 #include "map.h"
19 #include "regs-gpio.h"
20 #include "gpio-samsung.h"
21 
22 #include "cpu.h"
23 #include "devs.h"
24 #include "fb.h"
25 #include "gpio-cfg.h"
26 
27 #include "s3c64xx.h"
28 #include "mach-smartq.h"
29 
30 static struct gpio_led smartq5_leds[] = {
31 	{
32 		.name			= "smartq5:green",
33 		.active_low		= 1,
34 		.gpio			= S3C64XX_GPN(8),
35 	},
36 	{
37 		.name			= "smartq5:red",
38 		.active_low		= 1,
39 		.gpio			= S3C64XX_GPN(9),
40 	},
41 };
42 
43 static struct gpio_led_platform_data smartq5_led_data = {
44 	.num_leds = ARRAY_SIZE(smartq5_leds),
45 	.leds = smartq5_leds,
46 };
47 
48 static struct platform_device smartq5_leds_device = {
49 	.name			= "leds-gpio",
50 	.id			= -1,
51 	.dev.platform_data	= &smartq5_led_data,
52 };
53 
54 /* Labels according to the SmartQ manual */
55 static struct gpio_keys_button smartq5_buttons[] = {
56 	{
57 		.gpio			= S3C64XX_GPL(14),
58 		.code			= KEY_POWER,
59 		.desc			= "Power",
60 		.active_low		= 1,
61 		.debounce_interval	= 5,
62 		.type                   = EV_KEY,
63 	},
64 	{
65 		.gpio			= S3C64XX_GPN(2),
66 		.code			= KEY_KPMINUS,
67 		.desc			= "Minus",
68 		.active_low		= 1,
69 		.debounce_interval	= 5,
70 		.type                   = EV_KEY,
71 	},
72 	{
73 		.gpio			= S3C64XX_GPN(12),
74 		.code			= KEY_KPPLUS,
75 		.desc			= "Plus",
76 		.active_low		= 1,
77 		.debounce_interval	= 5,
78 		.type                   = EV_KEY,
79 	},
80 	{
81 		.gpio			= S3C64XX_GPN(15),
82 		.code			= KEY_ENTER,
83 		.desc			= "Move",
84 		.active_low		= 1,
85 		.debounce_interval	= 5,
86 		.type                   = EV_KEY,
87 	},
88 };
89 
90 static struct gpio_keys_platform_data smartq5_buttons_data  = {
91 	.buttons	= smartq5_buttons,
92 	.nbuttons	= ARRAY_SIZE(smartq5_buttons),
93 };
94 
95 static struct platform_device smartq5_buttons_device  = {
96 	.name		= "gpio-keys",
97 	.id		= 0,
98 	.num_resources	= 0,
99 	.dev		= {
100 		.platform_data	= &smartq5_buttons_data,
101 	}
102 };
103 
104 static struct s3c_fb_pd_win smartq5_fb_win0 = {
105 	.max_bpp	= 32,
106 	.default_bpp	= 16,
107 	.xres		= 800,
108 	.yres		= 480,
109 };
110 
111 static struct fb_videomode smartq5_lcd_timing = {
112 	.left_margin	= 216,
113 	.right_margin	= 40,
114 	.upper_margin	= 35,
115 	.lower_margin	= 10,
116 	.hsync_len	= 1,
117 	.vsync_len	= 1,
118 	.xres		= 800,
119 	.yres		= 480,
120 	.refresh	= 80,
121 };
122 
123 static struct s3c_fb_platdata smartq5_lcd_pdata __initdata = {
124 	.setup_gpio	= s3c64xx_fb_gpio_setup_24bpp,
125 	.vtiming	= &smartq5_lcd_timing,
126 	.win[0]		= &smartq5_fb_win0,
127 	.vidcon0	= VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB,
128 	.vidcon1	= VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC |
129 			  VIDCON1_INV_VDEN,
130 };
131 
132 static struct platform_device *smartq5_devices[] __initdata = {
133 	&smartq5_leds_device,
134 	&smartq5_buttons_device,
135 };
136 
smartq5_machine_init(void)137 static void __init smartq5_machine_init(void)
138 {
139 	s3c_fb_set_platdata(&smartq5_lcd_pdata);
140 
141 	smartq_machine_init();
142 
143 	platform_add_devices(smartq5_devices, ARRAY_SIZE(smartq5_devices));
144 }
145 
146 MACHINE_START(SMARTQ5, "SmartQ 5")
147 	/* Maintainer: Maurus Cuelenaere <mcuelenaere AT gmail DOT com> */
148 	.atag_offset	= 0x100,
149 	.nr_irqs	= S3C64XX_NR_IRQS,
150 	.init_irq	= s3c6410_init_irq,
151 	.map_io		= smartq_map_io,
152 	.init_machine	= smartq5_machine_init,
153 	.init_time	= s3c64xx_timer_init,
154 MACHINE_END
155