mach-crag6410.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890
  1. // SPDX-License-Identifier: GPL-2.0
  2. //
  3. // Copyright 2011 Wolfson Microelectronics plc
  4. // Mark Brown <[email protected]>
  5. //
  6. // Copyright 2011 Simtec Electronics
  7. // Ben Dooks <[email protected]>
  8. #include <linux/kernel.h>
  9. #include <linux/list.h>
  10. #include <linux/serial_core.h>
  11. #include <linux/serial_s3c.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/fb.h>
  14. #include <linux/io.h>
  15. #include <linux/init.h>
  16. #include <linux/gpio.h>
  17. #include <linux/gpio/machine.h>
  18. #include <linux/leds.h>
  19. #include <linux/delay.h>
  20. #include <linux/mmc/host.h>
  21. #include <linux/regulator/machine.h>
  22. #include <linux/regulator/fixed.h>
  23. #include <linux/pwm.h>
  24. #include <linux/pwm_backlight.h>
  25. #include <linux/dm9000.h>
  26. #include <linux/gpio_keys.h>
  27. #include <linux/gpio/driver.h>
  28. #include <linux/spi/spi.h>
  29. #include <linux/platform_data/pca953x.h>
  30. #include <linux/platform_data/s3c-hsotg.h>
  31. #include <video/platform_lcd.h>
  32. #include <linux/mfd/wm831x/core.h>
  33. #include <linux/mfd/wm831x/pdata.h>
  34. #include <linux/mfd/wm831x/irq.h>
  35. #include <linux/mfd/wm831x/gpio.h>
  36. #include <sound/wm1250-ev1.h>
  37. #include <asm/mach/arch.h>
  38. #include <asm/mach-types.h>
  39. #include <video/samsung_fimd.h>
  40. #include "map.h"
  41. #include "regs-gpio.h"
  42. #include "gpio-samsung.h"
  43. #include "irqs.h"
  44. #include "fb.h"
  45. #include "sdhci.h"
  46. #include "gpio-cfg.h"
  47. #include <linux/platform_data/spi-s3c64xx.h>
  48. #include "keypad.h"
  49. #include "devs.h"
  50. #include "cpu.h"
  51. #include <linux/soc/samsung/s3c-adc.h>
  52. #include <linux/platform_data/i2c-s3c2410.h>
  53. #include "pm.h"
  54. #include "s3c64xx.h"
  55. #include "crag6410.h"
  56. #include "regs-gpio-memport-s3c64xx.h"
  57. #include "regs-modem-s3c64xx.h"
  58. #include "regs-sys-s3c64xx.h"
  59. /* serial port setup */
  60. #define UCON (S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK)
  61. #define ULCON (S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB)
  62. #define UFCON (S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE)
  63. static struct s3c2410_uartcfg crag6410_uartcfgs[] __initdata = {
  64. [0] = {
  65. .hwport = 0,
  66. .flags = 0,
  67. .ucon = UCON,
  68. .ulcon = ULCON,
  69. .ufcon = UFCON,
  70. },
  71. [1] = {
  72. .hwport = 1,
  73. .flags = 0,
  74. .ucon = UCON,
  75. .ulcon = ULCON,
  76. .ufcon = UFCON,
  77. },
  78. [2] = {
  79. .hwport = 2,
  80. .flags = 0,
  81. .ucon = UCON,
  82. .ulcon = ULCON,
  83. .ufcon = UFCON,
  84. },
  85. [3] = {
  86. .hwport = 3,
  87. .flags = 0,
  88. .ucon = UCON,
  89. .ulcon = ULCON,
  90. .ufcon = UFCON,
  91. },
  92. };
  93. static struct pwm_lookup crag6410_pwm_lookup[] = {
  94. PWM_LOOKUP("samsung-pwm", 0, "pwm-backlight", NULL, 100000,
  95. PWM_POLARITY_NORMAL),
  96. };
  97. static struct platform_pwm_backlight_data crag6410_backlight_data = {
  98. .max_brightness = 1000,
  99. .dft_brightness = 600,
  100. };
  101. static struct platform_device crag6410_backlight_device = {
  102. .name = "pwm-backlight",
  103. .id = -1,
  104. .dev = {
  105. .parent = &samsung_device_pwm.dev,
  106. .platform_data = &crag6410_backlight_data,
  107. },
  108. };
  109. static void crag6410_lcd_power_set(struct plat_lcd_data *pd, unsigned int power)
  110. {
  111. pr_debug("%s: setting power %d\n", __func__, power);
  112. if (power) {
  113. gpio_set_value(S3C64XX_GPB(0), 1);
  114. msleep(1);
  115. s3c_gpio_cfgpin(S3C64XX_GPF(14), S3C_GPIO_SFN(2));
  116. } else {
  117. gpio_direction_output(S3C64XX_GPF(14), 0);
  118. gpio_set_value(S3C64XX_GPB(0), 0);
  119. }
  120. }
  121. static struct platform_device crag6410_lcd_powerdev = {
  122. .name = "platform-lcd",
  123. .id = -1,
  124. .dev.parent = &s3c_device_fb.dev,
  125. .dev.platform_data = &(struct plat_lcd_data) {
  126. .set_power = crag6410_lcd_power_set,
  127. },
  128. };
  129. /* 640x480 URT */
  130. static struct s3c_fb_pd_win crag6410_fb_win0 = {
  131. .max_bpp = 32,
  132. .default_bpp = 16,
  133. .xres = 640,
  134. .yres = 480,
  135. .virtual_y = 480 * 2,
  136. .virtual_x = 640,
  137. };
  138. static struct fb_videomode crag6410_lcd_timing = {
  139. .left_margin = 150,
  140. .right_margin = 80,
  141. .upper_margin = 40,
  142. .lower_margin = 5,
  143. .hsync_len = 40,
  144. .vsync_len = 5,
  145. .xres = 640,
  146. .yres = 480,
  147. };
  148. /* 405566 clocks per frame => 60Hz refresh requires 24333960Hz clock */
  149. static struct s3c_fb_platdata crag6410_lcd_pdata = {
  150. .setup_gpio = s3c64xx_fb_gpio_setup_24bpp,
  151. .vtiming = &crag6410_lcd_timing,
  152. .win[0] = &crag6410_fb_win0,
  153. .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB,
  154. .vidcon1 = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
  155. };
  156. /* 2x6 keypad */
  157. static uint32_t crag6410_keymap[] = {
  158. /* KEY(row, col, keycode) */
  159. KEY(0, 0, KEY_VOLUMEUP),
  160. KEY(0, 1, KEY_HOME),
  161. KEY(0, 2, KEY_VOLUMEDOWN),
  162. KEY(0, 3, KEY_HELP),
  163. KEY(0, 4, KEY_MENU),
  164. KEY(0, 5, KEY_MEDIA),
  165. KEY(1, 0, 232),
  166. KEY(1, 1, KEY_DOWN),
  167. KEY(1, 2, KEY_LEFT),
  168. KEY(1, 3, KEY_UP),
  169. KEY(1, 4, KEY_RIGHT),
  170. KEY(1, 5, KEY_CAMERA),
  171. };
  172. static struct matrix_keymap_data crag6410_keymap_data = {
  173. .keymap = crag6410_keymap,
  174. .keymap_size = ARRAY_SIZE(crag6410_keymap),
  175. };
  176. static struct samsung_keypad_platdata crag6410_keypad_data = {
  177. .keymap_data = &crag6410_keymap_data,
  178. .rows = 2,
  179. .cols = 6,
  180. };
  181. static struct gpio_keys_button crag6410_gpio_keys[] = {
  182. [0] = {
  183. .code = KEY_SUSPEND,
  184. .gpio = S3C64XX_GPL(10), /* EINT 18 */
  185. .type = EV_KEY,
  186. .wakeup = 1,
  187. .active_low = 1,
  188. },
  189. [1] = {
  190. .code = SW_FRONT_PROXIMITY,
  191. .gpio = S3C64XX_GPN(11), /* EINT 11 */
  192. .type = EV_SW,
  193. },
  194. };
  195. static struct gpio_keys_platform_data crag6410_gpio_keydata = {
  196. .buttons = crag6410_gpio_keys,
  197. .nbuttons = ARRAY_SIZE(crag6410_gpio_keys),
  198. };
  199. static struct platform_device crag6410_gpio_keydev = {
  200. .name = "gpio-keys",
  201. .id = 0,
  202. .dev.platform_data = &crag6410_gpio_keydata,
  203. };
  204. static struct resource crag6410_dm9k_resource[] = {
  205. [0] = DEFINE_RES_MEM(S3C64XX_PA_XM0CSN5, 2),
  206. [1] = DEFINE_RES_MEM(S3C64XX_PA_XM0CSN5 + (1 << 8), 2),
  207. [2] = DEFINE_RES_NAMED(S3C_EINT(17), 1, NULL, IORESOURCE_IRQ \
  208. | IORESOURCE_IRQ_HIGHLEVEL),
  209. };
  210. static struct dm9000_plat_data mini6410_dm9k_pdata = {
  211. .flags = DM9000_PLATF_16BITONLY,
  212. };
  213. static struct platform_device crag6410_dm9k_device = {
  214. .name = "dm9000",
  215. .id = -1,
  216. .num_resources = ARRAY_SIZE(crag6410_dm9k_resource),
  217. .resource = crag6410_dm9k_resource,
  218. .dev.platform_data = &mini6410_dm9k_pdata,
  219. };
  220. static struct resource crag6410_mmgpio_resource[] = {
  221. [0] = DEFINE_RES_MEM_NAMED(S3C64XX_PA_XM0CSN4, 1, "dat"),
  222. };
  223. static struct platform_device crag6410_mmgpio = {
  224. .name = "basic-mmio-gpio",
  225. .id = -1,
  226. .resource = crag6410_mmgpio_resource,
  227. .num_resources = ARRAY_SIZE(crag6410_mmgpio_resource),
  228. .dev.platform_data = &(struct bgpio_pdata) {
  229. .base = MMGPIO_GPIO_BASE,
  230. },
  231. };
  232. static struct platform_device speyside_device = {
  233. .name = "speyside",
  234. .id = -1,
  235. };
  236. static struct platform_device lowland_device = {
  237. .name = "lowland",
  238. .id = -1,
  239. };
  240. static struct platform_device tobermory_device = {
  241. .name = "tobermory",
  242. .id = -1,
  243. };
  244. static struct platform_device littlemill_device = {
  245. .name = "littlemill",
  246. .id = -1,
  247. };
  248. static struct platform_device bells_wm2200_device = {
  249. .name = "bells",
  250. .id = 0,
  251. };
  252. static struct platform_device bells_wm5102_device = {
  253. .name = "bells",
  254. .id = 1,
  255. };
  256. static struct platform_device bells_wm5110_device = {
  257. .name = "bells",
  258. .id = 2,
  259. };
  260. static struct regulator_consumer_supply wallvdd_consumers[] = {
  261. REGULATOR_SUPPLY("SPKVDD", "1-001a"),
  262. REGULATOR_SUPPLY("SPKVDD1", "1-001a"),
  263. REGULATOR_SUPPLY("SPKVDD2", "1-001a"),
  264. REGULATOR_SUPPLY("SPKVDDL", "1-001a"),
  265. REGULATOR_SUPPLY("SPKVDDR", "1-001a"),
  266. REGULATOR_SUPPLY("SPKVDDL", "spi0.1"),
  267. REGULATOR_SUPPLY("SPKVDDR", "spi0.1"),
  268. REGULATOR_SUPPLY("DC1VDD", "0-0034"),
  269. REGULATOR_SUPPLY("DC2VDD", "0-0034"),
  270. REGULATOR_SUPPLY("DC3VDD", "0-0034"),
  271. REGULATOR_SUPPLY("LDO1VDD", "0-0034"),
  272. REGULATOR_SUPPLY("LDO2VDD", "0-0034"),
  273. REGULATOR_SUPPLY("LDO4VDD", "0-0034"),
  274. REGULATOR_SUPPLY("LDO5VDD", "0-0034"),
  275. REGULATOR_SUPPLY("LDO6VDD", "0-0034"),
  276. REGULATOR_SUPPLY("LDO7VDD", "0-0034"),
  277. REGULATOR_SUPPLY("LDO8VDD", "0-0034"),
  278. REGULATOR_SUPPLY("LDO9VDD", "0-0034"),
  279. REGULATOR_SUPPLY("LDO10VDD", "0-0034"),
  280. REGULATOR_SUPPLY("LDO11VDD", "0-0034"),
  281. REGULATOR_SUPPLY("DC1VDD", "1-0034"),
  282. REGULATOR_SUPPLY("DC2VDD", "1-0034"),
  283. REGULATOR_SUPPLY("DC3VDD", "1-0034"),
  284. REGULATOR_SUPPLY("LDO1VDD", "1-0034"),
  285. REGULATOR_SUPPLY("LDO2VDD", "1-0034"),
  286. REGULATOR_SUPPLY("LDO4VDD", "1-0034"),
  287. REGULATOR_SUPPLY("LDO5VDD", "1-0034"),
  288. REGULATOR_SUPPLY("LDO6VDD", "1-0034"),
  289. REGULATOR_SUPPLY("LDO7VDD", "1-0034"),
  290. REGULATOR_SUPPLY("LDO8VDD", "1-0034"),
  291. REGULATOR_SUPPLY("LDO9VDD", "1-0034"),
  292. REGULATOR_SUPPLY("LDO10VDD", "1-0034"),
  293. REGULATOR_SUPPLY("LDO11VDD", "1-0034"),
  294. };
  295. static struct regulator_init_data wallvdd_data = {
  296. .constraints = {
  297. .always_on = 1,
  298. },
  299. .num_consumer_supplies = ARRAY_SIZE(wallvdd_consumers),
  300. .consumer_supplies = wallvdd_consumers,
  301. };
  302. static struct fixed_voltage_config wallvdd_pdata = {
  303. .supply_name = "WALLVDD",
  304. .microvolts = 5000000,
  305. .init_data = &wallvdd_data,
  306. };
  307. static struct platform_device wallvdd_device = {
  308. .name = "reg-fixed-voltage",
  309. .id = -1,
  310. .dev = {
  311. .platform_data = &wallvdd_pdata,
  312. },
  313. };
  314. static struct platform_device *crag6410_devices[] __initdata = {
  315. &s3c_device_hsmmc0,
  316. &s3c_device_hsmmc2,
  317. &s3c_device_i2c0,
  318. &s3c_device_i2c1,
  319. &s3c_device_fb,
  320. &s3c_device_ohci,
  321. &s3c_device_usb_hsotg,
  322. &samsung_device_pwm,
  323. &s3c64xx_device_iis0,
  324. &s3c64xx_device_iis1,
  325. &samsung_device_keypad,
  326. &crag6410_gpio_keydev,
  327. &crag6410_dm9k_device,
  328. &s3c64xx_device_spi0,
  329. &crag6410_mmgpio,
  330. &crag6410_lcd_powerdev,
  331. &crag6410_backlight_device,
  332. &speyside_device,
  333. &tobermory_device,
  334. &littlemill_device,
  335. &lowland_device,
  336. &bells_wm2200_device,
  337. &bells_wm5102_device,
  338. &bells_wm5110_device,
  339. &wallvdd_device,
  340. };
  341. static struct pca953x_platform_data crag6410_pca_data = {
  342. .gpio_base = PCA935X_GPIO_BASE,
  343. .irq_base = -1,
  344. };
  345. /* VDDARM is controlled by DVS1 connected to GPK(0) */
  346. static struct wm831x_buckv_pdata vddarm_pdata = {
  347. .dvs_control_src = 1,
  348. };
  349. static struct regulator_consumer_supply vddarm_consumers[] = {
  350. REGULATOR_SUPPLY("vddarm", NULL),
  351. };
  352. static struct regulator_init_data vddarm = {
  353. .constraints = {
  354. .name = "VDDARM",
  355. .min_uV = 1000000,
  356. .max_uV = 1300000,
  357. .always_on = 1,
  358. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
  359. },
  360. .num_consumer_supplies = ARRAY_SIZE(vddarm_consumers),
  361. .consumer_supplies = vddarm_consumers,
  362. .supply_regulator = "WALLVDD",
  363. .driver_data = &vddarm_pdata,
  364. };
  365. static struct regulator_consumer_supply vddint_consumers[] = {
  366. REGULATOR_SUPPLY("vddint", NULL),
  367. };
  368. static struct regulator_init_data vddint = {
  369. .constraints = {
  370. .name = "VDDINT",
  371. .min_uV = 1000000,
  372. .max_uV = 1200000,
  373. .always_on = 1,
  374. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
  375. },
  376. .num_consumer_supplies = ARRAY_SIZE(vddint_consumers),
  377. .consumer_supplies = vddint_consumers,
  378. .supply_regulator = "WALLVDD",
  379. };
  380. static struct regulator_init_data vddmem = {
  381. .constraints = {
  382. .name = "VDDMEM",
  383. .always_on = 1,
  384. },
  385. };
  386. static struct regulator_init_data vddsys = {
  387. .constraints = {
  388. .name = "VDDSYS,VDDEXT,VDDPCM,VDDSS",
  389. .always_on = 1,
  390. },
  391. };
  392. static struct regulator_consumer_supply vddmmc_consumers[] = {
  393. REGULATOR_SUPPLY("vmmc", "s3c-sdhci.0"),
  394. REGULATOR_SUPPLY("vmmc", "s3c-sdhci.1"),
  395. REGULATOR_SUPPLY("vmmc", "s3c-sdhci.2"),
  396. };
  397. static struct regulator_init_data vddmmc = {
  398. .constraints = {
  399. .name = "VDDMMC,UH",
  400. .always_on = 1,
  401. },
  402. .num_consumer_supplies = ARRAY_SIZE(vddmmc_consumers),
  403. .consumer_supplies = vddmmc_consumers,
  404. .supply_regulator = "WALLVDD",
  405. };
  406. static struct regulator_init_data vddotgi = {
  407. .constraints = {
  408. .name = "VDDOTGi",
  409. .always_on = 1,
  410. },
  411. .supply_regulator = "WALLVDD",
  412. };
  413. static struct regulator_init_data vddotg = {
  414. .constraints = {
  415. .name = "VDDOTG",
  416. .always_on = 1,
  417. },
  418. .supply_regulator = "WALLVDD",
  419. };
  420. static struct regulator_init_data vddhi = {
  421. .constraints = {
  422. .name = "VDDHI",
  423. .always_on = 1,
  424. },
  425. .supply_regulator = "WALLVDD",
  426. };
  427. static struct regulator_init_data vddadc = {
  428. .constraints = {
  429. .name = "VDDADC,VDDDAC",
  430. .always_on = 1,
  431. },
  432. .supply_regulator = "WALLVDD",
  433. };
  434. static struct regulator_init_data vddmem0 = {
  435. .constraints = {
  436. .name = "VDDMEM0",
  437. .always_on = 1,
  438. },
  439. .supply_regulator = "WALLVDD",
  440. };
  441. static struct regulator_init_data vddpll = {
  442. .constraints = {
  443. .name = "VDDPLL",
  444. .always_on = 1,
  445. },
  446. .supply_regulator = "WALLVDD",
  447. };
  448. static struct regulator_init_data vddlcd = {
  449. .constraints = {
  450. .name = "VDDLCD",
  451. .always_on = 1,
  452. },
  453. .supply_regulator = "WALLVDD",
  454. };
  455. static struct regulator_init_data vddalive = {
  456. .constraints = {
  457. .name = "VDDALIVE",
  458. .always_on = 1,
  459. },
  460. .supply_regulator = "WALLVDD",
  461. };
  462. static struct wm831x_backup_pdata banff_backup_pdata = {
  463. .charger_enable = 1,
  464. .vlim = 2500, /* mV */
  465. .ilim = 200, /* uA */
  466. };
  467. static struct wm831x_status_pdata banff_red_led = {
  468. .name = "banff:red:",
  469. .default_src = WM831X_STATUS_MANUAL,
  470. };
  471. static struct wm831x_status_pdata banff_green_led = {
  472. .name = "banff:green:",
  473. .default_src = WM831X_STATUS_MANUAL,
  474. };
  475. static struct wm831x_touch_pdata touch_pdata = {
  476. .data_irq = S3C_EINT(26),
  477. .pd_irq = S3C_EINT(27),
  478. };
  479. static struct wm831x_pdata crag_pmic_pdata = {
  480. .wm831x_num = 1,
  481. .irq_base = BANFF_PMIC_IRQ_BASE,
  482. .gpio_base = BANFF_PMIC_GPIO_BASE,
  483. .soft_shutdown = true,
  484. .backup = &banff_backup_pdata,
  485. .gpio_defaults = {
  486. /* GPIO5: DVS1_REQ - CMOS, DBVDD, active high */
  487. [4] = WM831X_GPN_DIR | WM831X_GPN_POL | WM831X_GPN_ENA | 0x8,
  488. /* GPIO11: Touchscreen data - CMOS, DBVDD, active high*/
  489. [10] = WM831X_GPN_POL | WM831X_GPN_ENA | 0x6,
  490. /* GPIO12: Touchscreen pen down - CMOS, DBVDD, active high*/
  491. [11] = WM831X_GPN_POL | WM831X_GPN_ENA | 0x7,
  492. },
  493. .dcdc = {
  494. &vddarm, /* DCDC1 */
  495. &vddint, /* DCDC2 */
  496. &vddmem, /* DCDC3 */
  497. },
  498. .ldo = {
  499. &vddsys, /* LDO1 */
  500. &vddmmc, /* LDO2 */
  501. NULL, /* LDO3 */
  502. &vddotgi, /* LDO4 */
  503. &vddotg, /* LDO5 */
  504. &vddhi, /* LDO6 */
  505. &vddadc, /* LDO7 */
  506. &vddmem0, /* LDO8 */
  507. &vddpll, /* LDO9 */
  508. &vddlcd, /* LDO10 */
  509. &vddalive, /* LDO11 */
  510. },
  511. .status = {
  512. &banff_green_led,
  513. &banff_red_led,
  514. },
  515. .touch = &touch_pdata,
  516. };
  517. /*
  518. * VDDARM is eventually ending up as a regulator hanging on the MFD cell device
  519. * "wm831x-buckv.1" spawn from drivers/mfd/wm831x-core.c.
  520. *
  521. * From the note on the platform data we can see that this is clearly DVS1
  522. * and assigned as dcdc1 resource to the MFD core which sets .id of the cell
  523. * spawning the DVS1 platform device to 1, then the cell platform device
  524. * name is calculated from 10*instance + id resulting in the device name
  525. * "wm831x-buckv.11"
  526. */
  527. static struct gpiod_lookup_table crag_pmic_gpiod_table = {
  528. .dev_id = "wm831x-buckv.11",
  529. .table = {
  530. GPIO_LOOKUP("GPIOK", 0, "dvs", GPIO_ACTIVE_HIGH),
  531. { },
  532. },
  533. };
  534. static struct i2c_board_info i2c_devs0[] = {
  535. { I2C_BOARD_INFO("24c08", 0x50), },
  536. { I2C_BOARD_INFO("tca6408", 0x20),
  537. .platform_data = &crag6410_pca_data,
  538. },
  539. { I2C_BOARD_INFO("wm8312", 0x34),
  540. .platform_data = &crag_pmic_pdata,
  541. .irq = S3C_EINT(23),
  542. },
  543. };
  544. static struct s3c2410_platform_i2c i2c0_pdata = {
  545. .frequency = 400000,
  546. };
  547. static struct regulator_consumer_supply pvdd_1v2_consumers[] = {
  548. REGULATOR_SUPPLY("DCVDD", "spi0.0"),
  549. REGULATOR_SUPPLY("AVDD", "spi0.0"),
  550. REGULATOR_SUPPLY("AVDD", "spi0.1"),
  551. };
  552. static struct regulator_init_data pvdd_1v2 = {
  553. .constraints = {
  554. .name = "PVDD_1V2",
  555. .valid_ops_mask = REGULATOR_CHANGE_STATUS,
  556. },
  557. .consumer_supplies = pvdd_1v2_consumers,
  558. .num_consumer_supplies = ARRAY_SIZE(pvdd_1v2_consumers),
  559. };
  560. static struct regulator_consumer_supply pvdd_1v8_consumers[] = {
  561. REGULATOR_SUPPLY("LDOVDD", "1-001a"),
  562. REGULATOR_SUPPLY("PLLVDD", "1-001a"),
  563. REGULATOR_SUPPLY("DBVDD", "1-001a"),
  564. REGULATOR_SUPPLY("DBVDD1", "1-001a"),
  565. REGULATOR_SUPPLY("DBVDD2", "1-001a"),
  566. REGULATOR_SUPPLY("DBVDD3", "1-001a"),
  567. REGULATOR_SUPPLY("CPVDD", "1-001a"),
  568. REGULATOR_SUPPLY("AVDD2", "1-001a"),
  569. REGULATOR_SUPPLY("DCVDD", "1-001a"),
  570. REGULATOR_SUPPLY("AVDD", "1-001a"),
  571. REGULATOR_SUPPLY("DBVDD", "spi0.0"),
  572. REGULATOR_SUPPLY("DBVDD", "1-003a"),
  573. REGULATOR_SUPPLY("LDOVDD", "1-003a"),
  574. REGULATOR_SUPPLY("CPVDD", "1-003a"),
  575. REGULATOR_SUPPLY("AVDD", "1-003a"),
  576. REGULATOR_SUPPLY("DBVDD1", "spi0.1"),
  577. REGULATOR_SUPPLY("DBVDD2", "spi0.1"),
  578. REGULATOR_SUPPLY("DBVDD3", "spi0.1"),
  579. REGULATOR_SUPPLY("LDOVDD", "spi0.1"),
  580. REGULATOR_SUPPLY("CPVDD", "spi0.1"),
  581. };
  582. static struct regulator_init_data pvdd_1v8 = {
  583. .constraints = {
  584. .name = "PVDD_1V8",
  585. .always_on = 1,
  586. },
  587. .consumer_supplies = pvdd_1v8_consumers,
  588. .num_consumer_supplies = ARRAY_SIZE(pvdd_1v8_consumers),
  589. };
  590. static struct regulator_consumer_supply pvdd_3v3_consumers[] = {
  591. REGULATOR_SUPPLY("MICVDD", "1-001a"),
  592. REGULATOR_SUPPLY("AVDD1", "1-001a"),
  593. };
  594. static struct regulator_init_data pvdd_3v3 = {
  595. .constraints = {
  596. .name = "PVDD_3V3",
  597. .always_on = 1,
  598. },
  599. .consumer_supplies = pvdd_3v3_consumers,
  600. .num_consumer_supplies = ARRAY_SIZE(pvdd_3v3_consumers),
  601. };
  602. static struct wm831x_pdata glenfarclas_pmic_pdata = {
  603. .wm831x_num = 2,
  604. .irq_base = GLENFARCLAS_PMIC_IRQ_BASE,
  605. .gpio_base = GLENFARCLAS_PMIC_GPIO_BASE,
  606. .soft_shutdown = true,
  607. .gpio_defaults = {
  608. /* GPIO1-3: IRQ inputs, rising edge triggered, CMOS */
  609. [0] = WM831X_GPN_DIR | WM831X_GPN_POL | WM831X_GPN_ENA,
  610. [1] = WM831X_GPN_DIR | WM831X_GPN_POL | WM831X_GPN_ENA,
  611. [2] = WM831X_GPN_DIR | WM831X_GPN_POL | WM831X_GPN_ENA,
  612. },
  613. .dcdc = {
  614. &pvdd_1v2, /* DCDC1 */
  615. &pvdd_1v8, /* DCDC2 */
  616. &pvdd_3v3, /* DCDC3 */
  617. },
  618. .disable_touch = true,
  619. };
  620. static struct wm1250_ev1_pdata wm1250_ev1_pdata = {
  621. .gpios = {
  622. [WM1250_EV1_GPIO_CLK_ENA] = S3C64XX_GPN(12),
  623. [WM1250_EV1_GPIO_CLK_SEL0] = S3C64XX_GPL(12),
  624. [WM1250_EV1_GPIO_CLK_SEL1] = S3C64XX_GPL(13),
  625. [WM1250_EV1_GPIO_OSR] = S3C64XX_GPL(14),
  626. [WM1250_EV1_GPIO_MASTER] = S3C64XX_GPL(8),
  627. },
  628. };
  629. static struct i2c_board_info i2c_devs1[] = {
  630. { I2C_BOARD_INFO("wm8311", 0x34),
  631. .irq = S3C_EINT(0),
  632. .platform_data = &glenfarclas_pmic_pdata },
  633. { I2C_BOARD_INFO("wlf-gf-module", 0x20) },
  634. { I2C_BOARD_INFO("wlf-gf-module", 0x22) },
  635. { I2C_BOARD_INFO("wlf-gf-module", 0x24) },
  636. { I2C_BOARD_INFO("wlf-gf-module", 0x25) },
  637. { I2C_BOARD_INFO("wlf-gf-module", 0x26) },
  638. { I2C_BOARD_INFO("wm1250-ev1", 0x27),
  639. .platform_data = &wm1250_ev1_pdata },
  640. };
  641. static struct s3c2410_platform_i2c i2c1_pdata = {
  642. .frequency = 400000,
  643. .bus_num = 1,
  644. };
  645. static void __init crag6410_map_io(void)
  646. {
  647. s3c64xx_init_io(NULL, 0);
  648. s3c64xx_set_xtal_freq(12000000);
  649. s3c24xx_init_uarts(crag6410_uartcfgs, ARRAY_SIZE(crag6410_uartcfgs));
  650. s3c64xx_set_timer_source(S3C64XX_PWM3, S3C64XX_PWM4);
  651. /* LCD type and Bypass set by bootloader */
  652. }
  653. static struct s3c_sdhci_platdata crag6410_hsmmc2_pdata = {
  654. .max_width = 4,
  655. .cd_type = S3C_SDHCI_CD_PERMANENT,
  656. .host_caps = MMC_CAP_POWER_OFF_CARD,
  657. };
  658. static void crag6410_cfg_sdhci0(struct platform_device *dev, int width)
  659. {
  660. /* Set all the necessary GPG pins to special-function 2 */
  661. s3c_gpio_cfgrange_nopull(S3C64XX_GPG(0), 2 + width, S3C_GPIO_SFN(2));
  662. /* force card-detected for prototype 0 */
  663. s3c_gpio_setpull(S3C64XX_GPG(6), S3C_GPIO_PULL_DOWN);
  664. }
  665. static struct s3c_sdhci_platdata crag6410_hsmmc0_pdata = {
  666. .max_width = 4,
  667. .cd_type = S3C_SDHCI_CD_INTERNAL,
  668. .cfg_gpio = crag6410_cfg_sdhci0,
  669. .host_caps = MMC_CAP_POWER_OFF_CARD,
  670. };
  671. static const struct gpio_led gpio_leds[] = {
  672. {
  673. .name = "d13:green:",
  674. .gpio = MMGPIO_GPIO_BASE + 0,
  675. .default_state = LEDS_GPIO_DEFSTATE_ON,
  676. },
  677. {
  678. .name = "d14:green:",
  679. .gpio = MMGPIO_GPIO_BASE + 1,
  680. .default_state = LEDS_GPIO_DEFSTATE_ON,
  681. },
  682. {
  683. .name = "d15:green:",
  684. .gpio = MMGPIO_GPIO_BASE + 2,
  685. .default_state = LEDS_GPIO_DEFSTATE_ON,
  686. },
  687. {
  688. .name = "d16:green:",
  689. .gpio = MMGPIO_GPIO_BASE + 3,
  690. .default_state = LEDS_GPIO_DEFSTATE_ON,
  691. },
  692. {
  693. .name = "d17:green:",
  694. .gpio = MMGPIO_GPIO_BASE + 4,
  695. .default_state = LEDS_GPIO_DEFSTATE_ON,
  696. },
  697. {
  698. .name = "d18:green:",
  699. .gpio = MMGPIO_GPIO_BASE + 5,
  700. .default_state = LEDS_GPIO_DEFSTATE_ON,
  701. },
  702. {
  703. .name = "d19:green:",
  704. .gpio = MMGPIO_GPIO_BASE + 6,
  705. .default_state = LEDS_GPIO_DEFSTATE_ON,
  706. },
  707. {
  708. .name = "d20:green:",
  709. .gpio = MMGPIO_GPIO_BASE + 7,
  710. .default_state = LEDS_GPIO_DEFSTATE_ON,
  711. },
  712. };
  713. static const struct gpio_led_platform_data gpio_leds_pdata = {
  714. .leds = gpio_leds,
  715. .num_leds = ARRAY_SIZE(gpio_leds),
  716. };
  717. static struct dwc2_hsotg_plat crag6410_hsotg_pdata;
  718. static struct gpiod_lookup_table crag_spi0_gpiod_table = {
  719. .dev_id = "s3c6410-spi.0",
  720. .table = {
  721. GPIO_LOOKUP_IDX("GPIOC", 3, "cs", 0, GPIO_ACTIVE_LOW),
  722. GPIO_LOOKUP_IDX("GPION", 5, "cs", 1, GPIO_ACTIVE_LOW),
  723. { },
  724. },
  725. };
  726. static void __init crag6410_machine_init(void)
  727. {
  728. /* Open drain IRQs need pullups */
  729. s3c_gpio_setpull(S3C64XX_GPM(0), S3C_GPIO_PULL_UP);
  730. s3c_gpio_setpull(S3C64XX_GPN(0), S3C_GPIO_PULL_UP);
  731. gpio_request(S3C64XX_GPB(0), "LCD power");
  732. gpio_direction_output(S3C64XX_GPB(0), 0);
  733. gpio_request(S3C64XX_GPF(14), "LCD PWM");
  734. gpio_direction_output(S3C64XX_GPF(14), 0); /* turn off */
  735. gpio_request(S3C64XX_GPB(1), "SD power");
  736. gpio_direction_output(S3C64XX_GPB(1), 0);
  737. gpio_request(S3C64XX_GPF(10), "nRESETSEL");
  738. gpio_direction_output(S3C64XX_GPF(10), 1);
  739. s3c_sdhci0_set_platdata(&crag6410_hsmmc0_pdata);
  740. s3c_sdhci2_set_platdata(&crag6410_hsmmc2_pdata);
  741. s3c_i2c0_set_platdata(&i2c0_pdata);
  742. s3c_i2c1_set_platdata(&i2c1_pdata);
  743. s3c_fb_set_platdata(&crag6410_lcd_pdata);
  744. dwc2_hsotg_set_platdata(&crag6410_hsotg_pdata);
  745. gpiod_add_lookup_table(&crag_pmic_gpiod_table);
  746. i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0));
  747. i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
  748. samsung_keypad_set_platdata(&crag6410_keypad_data);
  749. gpiod_add_lookup_table(&crag_spi0_gpiod_table);
  750. s3c64xx_spi0_set_platdata(0, 2);
  751. pwm_add_table(crag6410_pwm_lookup, ARRAY_SIZE(crag6410_pwm_lookup));
  752. platform_add_devices(crag6410_devices, ARRAY_SIZE(crag6410_devices));
  753. gpio_led_register_device(-1, &gpio_leds_pdata);
  754. regulator_has_full_constraints();
  755. s3c64xx_pm_init();
  756. }
  757. MACHINE_START(WLF_CRAGG_6410, "Wolfson Cragganmore 6410")
  758. /* Maintainer: Mark Brown <[email protected]> */
  759. .atag_offset = 0x100,
  760. .nr_irqs = S3C64XX_NR_IRQS,
  761. .init_irq = s3c6410_init_irq,
  762. .map_io = crag6410_map_io,
  763. .init_machine = crag6410_machine_init,
  764. .init_time = s3c64xx_timer_init,
  765. MACHINE_END