Krzysztof Kozlowski | 28a196f | 2017-12-25 20:54:33 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | // |
| 3 | // Copyright (C) 2010 Maurus Cuelenaere |
Maurus Cuelenaere | a2f7bff | 2010-05-20 11:35:50 +0200 | [diff] [blame] | 4 | |
| 5 | #include <linux/fb.h> |
| 6 | #include <linux/gpio.h> |
| 7 | #include <linux/gpio_keys.h> |
Maurus Cuelenaere | a2f7bff | 2010-05-20 11:35:50 +0200 | [diff] [blame] | 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 | |
Leela Krishna Amudala | 5a213a5 | 2012-08-08 09:44:49 +0900 | [diff] [blame] | 16 | #include <video/samsung_fimd.h> |
Arnd Bergmann | ba27904 | 2015-02-27 22:06:58 +0100 | [diff] [blame] | 17 | #include <mach/irqs.h> |
Arnd Bergmann | c6ff132 | 2019-09-02 18:37:30 +0200 | [diff] [blame] | 18 | #include "map.h" |
| 19 | #include "regs-gpio.h" |
| 20 | #include "gpio-samsung.h" |
Maurus Cuelenaere | a2f7bff | 2010-05-20 11:35:50 +0200 | [diff] [blame] | 21 | |
Arnd Bergmann | c6ff132 | 2019-09-02 18:37:30 +0200 | [diff] [blame] | 22 | #include "cpu.h" |
| 23 | #include "devs.h" |
| 24 | #include "fb.h" |
| 25 | #include "gpio-cfg.h" |
Maurus Cuelenaere | a2f7bff | 2010-05-20 11:35:50 +0200 | [diff] [blame] | 26 | |
Arnd Bergmann | 71b9114 | 2019-09-02 17:47:55 +0200 | [diff] [blame] | 27 | #include "s3c64xx.h" |
Maurus Cuelenaere | a2f7bff | 2010-05-20 11:35:50 +0200 | [diff] [blame] | 28 | #include "mach-smartq.h" |
| 29 | |
Uwe Kleine-König | 495c7b8 | 2010-09-02 09:14:19 +0100 | [diff] [blame] | 30 | static struct gpio_led smartq7_leds[] = { |
Maurus Cuelenaere | a2f7bff | 2010-05-20 11:35:50 +0200 | [diff] [blame] | 31 | { |
| 32 | .name = "smartq7:red", |
| 33 | .active_low = 1, |
| 34 | .gpio = S3C64XX_GPN(8), |
| 35 | }, |
| 36 | { |
| 37 | .name = "smartq7:green", |
| 38 | .active_low = 1, |
| 39 | .gpio = S3C64XX_GPN(9), |
| 40 | }, |
| 41 | }; |
| 42 | |
| 43 | static struct gpio_led_platform_data smartq7_led_data = { |
| 44 | .num_leds = ARRAY_SIZE(smartq7_leds), |
| 45 | .leds = smartq7_leds, |
| 46 | }; |
| 47 | |
| 48 | static struct platform_device smartq7_leds_device = { |
| 49 | .name = "leds-gpio", |
| 50 | .id = -1, |
| 51 | .dev.platform_data = &smartq7_led_data, |
| 52 | }; |
| 53 | |
| 54 | /* Labels according to the SmartQ manual */ |
| 55 | static struct gpio_keys_button smartq7_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_FN, |
| 67 | .desc = "Function", |
| 68 | .active_low = 1, |
| 69 | .debounce_interval = 5, |
| 70 | .type = EV_KEY, |
| 71 | }, |
| 72 | { |
| 73 | .gpio = S3C64XX_GPN(3), |
| 74 | .code = KEY_KPMINUS, |
| 75 | .desc = "Minus", |
| 76 | .active_low = 1, |
| 77 | .debounce_interval = 5, |
| 78 | .type = EV_KEY, |
| 79 | }, |
| 80 | { |
| 81 | .gpio = S3C64XX_GPN(4), |
| 82 | .code = KEY_KPPLUS, |
| 83 | .desc = "Plus", |
| 84 | .active_low = 1, |
| 85 | .debounce_interval = 5, |
| 86 | .type = EV_KEY, |
| 87 | }, |
| 88 | { |
| 89 | .gpio = S3C64XX_GPN(12), |
| 90 | .code = KEY_ENTER, |
| 91 | .desc = "Enter", |
| 92 | .active_low = 1, |
| 93 | .debounce_interval = 5, |
| 94 | .type = EV_KEY, |
| 95 | }, |
| 96 | { |
| 97 | .gpio = S3C64XX_GPN(15), |
| 98 | .code = KEY_ESC, |
| 99 | .desc = "Cancel", |
| 100 | .active_low = 1, |
| 101 | .debounce_interval = 5, |
| 102 | .type = EV_KEY, |
| 103 | }, |
| 104 | }; |
| 105 | |
| 106 | static struct gpio_keys_platform_data smartq7_buttons_data = { |
| 107 | .buttons = smartq7_buttons, |
| 108 | .nbuttons = ARRAY_SIZE(smartq7_buttons), |
| 109 | }; |
| 110 | |
| 111 | static struct platform_device smartq7_buttons_device = { |
| 112 | .name = "gpio-keys", |
| 113 | .id = 0, |
| 114 | .num_resources = 0, |
| 115 | .dev = { |
| 116 | .platform_data = &smartq7_buttons_data, |
| 117 | } |
| 118 | }; |
| 119 | |
| 120 | static struct s3c_fb_pd_win smartq7_fb_win0 = { |
Maurus Cuelenaere | a2f7bff | 2010-05-20 11:35:50 +0200 | [diff] [blame] | 121 | .max_bpp = 32, |
| 122 | .default_bpp = 16, |
Thomas Abraham | 79d3c41 | 2012-03-24 21:58:48 +0530 | [diff] [blame] | 123 | .xres = 800, |
| 124 | .yres = 480, |
| 125 | }; |
| 126 | |
| 127 | static struct fb_videomode smartq7_lcd_timing = { |
| 128 | .left_margin = 3, |
| 129 | .right_margin = 5, |
| 130 | .upper_margin = 1, |
| 131 | .lower_margin = 20, |
| 132 | .hsync_len = 10, |
| 133 | .vsync_len = 3, |
| 134 | .xres = 800, |
| 135 | .yres = 480, |
| 136 | .refresh = 80, |
Maurus Cuelenaere | a2f7bff | 2010-05-20 11:35:50 +0200 | [diff] [blame] | 137 | }; |
| 138 | |
| 139 | static struct s3c_fb_platdata smartq7_lcd_pdata __initdata = { |
| 140 | .setup_gpio = s3c64xx_fb_gpio_setup_24bpp, |
Thomas Abraham | 79d3c41 | 2012-03-24 21:58:48 +0530 | [diff] [blame] | 141 | .vtiming = &smartq7_lcd_timing, |
Maurus Cuelenaere | a2f7bff | 2010-05-20 11:35:50 +0200 | [diff] [blame] | 142 | .win[0] = &smartq7_fb_win0, |
| 143 | .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB, |
| 144 | .vidcon1 = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC | |
| 145 | VIDCON1_INV_VCLK, |
| 146 | }; |
| 147 | |
| 148 | static struct platform_device *smartq7_devices[] __initdata = { |
| 149 | &smartq7_leds_device, |
| 150 | &smartq7_buttons_device, |
Maurus Cuelenaere | a2f7bff | 2010-05-20 11:35:50 +0200 | [diff] [blame] | 151 | }; |
| 152 | |
| 153 | static void __init smartq7_machine_init(void) |
| 154 | { |
| 155 | s3c_fb_set_platdata(&smartq7_lcd_pdata); |
| 156 | |
| 157 | smartq_machine_init(); |
Maurus Cuelenaere | a2f7bff | 2010-05-20 11:35:50 +0200 | [diff] [blame] | 158 | |
| 159 | platform_add_devices(smartq7_devices, ARRAY_SIZE(smartq7_devices)); |
| 160 | } |
| 161 | |
| 162 | MACHINE_START(SMARTQ7, "SmartQ 7") |
| 163 | /* Maintainer: Maurus Cuelenaere <mcuelenaere AT gmail DOT com> */ |
Nicolas Pitre | 170a590 | 2011-07-05 22:38:17 -0400 | [diff] [blame] | 164 | .atag_offset = 0x100, |
Arnd Bergmann | ba27904 | 2015-02-27 22:06:58 +0100 | [diff] [blame] | 165 | .nr_irqs = S3C64XX_NR_IRQS, |
Maurus Cuelenaere | a2f7bff | 2010-05-20 11:35:50 +0200 | [diff] [blame] | 166 | .init_irq = s3c6410_init_irq, |
Maurus Cuelenaere | a2f7bff | 2010-05-20 11:35:50 +0200 | [diff] [blame] | 167 | .map_io = smartq_map_io, |
| 168 | .init_machine = smartq7_machine_init, |
Krzysztof Kozlowski | a1342f6 | 2020-08-20 22:42:03 +0200 | [diff] [blame] | 169 | .init_time = s3c64xx_timer_init, |
Maurus Cuelenaere | a2f7bff | 2010-05-20 11:35:50 +0200 | [diff] [blame] | 170 | MACHINE_END |