mach-mini2440.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804
  1. // SPDX-License-Identifier: GPL-2.0
  2. //
  3. // Copyright (c) 2008 Ramax Lo <[email protected]>
  4. // Based on mach-anubis.c by Ben Dooks <[email protected]>
  5. // and modifications by SBZ <[email protected]> and
  6. // Weibing <http://weibing.blogbus.com> and
  7. // Michel Pollet <[email protected]>
  8. //
  9. // For product information, visit https://code.google.com/p/mini2440/
  10. #include <linux/kernel.h>
  11. #include <linux/types.h>
  12. #include <linux/interrupt.h>
  13. #include <linux/list.h>
  14. #include <linux/timer.h>
  15. #include <linux/init.h>
  16. #include <linux/gpio.h>
  17. #include <linux/gpio/machine.h>
  18. #include <linux/input.h>
  19. #include <linux/io.h>
  20. #include <linux/serial_core.h>
  21. #include <linux/serial_s3c.h>
  22. #include <linux/dm9000.h>
  23. #include <linux/property.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/gpio_keys.h>
  26. #include <linux/i2c.h>
  27. #include <linux/mmc/host.h>
  28. #include <asm/mach/arch.h>
  29. #include <asm/mach/map.h>
  30. #include <linux/platform_data/fb-s3c2410.h>
  31. #include <asm/mach-types.h>
  32. #include "regs-gpio.h"
  33. #include <linux/platform_data/leds-s3c24xx.h>
  34. #include "irqs.h"
  35. #include "gpio-samsung.h"
  36. #include <linux/platform_data/mtd-nand-s3c2410.h>
  37. #include <linux/platform_data/i2c-s3c2410.h>
  38. #include <linux/platform_data/mmc-s3cmci.h>
  39. #include <linux/platform_data/usb-s3c2410_udc.h>
  40. #include <linux/mtd/mtd.h>
  41. #include <linux/mtd/rawnand.h>
  42. #include <linux/mtd/nand-ecc-sw-hamming.h>
  43. #include <linux/mtd/partitions.h>
  44. #include "gpio-cfg.h"
  45. #include "devs.h"
  46. #include "cpu.h"
  47. #include <sound/s3c24xx_uda134x.h>
  48. #include "s3c24xx.h"
  49. #define MACH_MINI2440_DM9K_BASE (S3C2410_CS4 + 0x300)
  50. static struct map_desc mini2440_iodesc[] __initdata = {
  51. /* nothing to declare, move along */
  52. };
  53. #define UCON S3C2410_UCON_DEFAULT
  54. #define ULCON (S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB)
  55. #define UFCON (S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE)
  56. static struct s3c2410_uartcfg mini2440_uartcfgs[] __initdata = {
  57. [0] = {
  58. .hwport = 0,
  59. .flags = 0,
  60. .ucon = UCON,
  61. .ulcon = ULCON,
  62. .ufcon = UFCON,
  63. },
  64. [1] = {
  65. .hwport = 1,
  66. .flags = 0,
  67. .ucon = UCON,
  68. .ulcon = ULCON,
  69. .ufcon = UFCON,
  70. },
  71. [2] = {
  72. .hwport = 2,
  73. .flags = 0,
  74. .ucon = UCON,
  75. .ulcon = ULCON,
  76. .ufcon = UFCON,
  77. },
  78. };
  79. /* USB device UDC support */
  80. static struct s3c2410_udc_mach_info mini2440_udc_cfg __initdata = {
  81. };
  82. static struct gpiod_lookup_table mini2440_udc_gpio_table = {
  83. .dev_id = "s3c2410-usbgadget",
  84. .table = {
  85. GPIO_LOOKUP("GPIOC", 5, "pullup", GPIO_ACTIVE_HIGH),
  86. { },
  87. },
  88. };
  89. /* LCD timing and setup */
  90. /*
  91. * This macro simplifies the table bellow
  92. */
  93. #define _LCD_DECLARE(_clock, _xres, margin_left, margin_right, hsync, \
  94. _yres, margin_top, margin_bottom, vsync, refresh) \
  95. .width = _xres, \
  96. .xres = _xres, \
  97. .height = _yres, \
  98. .yres = _yres, \
  99. .left_margin = margin_left, \
  100. .right_margin = margin_right, \
  101. .upper_margin = margin_top, \
  102. .lower_margin = margin_bottom, \
  103. .hsync_len = hsync, \
  104. .vsync_len = vsync, \
  105. .pixclock = ((_clock*100000000000LL) / \
  106. ((refresh) * \
  107. (hsync + margin_left + _xres + margin_right) * \
  108. (vsync + margin_top + _yres + margin_bottom))), \
  109. .bpp = 16,\
  110. .type = (S3C2410_LCDCON1_TFT16BPP |\
  111. S3C2410_LCDCON1_TFT)
  112. static struct s3c2410fb_display mini2440_lcd_cfg[] __initdata = {
  113. [0] = { /* mini2440 + 3.5" TFT + touchscreen */
  114. _LCD_DECLARE(
  115. 7, /* The 3.5 is quite fast */
  116. 240, 21, 38, 6, /* x timing */
  117. 320, 4, 4, 2, /* y timing */
  118. 60), /* refresh rate */
  119. .lcdcon5 = (S3C2410_LCDCON5_FRM565 |
  120. S3C2410_LCDCON5_INVVLINE |
  121. S3C2410_LCDCON5_INVVFRAME |
  122. S3C2410_LCDCON5_INVVDEN |
  123. S3C2410_LCDCON5_PWREN),
  124. },
  125. [1] = { /* mini2440 + 7" TFT + touchscreen */
  126. _LCD_DECLARE(
  127. 10, /* the 7" runs slower */
  128. 800, 40, 40, 48, /* x timing */
  129. 480, 29, 3, 3, /* y timing */
  130. 50), /* refresh rate */
  131. .lcdcon5 = (S3C2410_LCDCON5_FRM565 |
  132. S3C2410_LCDCON5_INVVLINE |
  133. S3C2410_LCDCON5_INVVFRAME |
  134. S3C2410_LCDCON5_PWREN),
  135. },
  136. /* The VGA shield can outout at several resolutions. All share
  137. * the same timings, however, anything smaller than 1024x768
  138. * will only be displayed in the top left corner of a 1024x768
  139. * XGA output unless you add optional dip switches to the shield.
  140. * Therefore timings for other resolutions have been omitted here.
  141. */
  142. [2] = {
  143. _LCD_DECLARE(
  144. 10,
  145. 1024, 1, 2, 2, /* y timing */
  146. 768, 200, 16, 16, /* x timing */
  147. 24), /* refresh rate, maximum stable,
  148. * tested with the FPGA shield
  149. */
  150. .lcdcon5 = (S3C2410_LCDCON5_FRM565 |
  151. S3C2410_LCDCON5_HWSWP),
  152. },
  153. /* mini2440 + 3.5" TFT (LCD-W35i, LQ035Q1DG06 type) + touchscreen*/
  154. [3] = {
  155. _LCD_DECLARE(
  156. /* clock */
  157. 7,
  158. /* xres, margin_right, margin_left, hsync */
  159. 320, 68, 66, 4,
  160. /* yres, margin_top, margin_bottom, vsync */
  161. 240, 4, 4, 9,
  162. /* refresh rate */
  163. 60),
  164. .lcdcon5 = (S3C2410_LCDCON5_FRM565 |
  165. S3C2410_LCDCON5_INVVDEN |
  166. S3C2410_LCDCON5_INVVFRAME |
  167. S3C2410_LCDCON5_INVVLINE |
  168. S3C2410_LCDCON5_INVVCLK |
  169. S3C2410_LCDCON5_HWSWP),
  170. },
  171. };
  172. /* todo - put into gpio header */
  173. #define S3C2410_GPCCON_MASK(x) (3 << ((x) * 2))
  174. #define S3C2410_GPDCON_MASK(x) (3 << ((x) * 2))
  175. static struct s3c2410fb_mach_info mini2440_fb_info __initdata = {
  176. .displays = &mini2440_lcd_cfg[0], /* not constant! see init */
  177. .num_displays = 1,
  178. .default_display = 0,
  179. /* Enable VD[2..7], VD[10..15], VD[18..23] and VCLK, syncs, VDEN
  180. * and disable the pull down resistors on pins we are using for LCD
  181. * data.
  182. */
  183. .gpcup = (0xf << 1) | (0x3f << 10),
  184. .gpccon = (S3C2410_GPC1_VCLK | S3C2410_GPC2_VLINE |
  185. S3C2410_GPC3_VFRAME | S3C2410_GPC4_VM |
  186. S3C2410_GPC10_VD2 | S3C2410_GPC11_VD3 |
  187. S3C2410_GPC12_VD4 | S3C2410_GPC13_VD5 |
  188. S3C2410_GPC14_VD6 | S3C2410_GPC15_VD7),
  189. .gpccon_mask = (S3C2410_GPCCON_MASK(1) | S3C2410_GPCCON_MASK(2) |
  190. S3C2410_GPCCON_MASK(3) | S3C2410_GPCCON_MASK(4) |
  191. S3C2410_GPCCON_MASK(10) | S3C2410_GPCCON_MASK(11) |
  192. S3C2410_GPCCON_MASK(12) | S3C2410_GPCCON_MASK(13) |
  193. S3C2410_GPCCON_MASK(14) | S3C2410_GPCCON_MASK(15)),
  194. .gpccon_reg = S3C2410_GPCCON,
  195. .gpcup_reg = S3C2410_GPCUP,
  196. .gpdup = (0x3f << 2) | (0x3f << 10),
  197. .gpdcon = (S3C2410_GPD2_VD10 | S3C2410_GPD3_VD11 |
  198. S3C2410_GPD4_VD12 | S3C2410_GPD5_VD13 |
  199. S3C2410_GPD6_VD14 | S3C2410_GPD7_VD15 |
  200. S3C2410_GPD10_VD18 | S3C2410_GPD11_VD19 |
  201. S3C2410_GPD12_VD20 | S3C2410_GPD13_VD21 |
  202. S3C2410_GPD14_VD22 | S3C2410_GPD15_VD23),
  203. .gpdcon_mask = (S3C2410_GPDCON_MASK(2) | S3C2410_GPDCON_MASK(3) |
  204. S3C2410_GPDCON_MASK(4) | S3C2410_GPDCON_MASK(5) |
  205. S3C2410_GPDCON_MASK(6) | S3C2410_GPDCON_MASK(7) |
  206. S3C2410_GPDCON_MASK(10) | S3C2410_GPDCON_MASK(11)|
  207. S3C2410_GPDCON_MASK(12) | S3C2410_GPDCON_MASK(13)|
  208. S3C2410_GPDCON_MASK(14) | S3C2410_GPDCON_MASK(15)),
  209. .gpdcon_reg = S3C2410_GPDCON,
  210. .gpdup_reg = S3C2410_GPDUP,
  211. };
  212. /* MMC/SD */
  213. static struct s3c24xx_mci_pdata mini2440_mmc_cfg __initdata = {
  214. .wprotect_invert = 1,
  215. .set_power = s3c24xx_mci_def_set_power,
  216. .ocr_avail = MMC_VDD_32_33|MMC_VDD_33_34,
  217. };
  218. static struct gpiod_lookup_table mini2440_mmc_gpio_table = {
  219. .dev_id = "s3c2410-sdi",
  220. .table = {
  221. /* Card detect S3C2410_GPG(8) */
  222. GPIO_LOOKUP("GPIOG", 8, "cd", GPIO_ACTIVE_LOW),
  223. /* Write protect S3C2410_GPH(8) */
  224. GPIO_LOOKUP("GPIOH", 8, "wp", GPIO_ACTIVE_HIGH),
  225. /* bus pins */
  226. GPIO_LOOKUP_IDX("GPIOE", 5, "bus", 0, GPIO_ACTIVE_HIGH),
  227. GPIO_LOOKUP_IDX("GPIOE", 6, "bus", 1, GPIO_ACTIVE_HIGH),
  228. GPIO_LOOKUP_IDX("GPIOE", 7, "bus", 2, GPIO_ACTIVE_HIGH),
  229. GPIO_LOOKUP_IDX("GPIOE", 8, "bus", 3, GPIO_ACTIVE_HIGH),
  230. GPIO_LOOKUP_IDX("GPIOE", 9, "bus", 4, GPIO_ACTIVE_HIGH),
  231. GPIO_LOOKUP_IDX("GPIOE", 10, "bus", 5, GPIO_ACTIVE_HIGH),
  232. { },
  233. },
  234. };
  235. /* NAND Flash on MINI2440 board */
  236. static struct mtd_partition mini2440_default_nand_part[] __initdata = {
  237. [0] = {
  238. .name = "u-boot",
  239. .size = SZ_256K,
  240. .offset = 0,
  241. },
  242. [1] = {
  243. .name = "u-boot-env",
  244. .size = SZ_128K,
  245. .offset = SZ_256K,
  246. },
  247. [2] = {
  248. .name = "kernel",
  249. /* 5 megabytes, for a kernel with no modules
  250. * or a uImage with a ramdisk attached
  251. */
  252. .size = 0x00500000,
  253. .offset = SZ_256K + SZ_128K,
  254. },
  255. [3] = {
  256. .name = "root",
  257. .offset = SZ_256K + SZ_128K + 0x00500000,
  258. .size = MTDPART_SIZ_FULL,
  259. },
  260. };
  261. static struct s3c2410_nand_set mini2440_nand_sets[] __initdata = {
  262. [0] = {
  263. .name = "nand",
  264. .nr_chips = 1,
  265. .nr_partitions = ARRAY_SIZE(mini2440_default_nand_part),
  266. .partitions = mini2440_default_nand_part,
  267. .flash_bbt = 1, /* we use u-boot to create a BBT */
  268. },
  269. };
  270. static struct s3c2410_platform_nand mini2440_nand_info __initdata = {
  271. .tacls = 0,
  272. .twrph0 = 25,
  273. .twrph1 = 15,
  274. .nr_sets = ARRAY_SIZE(mini2440_nand_sets),
  275. .sets = mini2440_nand_sets,
  276. .ignore_unset_ecc = 1,
  277. .engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST,
  278. };
  279. /* DM9000AEP 10/100 ethernet controller */
  280. static struct resource mini2440_dm9k_resource[] = {
  281. [0] = DEFINE_RES_MEM(MACH_MINI2440_DM9K_BASE, 4),
  282. [1] = DEFINE_RES_MEM(MACH_MINI2440_DM9K_BASE + 4, 4),
  283. [2] = DEFINE_RES_NAMED(IRQ_EINT7, 1, NULL, IORESOURCE_IRQ
  284. | IORESOURCE_IRQ_HIGHEDGE),
  285. };
  286. /*
  287. * The DM9000 has no eeprom, and it's MAC address is set by
  288. * the bootloader before starting the kernel.
  289. */
  290. static struct dm9000_plat_data mini2440_dm9k_pdata = {
  291. .flags = (DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM),
  292. };
  293. static struct platform_device mini2440_device_eth = {
  294. .name = "dm9000",
  295. .id = -1,
  296. .num_resources = ARRAY_SIZE(mini2440_dm9k_resource),
  297. .resource = mini2440_dm9k_resource,
  298. .dev = {
  299. .platform_data = &mini2440_dm9k_pdata,
  300. },
  301. };
  302. /* CON5
  303. * +--+ /-----\
  304. * | | | |
  305. * | | | BAT |
  306. * | | \_____/
  307. * | |
  308. * | | +----+ +----+
  309. * | | | K5 | | K1 |
  310. * | | +----+ +----+
  311. * | | +----+ +----+
  312. * | | | K4 | | K2 |
  313. * | | +----+ +----+
  314. * | | +----+ +----+
  315. * | | | K6 | | K3 |
  316. * | | +----+ +----+
  317. * .....
  318. */
  319. static struct gpio_keys_button mini2440_buttons[] = {
  320. {
  321. .gpio = S3C2410_GPG(0), /* K1 */
  322. .code = KEY_F1,
  323. .desc = "Button 1",
  324. .active_low = 1,
  325. },
  326. {
  327. .gpio = S3C2410_GPG(3), /* K2 */
  328. .code = KEY_F2,
  329. .desc = "Button 2",
  330. .active_low = 1,
  331. },
  332. {
  333. .gpio = S3C2410_GPG(5), /* K3 */
  334. .code = KEY_F3,
  335. .desc = "Button 3",
  336. .active_low = 1,
  337. },
  338. {
  339. .gpio = S3C2410_GPG(6), /* K4 */
  340. .code = KEY_POWER,
  341. .desc = "Power",
  342. .active_low = 1,
  343. },
  344. {
  345. .gpio = S3C2410_GPG(7), /* K5 */
  346. .code = KEY_F5,
  347. .desc = "Button 5",
  348. .active_low = 1,
  349. },
  350. #if 0
  351. /* this pin is also known as TCLK1 and seems to already
  352. * marked as "in use" somehow in the kernel -- possibly wrongly
  353. */
  354. {
  355. .gpio = S3C2410_GPG(11), /* K6 */
  356. .code = KEY_F6,
  357. .desc = "Button 6",
  358. .active_low = 1,
  359. },
  360. #endif
  361. };
  362. static struct gpio_keys_platform_data mini2440_button_data = {
  363. .buttons = mini2440_buttons,
  364. .nbuttons = ARRAY_SIZE(mini2440_buttons),
  365. };
  366. static struct platform_device mini2440_button_device = {
  367. .name = "gpio-keys",
  368. .id = -1,
  369. .dev = {
  370. .platform_data = &mini2440_button_data,
  371. }
  372. };
  373. /* LEDS */
  374. static struct gpiod_lookup_table mini2440_led1_gpio_table = {
  375. .dev_id = "s3c24xx_led.1",
  376. .table = {
  377. GPIO_LOOKUP("GPB", 5, NULL, GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN),
  378. { },
  379. },
  380. };
  381. static struct gpiod_lookup_table mini2440_led2_gpio_table = {
  382. .dev_id = "s3c24xx_led.2",
  383. .table = {
  384. GPIO_LOOKUP("GPB", 6, NULL, GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN),
  385. { },
  386. },
  387. };
  388. static struct gpiod_lookup_table mini2440_led3_gpio_table = {
  389. .dev_id = "s3c24xx_led.3",
  390. .table = {
  391. GPIO_LOOKUP("GPB", 7, NULL, GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN),
  392. { },
  393. },
  394. };
  395. static struct gpiod_lookup_table mini2440_led4_gpio_table = {
  396. .dev_id = "s3c24xx_led.4",
  397. .table = {
  398. GPIO_LOOKUP("GPB", 8, NULL, GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN),
  399. { },
  400. },
  401. };
  402. static struct gpiod_lookup_table mini2440_backlight_gpio_table = {
  403. .dev_id = "s3c24xx_led.5",
  404. .table = {
  405. GPIO_LOOKUP("GPG", 4, NULL, GPIO_ACTIVE_HIGH),
  406. { },
  407. },
  408. };
  409. static struct s3c24xx_led_platdata mini2440_led1_pdata = {
  410. .name = "led1",
  411. .def_trigger = "heartbeat",
  412. };
  413. static struct s3c24xx_led_platdata mini2440_led2_pdata = {
  414. .name = "led2",
  415. .def_trigger = "nand-disk",
  416. };
  417. static struct s3c24xx_led_platdata mini2440_led3_pdata = {
  418. .name = "led3",
  419. .def_trigger = "mmc0",
  420. };
  421. static struct s3c24xx_led_platdata mini2440_led4_pdata = {
  422. .name = "led4",
  423. .def_trigger = "",
  424. };
  425. static struct s3c24xx_led_platdata mini2440_led_backlight_pdata = {
  426. .name = "backlight",
  427. .def_trigger = "backlight",
  428. };
  429. static struct platform_device mini2440_led1 = {
  430. .name = "s3c24xx_led",
  431. .id = 1,
  432. .dev = {
  433. .platform_data = &mini2440_led1_pdata,
  434. },
  435. };
  436. static struct platform_device mini2440_led2 = {
  437. .name = "s3c24xx_led",
  438. .id = 2,
  439. .dev = {
  440. .platform_data = &mini2440_led2_pdata,
  441. },
  442. };
  443. static struct platform_device mini2440_led3 = {
  444. .name = "s3c24xx_led",
  445. .id = 3,
  446. .dev = {
  447. .platform_data = &mini2440_led3_pdata,
  448. },
  449. };
  450. static struct platform_device mini2440_led4 = {
  451. .name = "s3c24xx_led",
  452. .id = 4,
  453. .dev = {
  454. .platform_data = &mini2440_led4_pdata,
  455. },
  456. };
  457. static struct platform_device mini2440_led_backlight = {
  458. .name = "s3c24xx_led",
  459. .id = 5,
  460. .dev = {
  461. .platform_data = &mini2440_led_backlight_pdata,
  462. },
  463. };
  464. /* AUDIO */
  465. static struct s3c24xx_uda134x_platform_data mini2440_audio_pins = {
  466. .l3_clk = S3C2410_GPB(4),
  467. .l3_mode = S3C2410_GPB(2),
  468. .l3_data = S3C2410_GPB(3),
  469. .model = UDA134X_UDA1341
  470. };
  471. static struct platform_device mini2440_audio = {
  472. .name = "s3c24xx_uda134x",
  473. .id = 0,
  474. .dev = {
  475. .platform_data = &mini2440_audio_pins,
  476. },
  477. };
  478. /*
  479. * I2C devices
  480. */
  481. static const struct property_entry mini2440_at24_properties[] = {
  482. PROPERTY_ENTRY_U32("pagesize", 16),
  483. { }
  484. };
  485. static const struct software_node mini2440_at24_node = {
  486. .properties = mini2440_at24_properties,
  487. };
  488. static struct i2c_board_info mini2440_i2c_devs[] __initdata = {
  489. {
  490. I2C_BOARD_INFO("24c08", 0x50),
  491. .swnode = &mini2440_at24_node,
  492. },
  493. };
  494. static struct uda134x_platform_data s3c24xx_uda134x = {
  495. .l3 = {
  496. .gpio_clk = S3C2410_GPB(4),
  497. .gpio_data = S3C2410_GPB(3),
  498. .gpio_mode = S3C2410_GPB(2),
  499. .use_gpios = 1,
  500. .data_hold = 1,
  501. .data_setup = 1,
  502. .clock_high = 1,
  503. .mode_hold = 1,
  504. .mode = 1,
  505. .mode_setup = 1,
  506. },
  507. .model = UDA134X_UDA1341,
  508. };
  509. static struct platform_device uda1340_codec = {
  510. .name = "uda134x-codec",
  511. .id = -1,
  512. .dev = {
  513. .platform_data = &s3c24xx_uda134x,
  514. },
  515. };
  516. static struct platform_device *mini2440_devices[] __initdata = {
  517. &s3c_device_ohci,
  518. &s3c_device_wdt,
  519. &s3c_device_i2c0,
  520. &s3c_device_rtc,
  521. &s3c_device_usbgadget,
  522. &mini2440_device_eth,
  523. &mini2440_led1,
  524. &mini2440_led2,
  525. &mini2440_led3,
  526. &mini2440_led4,
  527. &mini2440_button_device,
  528. &s3c_device_nand,
  529. &s3c_device_sdi,
  530. &s3c2440_device_dma,
  531. &s3c_device_iis,
  532. &uda1340_codec,
  533. &mini2440_audio,
  534. };
  535. static void __init mini2440_map_io(void)
  536. {
  537. s3c24xx_init_io(mini2440_iodesc, ARRAY_SIZE(mini2440_iodesc));
  538. s3c24xx_init_uarts(mini2440_uartcfgs, ARRAY_SIZE(mini2440_uartcfgs));
  539. s3c24xx_set_timer_source(S3C24XX_PWM3, S3C24XX_PWM4);
  540. }
  541. static void __init mini2440_init_time(void)
  542. {
  543. s3c2440_init_clocks(12000000);
  544. s3c24xx_timer_init();
  545. }
  546. /*
  547. * mini2440_features string
  548. *
  549. * t = Touchscreen present
  550. * b = backlight control
  551. * c = camera [TODO]
  552. * 0-9 LCD configuration
  553. *
  554. */
  555. static char mini2440_features_str[12] __initdata = "0tb";
  556. static int __init mini2440_features_setup(char *str)
  557. {
  558. if (str)
  559. strscpy(mini2440_features_str, str,
  560. sizeof(mini2440_features_str));
  561. return 1;
  562. }
  563. __setup("mini2440=", mini2440_features_setup);
  564. #define FEATURE_SCREEN (1 << 0)
  565. #define FEATURE_BACKLIGHT (1 << 1)
  566. #define FEATURE_TOUCH (1 << 2)
  567. #define FEATURE_CAMERA (1 << 3)
  568. struct mini2440_features_t {
  569. int count;
  570. int done;
  571. int lcd_index;
  572. struct platform_device *optional[8];
  573. };
  574. static void __init mini2440_parse_features(
  575. struct mini2440_features_t *features,
  576. const char *features_str)
  577. {
  578. const char *fp = features_str;
  579. features->count = 0;
  580. features->done = 0;
  581. features->lcd_index = -1;
  582. while (*fp) {
  583. char f = *fp++;
  584. switch (f) {
  585. case '0'...'9': /* tft screen */
  586. if (features->done & FEATURE_SCREEN) {
  587. pr_info("MINI2440: '%c' ignored, screen type already set\n",
  588. f);
  589. } else {
  590. int li = f - '0';
  591. if (li >= ARRAY_SIZE(mini2440_lcd_cfg))
  592. pr_info("MINI2440: '%c' out of range LCD mode\n",
  593. f);
  594. else {
  595. features->optional[features->count++] =
  596. &s3c_device_lcd;
  597. features->lcd_index = li;
  598. }
  599. }
  600. features->done |= FEATURE_SCREEN;
  601. break;
  602. case 'b':
  603. if (features->done & FEATURE_BACKLIGHT)
  604. pr_info("MINI2440: '%c' ignored, backlight already set\n",
  605. f);
  606. else {
  607. features->optional[features->count++] =
  608. &mini2440_led_backlight;
  609. }
  610. features->done |= FEATURE_BACKLIGHT;
  611. break;
  612. case 't':
  613. pr_info("MINI2440: '%c' ignored, touchscreen not compiled in\n",
  614. f);
  615. break;
  616. case 'c':
  617. if (features->done & FEATURE_CAMERA)
  618. pr_info("MINI2440: '%c' ignored, camera already registered\n",
  619. f);
  620. else
  621. features->optional[features->count++] =
  622. &s3c_device_camif;
  623. features->done |= FEATURE_CAMERA;
  624. break;
  625. }
  626. }
  627. }
  628. static void __init mini2440_init(void)
  629. {
  630. struct mini2440_features_t features = { 0 };
  631. int i;
  632. pr_info("MINI2440: Option string mini2440=%s\n",
  633. mini2440_features_str);
  634. /* Parse the feature string */
  635. mini2440_parse_features(&features, mini2440_features_str);
  636. /* turn LCD on */
  637. s3c_gpio_cfgpin(S3C2410_GPC(0), S3C2410_GPC0_LEND);
  638. /* Turn the backlight early on */
  639. WARN_ON(gpio_request_one(S3C2410_GPG(4), GPIOF_OUT_INIT_HIGH, NULL));
  640. gpio_free(S3C2410_GPG(4));
  641. /* remove pullup on optional PWM backlight -- unused on 3.5 and 7"s */
  642. gpio_request_one(S3C2410_GPB(1), GPIOF_IN, NULL);
  643. s3c_gpio_setpull(S3C2410_GPB(1), S3C_GPIO_PULL_UP);
  644. gpio_free(S3C2410_GPB(1));
  645. /* mark the key as input, without pullups (there is one on the board) */
  646. for (i = 0; i < ARRAY_SIZE(mini2440_buttons); i++) {
  647. s3c_gpio_setpull(mini2440_buttons[i].gpio, S3C_GPIO_PULL_UP);
  648. s3c_gpio_cfgpin(mini2440_buttons[i].gpio, S3C2410_GPIO_INPUT);
  649. }
  650. /* Configure the I2S pins (GPE0...GPE4) in correct mode */
  651. s3c_gpio_cfgall_range(S3C2410_GPE(0), 5, S3C_GPIO_SFN(2),
  652. S3C_GPIO_PULL_NONE);
  653. if (features.lcd_index != -1) {
  654. int li;
  655. mini2440_fb_info.displays =
  656. &mini2440_lcd_cfg[features.lcd_index];
  657. pr_info("MINI2440: LCD");
  658. for (li = 0; li < ARRAY_SIZE(mini2440_lcd_cfg); li++)
  659. if (li == features.lcd_index)
  660. pr_cont(" [%d:%dx%d]", li,
  661. mini2440_lcd_cfg[li].width,
  662. mini2440_lcd_cfg[li].height);
  663. else
  664. pr_cont(" %d:%dx%d", li,
  665. mini2440_lcd_cfg[li].width,
  666. mini2440_lcd_cfg[li].height);
  667. pr_cont("\n");
  668. s3c24xx_fb_set_platdata(&mini2440_fb_info);
  669. }
  670. gpiod_add_lookup_table(&mini2440_udc_gpio_table);
  671. s3c24xx_udc_set_platdata(&mini2440_udc_cfg);
  672. gpiod_add_lookup_table(&mini2440_mmc_gpio_table);
  673. s3c24xx_mci_set_platdata(&mini2440_mmc_cfg);
  674. s3c_nand_set_platdata(&mini2440_nand_info);
  675. s3c_i2c0_set_platdata(NULL);
  676. i2c_register_board_info(0, mini2440_i2c_devs,
  677. ARRAY_SIZE(mini2440_i2c_devs));
  678. /* Disable pull-up on the LED lines */
  679. s3c_gpio_setpull(S3C2410_GPB(5), S3C_GPIO_PULL_NONE);
  680. s3c_gpio_setpull(S3C2410_GPB(6), S3C_GPIO_PULL_NONE);
  681. s3c_gpio_setpull(S3C2410_GPB(7), S3C_GPIO_PULL_NONE);
  682. s3c_gpio_setpull(S3C2410_GPB(8), S3C_GPIO_PULL_NONE);
  683. s3c_gpio_setpull(S3C2410_GPG(4), S3C_GPIO_PULL_NONE);
  684. /* Add lookups for the lines */
  685. gpiod_add_lookup_table(&mini2440_led1_gpio_table);
  686. gpiod_add_lookup_table(&mini2440_led2_gpio_table);
  687. gpiod_add_lookup_table(&mini2440_led3_gpio_table);
  688. gpiod_add_lookup_table(&mini2440_led4_gpio_table);
  689. gpiod_add_lookup_table(&mini2440_backlight_gpio_table);
  690. platform_add_devices(mini2440_devices, ARRAY_SIZE(mini2440_devices));
  691. if (features.count) /* the optional features */
  692. platform_add_devices(features.optional, features.count);
  693. }
  694. MACHINE_START(MINI2440, "MINI2440")
  695. /* Maintainer: Michel Pollet <[email protected]> */
  696. .atag_offset = 0x100,
  697. .nr_irqs = NR_IRQS_S3C2440,
  698. .map_io = mini2440_map_io,
  699. .init_machine = mini2440_init,
  700. .init_irq = s3c2440_init_irq,
  701. .init_time = mini2440_init_time,
  702. MACHINE_END