Krzysztof Kozlowski | 84b2170 | 2017-12-25 20:54:32 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | // |
| 3 | // Copyright (c) 2003-2004 Simtec Electronics |
| 4 | // Ben Dooks <ben@simtec.co.uk> |
| 5 | // |
Alexander A. Klimov | 3ecdf2a | 2020-07-19 11:39:39 +0200 | [diff] [blame] | 6 | // https://www.handhelds.org/projects/rx3715.html |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | |
| 8 | #include <linux/kernel.h> |
| 9 | #include <linux/types.h> |
| 10 | #include <linux/interrupt.h> |
| 11 | #include <linux/list.h> |
Russell King | 8d717a5 | 2010-05-22 19:47:18 +0100 | [diff] [blame] | 12 | #include <linux/memblock.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <linux/timer.h> |
| 14 | #include <linux/init.h> |
| 15 | #include <linux/tty.h> |
| 16 | #include <linux/console.h> |
Kay Sievers | edbaa60 | 2011-12-21 16:26:03 -0800 | [diff] [blame] | 17 | #include <linux/device.h> |
Russell King | d052d1b | 2005-10-29 19:07:23 +0100 | [diff] [blame] | 18 | #include <linux/platform_device.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #include <linux/serial_core.h> |
Tushar Behera | 334a1c7 | 2014-02-14 10:32:45 +0900 | [diff] [blame] | 20 | #include <linux/serial_s3c.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | #include <linux/serial.h> |
Russell King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 22 | #include <linux/io.h> |
Ben Dooks | 272eb57 | 2006-04-02 16:16:15 +0100 | [diff] [blame] | 23 | #include <linux/mtd/mtd.h> |
Boris Brezillon | d4092d7 | 2017-08-04 17:29:10 +0200 | [diff] [blame] | 24 | #include <linux/mtd/rawnand.h> |
Miquel Raynal | e5acf9c | 2020-09-30 01:01:15 +0200 | [diff] [blame] | 25 | #include <linux/mtd/nand-ecc-sw-hamming.h> |
Ben Dooks | 272eb57 | 2006-04-02 16:16:15 +0100 | [diff] [blame] | 26 | #include <linux/mtd/partitions.h> |
| 27 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | #include <asm/mach/arch.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | #include <asm/mach/irq.h> |
Kukjin Kim | 232910d | 2013-01-02 10:18:58 -0800 | [diff] [blame] | 30 | #include <asm/mach/map.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | |
Kukjin Kim | 232910d | 2013-01-02 10:18:58 -0800 | [diff] [blame] | 32 | #include <linux/platform_data/mtd-nand-s3c2410.h> |
Arnd Bergmann | 81994e0 | 2019-09-02 22:33:24 +0200 | [diff] [blame] | 33 | #include <linux/platform_data/fb-s3c2410.h> |
Kukjin Kim | 232910d | 2013-01-02 10:18:58 -0800 | [diff] [blame] | 34 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | #include <asm/irq.h> |
| 36 | #include <asm/mach-types.h> |
| 37 | |
Arnd Bergmann | c6ff132 | 2019-09-02 18:37:30 +0200 | [diff] [blame] | 38 | #include "regs-gpio.h" |
| 39 | #include "gpio-samsung.h" |
| 40 | #include "gpio-cfg.h" |
Ben Dooks | e838ffc | 2005-11-01 19:44:28 +0000 | [diff] [blame] | 41 | |
Arnd Bergmann | c6ff132 | 2019-09-02 18:37:30 +0200 | [diff] [blame] | 42 | #include "cpu.h" |
| 43 | #include "devs.h" |
| 44 | #include "pm.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | |
Arnd Bergmann | 71b9114 | 2019-09-02 17:47:55 +0200 | [diff] [blame] | 46 | #include "s3c24xx.h" |
Kukjin Kim | 232910d | 2013-01-02 10:18:58 -0800 | [diff] [blame] | 47 | #include "h1940.h" |
Kukjin Kim | b27b072 | 2012-01-03 14:02:03 +0100 | [diff] [blame] | 48 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | static struct map_desc rx3715_iodesc[] __initdata = { |
| 50 | /* dump ISA space somewhere unused */ |
| 51 | |
Ben Dooks | ff6ffa8 | 2005-11-09 14:05:31 +0000 | [diff] [blame] | 52 | { |
| 53 | .virtual = (u32)S3C24XX_VA_ISA_WORD, |
| 54 | .pfn = __phys_to_pfn(S3C2410_CS3), |
| 55 | .length = SZ_1M, |
| 56 | .type = MT_DEVICE, |
| 57 | }, { |
| 58 | .virtual = (u32)S3C24XX_VA_ISA_BYTE, |
| 59 | .pfn = __phys_to_pfn(S3C2410_CS3), |
| 60 | .length = SZ_1M, |
| 61 | .type = MT_DEVICE, |
| 62 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | }; |
| 64 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | static struct s3c2410_uartcfg rx3715_uartcfgs[] = { |
| 66 | [0] = { |
| 67 | .hwport = 0, |
| 68 | .flags = 0, |
| 69 | .ucon = 0x3c5, |
| 70 | .ulcon = 0x03, |
| 71 | .ufcon = 0x51, |
Thomas Abraham | afba7f9 | 2011-10-24 11:47:51 +0200 | [diff] [blame] | 72 | .clk_sel = S3C2410_UCON_CLKSEL3, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | }, |
| 74 | [1] = { |
| 75 | .hwport = 1, |
| 76 | .flags = 0, |
| 77 | .ucon = 0x3c5, |
| 78 | .ulcon = 0x03, |
| 79 | .ufcon = 0x00, |
Thomas Abraham | afba7f9 | 2011-10-24 11:47:51 +0200 | [diff] [blame] | 80 | .clk_sel = S3C2410_UCON_CLKSEL3, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | }, |
| 82 | /* IR port */ |
| 83 | [2] = { |
| 84 | .hwport = 2, |
| 85 | .uart_flags = UPF_CONS_FLOW, |
| 86 | .ucon = 0x3c5, |
| 87 | .ulcon = 0x43, |
| 88 | .ufcon = 0x51, |
Thomas Abraham | afba7f9 | 2011-10-24 11:47:51 +0200 | [diff] [blame] | 89 | .clk_sel = S3C2410_UCON_CLKSEL3, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | } |
| 91 | }; |
| 92 | |
Ben Dooks | e838ffc | 2005-11-01 19:44:28 +0000 | [diff] [blame] | 93 | /* framebuffer lcd controller information */ |
| 94 | |
Krzysztof Helt | 09fe75f | 2007-10-16 01:28:56 -0700 | [diff] [blame] | 95 | static struct s3c2410fb_display rx3715_lcdcfg __initdata = { |
Krzysztof Helt | f28ef57 | 2007-10-16 01:28:58 -0700 | [diff] [blame] | 96 | .lcdcon5 = S3C2410_LCDCON5_INVVLINE | |
| 97 | S3C2410_LCDCON5_FRM565 | |
| 98 | S3C2410_LCDCON5_HWSWP, |
Ben Dooks | e838ffc | 2005-11-01 19:44:28 +0000 | [diff] [blame] | 99 | |
Krzysztof Helt | 1f41153 | 2007-10-16 01:28:57 -0700 | [diff] [blame] | 100 | .type = S3C2410_LCDCON1_TFT, |
| 101 | .width = 240, |
| 102 | .height = 320, |
Krzysztof Helt | 09fe75f | 2007-10-16 01:28:56 -0700 | [diff] [blame] | 103 | |
Krzysztof Helt | 6981669 | 2007-10-16 01:29:06 -0700 | [diff] [blame] | 104 | .pixclock = 260000, |
Krzysztof Helt | 1f41153 | 2007-10-16 01:28:57 -0700 | [diff] [blame] | 105 | .xres = 240, |
| 106 | .yres = 320, |
| 107 | .bpp = 16, |
| 108 | .left_margin = 36, |
| 109 | .right_margin = 36, |
Krzysztof Helt | 93d11f5 | 2007-10-16 01:29:00 -0700 | [diff] [blame] | 110 | .hsync_len = 8, |
Krzysztof Helt | 5f20f69 | 2007-10-16 01:28:59 -0700 | [diff] [blame] | 111 | .upper_margin = 6, |
| 112 | .lower_margin = 7, |
Krzysztof Helt | 93d11f5 | 2007-10-16 01:29:00 -0700 | [diff] [blame] | 113 | .vsync_len = 3, |
Krzysztof Helt | 09fe75f | 2007-10-16 01:28:56 -0700 | [diff] [blame] | 114 | }; |
| 115 | |
| 116 | static struct s3c2410fb_mach_info rx3715_fb_info __initdata = { |
| 117 | |
| 118 | .displays = &rx3715_lcdcfg, |
| 119 | .num_displays = 1, |
| 120 | .default_display = 0, |
| 121 | |
Ben Dooks | e838ffc | 2005-11-01 19:44:28 +0000 | [diff] [blame] | 122 | .lpcsel = 0xf82, |
| 123 | |
| 124 | .gpccon = 0xaa955699, |
| 125 | .gpccon_mask = 0xffc003cc, |
Arnd Bergmann | 81994e0 | 2019-09-02 22:33:24 +0200 | [diff] [blame] | 126 | .gpccon_reg = S3C2410_GPCCON, |
Ben Dooks | e838ffc | 2005-11-01 19:44:28 +0000 | [diff] [blame] | 127 | .gpcup = 0x0000ffff, |
| 128 | .gpcup_mask = 0xffffffff, |
Arnd Bergmann | 81994e0 | 2019-09-02 22:33:24 +0200 | [diff] [blame] | 129 | .gpcup_reg = S3C2410_GPCUP, |
Ben Dooks | e838ffc | 2005-11-01 19:44:28 +0000 | [diff] [blame] | 130 | |
| 131 | .gpdcon = 0xaa95aaa1, |
| 132 | .gpdcon_mask = 0xffc0fff0, |
Arnd Bergmann | 81994e0 | 2019-09-02 22:33:24 +0200 | [diff] [blame] | 133 | .gpdcon_reg = S3C2410_GPDCON, |
Ben Dooks | e838ffc | 2005-11-01 19:44:28 +0000 | [diff] [blame] | 134 | .gpdup = 0x0000faff, |
| 135 | .gpdup_mask = 0xffffffff, |
Arnd Bergmann | 81994e0 | 2019-09-02 22:33:24 +0200 | [diff] [blame] | 136 | .gpdup_reg = S3C2410_GPDUP, |
Ben Dooks | e838ffc | 2005-11-01 19:44:28 +0000 | [diff] [blame] | 137 | }; |
| 138 | |
Ben Dooks | 2a3a180 | 2009-09-28 13:59:49 +0300 | [diff] [blame] | 139 | static struct mtd_partition __initdata rx3715_nand_part[] = { |
Ben Dooks | 272eb57 | 2006-04-02 16:16:15 +0100 | [diff] [blame] | 140 | [0] = { |
| 141 | .name = "Whole Flash", |
| 142 | .offset = 0, |
| 143 | .size = MTDPART_SIZ_FULL, |
| 144 | .mask_flags = MTD_WRITEABLE, |
| 145 | } |
| 146 | }; |
| 147 | |
Ben Dooks | 2a3a180 | 2009-09-28 13:59:49 +0300 | [diff] [blame] | 148 | static struct s3c2410_nand_set __initdata rx3715_nand_sets[] = { |
Ben Dooks | 272eb57 | 2006-04-02 16:16:15 +0100 | [diff] [blame] | 149 | [0] = { |
| 150 | .name = "Internal", |
| 151 | .nr_chips = 1, |
| 152 | .nr_partitions = ARRAY_SIZE(rx3715_nand_part), |
| 153 | .partitions = rx3715_nand_part, |
| 154 | }, |
| 155 | }; |
| 156 | |
Ben Dooks | 2a3a180 | 2009-09-28 13:59:49 +0300 | [diff] [blame] | 157 | static struct s3c2410_platform_nand __initdata rx3715_nand_info = { |
Ben Dooks | 272eb57 | 2006-04-02 16:16:15 +0100 | [diff] [blame] | 158 | .tacls = 25, |
| 159 | .twrph0 = 50, |
| 160 | .twrph1 = 15, |
| 161 | .nr_sets = ARRAY_SIZE(rx3715_nand_sets), |
| 162 | .sets = rx3715_nand_sets, |
Miquel Raynal | bace41f | 2020-08-27 10:51:58 +0200 | [diff] [blame] | 163 | .engine_type = NAND_ECC_ENGINE_TYPE_SOFT, |
Ben Dooks | 272eb57 | 2006-04-02 16:16:15 +0100 | [diff] [blame] | 164 | }; |
| 165 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | static struct platform_device *rx3715_devices[] __initdata = { |
Ben Dooks | b813248 | 2009-11-23 00:13:39 +0000 | [diff] [blame] | 167 | &s3c_device_ohci, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | &s3c_device_lcd, |
| 169 | &s3c_device_wdt, |
Ben Dooks | 3e1b776 | 2008-10-31 16:14:40 +0000 | [diff] [blame] | 170 | &s3c_device_i2c0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | &s3c_device_iis, |
Ben Dooks | 272eb57 | 2006-04-02 16:16:15 +0100 | [diff] [blame] | 172 | &s3c_device_nand, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | }; |
| 174 | |
Ben Dooks | 5fe10ab | 2005-09-20 17:24:33 +0100 | [diff] [blame] | 175 | static void __init rx3715_map_io(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | { |
| 177 | s3c24xx_init_io(rx3715_iodesc, ARRAY_SIZE(rx3715_iodesc)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | s3c24xx_init_uarts(rx3715_uartcfgs, ARRAY_SIZE(rx3715_uartcfgs)); |
Krzysztof Kozlowski | a1342f6 | 2020-08-20 22:42:03 +0200 | [diff] [blame] | 179 | s3c24xx_set_timer_source(S3C24XX_PWM3, S3C24XX_PWM4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | } |
| 181 | |
Heiko Stuebner | a28d618 | 2014-05-09 05:49:19 +0900 | [diff] [blame] | 182 | static void __init rx3715_init_time(void) |
| 183 | { |
| 184 | s3c2440_init_clocks(16934000); |
Krzysztof Kozlowski | a1342f6 | 2020-08-20 22:42:03 +0200 | [diff] [blame] | 185 | s3c24xx_timer_init(); |
Heiko Stuebner | a28d618 | 2014-05-09 05:49:19 +0900 | [diff] [blame] | 186 | } |
| 187 | |
Russell King | 98c672c | 2010-05-22 18:18:57 +0100 | [diff] [blame] | 188 | /* H1940 and RX3715 need to reserve this for suspend */ |
| 189 | static void __init rx3715_reserve(void) |
| 190 | { |
Russell King | 8d717a5 | 2010-05-22 19:47:18 +0100 | [diff] [blame] | 191 | memblock_reserve(0x30003000, 0x1000); |
| 192 | memblock_reserve(0x30081000, 0x1000); |
Russell King | 98c672c | 2010-05-22 18:18:57 +0100 | [diff] [blame] | 193 | } |
| 194 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | static void __init rx3715_init_machine(void) |
| 196 | { |
Krzysztof Helt | b1dfe1f | 2007-03-19 15:10:20 +0100 | [diff] [blame] | 197 | #ifdef CONFIG_PM_H1940 |
Ben Dooks | bbf6f28 | 2006-12-07 20:47:58 +0100 | [diff] [blame] | 198 | memcpy(phys_to_virt(H1940_SUSPEND_RESUMEAT), h1940_pm_return, 1024); |
Krzysztof Helt | b1dfe1f | 2007-03-19 15:10:20 +0100 | [diff] [blame] | 199 | #endif |
Ben Dooks | 4e59c25 | 2008-12-12 00:24:18 +0000 | [diff] [blame] | 200 | s3c_pm_init(); |
Ben Dooks | bbf6f28 | 2006-12-07 20:47:58 +0100 | [diff] [blame] | 201 | |
Ben Dooks | 2a3a180 | 2009-09-28 13:59:49 +0300 | [diff] [blame] | 202 | s3c_nand_set_platdata(&rx3715_nand_info); |
Krzysztof Helt | 09fe75f | 2007-10-16 01:28:56 -0700 | [diff] [blame] | 203 | s3c24xx_fb_set_platdata(&rx3715_fb_info); |
Arnd Bergmann | 673085f | 2020-08-06 20:20:45 +0200 | [diff] [blame] | 204 | /* Configure the I2S pins (GPE0...GPE4) in correct mode */ |
| 205 | s3c_gpio_cfgall_range(S3C2410_GPE(0), 5, S3C_GPIO_SFN(2), |
| 206 | S3C_GPIO_PULL_NONE); |
Ben Dooks | 57e5171 | 2007-04-20 11:19:16 +0100 | [diff] [blame] | 207 | platform_add_devices(rx3715_devices, ARRAY_SIZE(rx3715_devices)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | } |
Ben Dooks | e838ffc | 2005-11-01 19:44:28 +0000 | [diff] [blame] | 209 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 | MACHINE_START(RX3715, "IPAQ-RX3715") |
Ben Dooks | afdd225 | 2010-05-07 09:24:05 +0900 | [diff] [blame] | 211 | /* Maintainer: Ben Dooks <ben-linux@fluff.org> */ |
Nicolas Pitre | 69d5071 | 2011-07-05 22:38:17 -0400 | [diff] [blame] | 212 | .atag_offset = 0x100, |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 213 | .map_io = rx3715_map_io, |
Russell King | 98c672c | 2010-05-22 18:18:57 +0100 | [diff] [blame] | 214 | .reserve = rx3715_reserve, |
Heiko Stuebner | ce6c164 | 2013-02-12 09:59:20 -0800 | [diff] [blame] | 215 | .init_irq = s3c2440_init_irq, |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 216 | .init_machine = rx3715_init_machine, |
Heiko Stuebner | a28d618 | 2014-05-09 05:49:19 +0900 | [diff] [blame] | 217 | .init_time = rx3715_init_time, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | MACHINE_END |