acpi_lpss.c 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168
  1. /*
  2. * ACPI support for Intel Lynxpoint LPSS.
  3. *
  4. * Copyright (C) 2013, Intel Corporation
  5. * Authors: Mika Westerberg <mika.westerberg@linux.intel.com>
  6. * Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #include <linux/acpi.h>
  13. #include <linux/clkdev.h>
  14. #include <linux/clk-provider.h>
  15. #include <linux/err.h>
  16. #include <linux/io.h>
  17. #include <linux/mutex.h>
  18. #include <linux/platform_device.h>
  19. #include <linux/platform_data/clk-lpss.h>
  20. #include <linux/platform_data/x86/pmc_atom.h>
  21. #include <linux/pm_domain.h>
  22. #include <linux/pm_runtime.h>
  23. #include <linux/pwm.h>
  24. #include <linux/delay.h>
  25. #include "internal.h"
  26. ACPI_MODULE_NAME("acpi_lpss");
  27. #ifdef CONFIG_X86_INTEL_LPSS
  28. #include <asm/cpu_device_id.h>
  29. #include <asm/intel-family.h>
  30. #include <asm/iosf_mbi.h>
  31. #define LPSS_ADDR(desc) ((unsigned long)&desc)
  32. #define LPSS_CLK_SIZE 0x04
  33. #define LPSS_LTR_SIZE 0x18
  34. /* Offsets relative to LPSS_PRIVATE_OFFSET */
  35. #define LPSS_CLK_DIVIDER_DEF_MASK (BIT(1) | BIT(16))
  36. #define LPSS_RESETS 0x04
  37. #define LPSS_RESETS_RESET_FUNC BIT(0)
  38. #define LPSS_RESETS_RESET_APB BIT(1)
  39. #define LPSS_GENERAL 0x08
  40. #define LPSS_GENERAL_LTR_MODE_SW BIT(2)
  41. #define LPSS_GENERAL_UART_RTS_OVRD BIT(3)
  42. #define LPSS_SW_LTR 0x10
  43. #define LPSS_AUTO_LTR 0x14
  44. #define LPSS_LTR_SNOOP_REQ BIT(15)
  45. #define LPSS_LTR_SNOOP_MASK 0x0000FFFF
  46. #define LPSS_LTR_SNOOP_LAT_1US 0x800
  47. #define LPSS_LTR_SNOOP_LAT_32US 0xC00
  48. #define LPSS_LTR_SNOOP_LAT_SHIFT 5
  49. #define LPSS_LTR_SNOOP_LAT_CUTOFF 3000
  50. #define LPSS_LTR_MAX_VAL 0x3FF
  51. #define LPSS_TX_INT 0x20
  52. #define LPSS_TX_INT_MASK BIT(1)
  53. #define LPSS_PRV_REG_COUNT 9
  54. /* LPSS Flags */
  55. #define LPSS_CLK BIT(0)
  56. #define LPSS_CLK_GATE BIT(1)
  57. #define LPSS_CLK_DIVIDER BIT(2)
  58. #define LPSS_LTR BIT(3)
  59. #define LPSS_SAVE_CTX BIT(4)
  60. #define LPSS_NO_D3_DELAY BIT(5)
  61. /* Crystal Cove PMIC shares same ACPI ID between different platforms */
  62. #define BYT_CRC_HRV 2
  63. #define CHT_CRC_HRV 3
  64. struct lpss_private_data;
  65. struct lpss_device_desc {
  66. unsigned int flags;
  67. const char *clk_con_id;
  68. unsigned int prv_offset;
  69. size_t prv_size_override;
  70. struct property_entry *properties;
  71. void (*setup)(struct lpss_private_data *pdata);
  72. };
  73. static const struct lpss_device_desc lpss_dma_desc = {
  74. .flags = LPSS_CLK,
  75. };
  76. struct lpss_private_data {
  77. struct acpi_device *adev;
  78. void __iomem *mmio_base;
  79. resource_size_t mmio_size;
  80. unsigned int fixed_clk_rate;
  81. struct clk *clk;
  82. const struct lpss_device_desc *dev_desc;
  83. u32 prv_reg_ctx[LPSS_PRV_REG_COUNT];
  84. };
  85. /* LPSS run time quirks */
  86. static unsigned int lpss_quirks;
  87. /*
  88. * LPSS_QUIRK_ALWAYS_POWER_ON: override power state for LPSS DMA device.
  89. *
  90. * The LPSS DMA controller has neither _PS0 nor _PS3 method. Moreover
  91. * it can be powered off automatically whenever the last LPSS device goes down.
  92. * In case of no power any access to the DMA controller will hang the system.
  93. * The behaviour is reproduced on some HP laptops based on Intel BayTrail as
  94. * well as on ASuS T100TA transformer.
  95. *
  96. * This quirk overrides power state of entire LPSS island to keep DMA powered
  97. * on whenever we have at least one other device in use.
  98. */
  99. #define LPSS_QUIRK_ALWAYS_POWER_ON BIT(0)
  100. /* UART Component Parameter Register */
  101. #define LPSS_UART_CPR 0xF4
  102. #define LPSS_UART_CPR_AFCE BIT(4)
  103. static void lpss_uart_setup(struct lpss_private_data *pdata)
  104. {
  105. unsigned int offset;
  106. u32 val;
  107. offset = pdata->dev_desc->prv_offset + LPSS_TX_INT;
  108. val = readl(pdata->mmio_base + offset);
  109. writel(val | LPSS_TX_INT_MASK, pdata->mmio_base + offset);
  110. val = readl(pdata->mmio_base + LPSS_UART_CPR);
  111. if (!(val & LPSS_UART_CPR_AFCE)) {
  112. offset = pdata->dev_desc->prv_offset + LPSS_GENERAL;
  113. val = readl(pdata->mmio_base + offset);
  114. val |= LPSS_GENERAL_UART_RTS_OVRD;
  115. writel(val, pdata->mmio_base + offset);
  116. }
  117. }
  118. static void lpss_deassert_reset(struct lpss_private_data *pdata)
  119. {
  120. unsigned int offset;
  121. u32 val;
  122. offset = pdata->dev_desc->prv_offset + LPSS_RESETS;
  123. val = readl(pdata->mmio_base + offset);
  124. val |= LPSS_RESETS_RESET_APB | LPSS_RESETS_RESET_FUNC;
  125. writel(val, pdata->mmio_base + offset);
  126. }
  127. /*
  128. * BYT PWM used for backlight control by the i915 driver on systems without
  129. * the Crystal Cove PMIC.
  130. */
  131. static struct pwm_lookup byt_pwm_lookup[] = {
  132. PWM_LOOKUP_WITH_MODULE("80860F09:00", 0, "0000:00:02.0",
  133. "pwm_backlight", 0, PWM_POLARITY_NORMAL,
  134. "pwm-lpss-platform"),
  135. };
  136. static void byt_pwm_setup(struct lpss_private_data *pdata)
  137. {
  138. struct acpi_device *adev = pdata->adev;
  139. /* Only call pwm_add_table for the first PWM controller */
  140. if (!adev->pnp.unique_id || strcmp(adev->pnp.unique_id, "1"))
  141. return;
  142. if (!acpi_dev_present("INT33FD", NULL, BYT_CRC_HRV))
  143. pwm_add_table(byt_pwm_lookup, ARRAY_SIZE(byt_pwm_lookup));
  144. }
  145. #define LPSS_I2C_ENABLE 0x6c
  146. static void byt_i2c_setup(struct lpss_private_data *pdata)
  147. {
  148. lpss_deassert_reset(pdata);
  149. if (readl(pdata->mmio_base + pdata->dev_desc->prv_offset))
  150. pdata->fixed_clk_rate = 133000000;
  151. writel(0, pdata->mmio_base + LPSS_I2C_ENABLE);
  152. }
  153. /* BSW PWM used for backlight control by the i915 driver */
  154. static struct pwm_lookup bsw_pwm_lookup[] = {
  155. PWM_LOOKUP_WITH_MODULE("80862288:00", 0, "0000:00:02.0",
  156. "pwm_backlight", 0, PWM_POLARITY_NORMAL,
  157. "pwm-lpss-platform"),
  158. };
  159. static void bsw_pwm_setup(struct lpss_private_data *pdata)
  160. {
  161. struct acpi_device *adev = pdata->adev;
  162. /* Only call pwm_add_table for the first PWM controller */
  163. if (!adev->pnp.unique_id || strcmp(adev->pnp.unique_id, "1"))
  164. return;
  165. pwm_add_table(bsw_pwm_lookup, ARRAY_SIZE(bsw_pwm_lookup));
  166. }
  167. static const struct lpss_device_desc lpt_dev_desc = {
  168. .flags = LPSS_CLK | LPSS_CLK_GATE | LPSS_CLK_DIVIDER | LPSS_LTR,
  169. .prv_offset = 0x800,
  170. };
  171. static const struct lpss_device_desc lpt_i2c_dev_desc = {
  172. .flags = LPSS_CLK | LPSS_CLK_GATE | LPSS_LTR,
  173. .prv_offset = 0x800,
  174. };
  175. static struct property_entry uart_properties[] = {
  176. PROPERTY_ENTRY_U32("reg-io-width", 4),
  177. PROPERTY_ENTRY_U32("reg-shift", 2),
  178. PROPERTY_ENTRY_BOOL("snps,uart-16550-compatible"),
  179. { },
  180. };
  181. static const struct lpss_device_desc lpt_uart_dev_desc = {
  182. .flags = LPSS_CLK | LPSS_CLK_GATE | LPSS_CLK_DIVIDER | LPSS_LTR,
  183. .clk_con_id = "baudclk",
  184. .prv_offset = 0x800,
  185. .setup = lpss_uart_setup,
  186. .properties = uart_properties,
  187. };
  188. static const struct lpss_device_desc lpt_sdio_dev_desc = {
  189. .flags = LPSS_LTR,
  190. .prv_offset = 0x1000,
  191. .prv_size_override = 0x1018,
  192. };
  193. static const struct lpss_device_desc byt_pwm_dev_desc = {
  194. .flags = LPSS_SAVE_CTX,
  195. .prv_offset = 0x800,
  196. .setup = byt_pwm_setup,
  197. };
  198. static const struct lpss_device_desc bsw_pwm_dev_desc = {
  199. .flags = LPSS_SAVE_CTX | LPSS_NO_D3_DELAY,
  200. .prv_offset = 0x800,
  201. .setup = bsw_pwm_setup,
  202. };
  203. static const struct lpss_device_desc byt_uart_dev_desc = {
  204. .flags = LPSS_CLK | LPSS_CLK_GATE | LPSS_CLK_DIVIDER | LPSS_SAVE_CTX,
  205. .clk_con_id = "baudclk",
  206. .prv_offset = 0x800,
  207. .setup = lpss_uart_setup,
  208. .properties = uart_properties,
  209. };
  210. static const struct lpss_device_desc bsw_uart_dev_desc = {
  211. .flags = LPSS_CLK | LPSS_CLK_GATE | LPSS_CLK_DIVIDER | LPSS_SAVE_CTX
  212. | LPSS_NO_D3_DELAY,
  213. .clk_con_id = "baudclk",
  214. .prv_offset = 0x800,
  215. .setup = lpss_uart_setup,
  216. .properties = uart_properties,
  217. };
  218. static const struct lpss_device_desc byt_spi_dev_desc = {
  219. .flags = LPSS_CLK | LPSS_CLK_GATE | LPSS_CLK_DIVIDER | LPSS_SAVE_CTX,
  220. .prv_offset = 0x400,
  221. };
  222. static const struct lpss_device_desc byt_sdio_dev_desc = {
  223. .flags = LPSS_CLK,
  224. };
  225. static const struct lpss_device_desc byt_i2c_dev_desc = {
  226. .flags = LPSS_CLK | LPSS_SAVE_CTX,
  227. .prv_offset = 0x800,
  228. .setup = byt_i2c_setup,
  229. };
  230. static const struct lpss_device_desc bsw_i2c_dev_desc = {
  231. .flags = LPSS_CLK | LPSS_SAVE_CTX | LPSS_NO_D3_DELAY,
  232. .prv_offset = 0x800,
  233. .setup = byt_i2c_setup,
  234. };
  235. static const struct lpss_device_desc bsw_spi_dev_desc = {
  236. .flags = LPSS_CLK | LPSS_CLK_GATE | LPSS_CLK_DIVIDER | LPSS_SAVE_CTX
  237. | LPSS_NO_D3_DELAY,
  238. .prv_offset = 0x400,
  239. .setup = lpss_deassert_reset,
  240. };
  241. #define ICPU(model) { X86_VENDOR_INTEL, 6, model, X86_FEATURE_ANY, }
  242. static const struct x86_cpu_id lpss_cpu_ids[] = {
  243. ICPU(INTEL_FAM6_ATOM_SILVERMONT1), /* Valleyview, Bay Trail */
  244. ICPU(INTEL_FAM6_ATOM_AIRMONT), /* Braswell, Cherry Trail */
  245. {}
  246. };
  247. #else
  248. #define LPSS_ADDR(desc) (0UL)
  249. #endif /* CONFIG_X86_INTEL_LPSS */
  250. static const struct acpi_device_id acpi_lpss_device_ids[] = {
  251. /* Generic LPSS devices */
  252. { "INTL9C60", LPSS_ADDR(lpss_dma_desc) },
  253. /* Lynxpoint LPSS devices */
  254. { "INT33C0", LPSS_ADDR(lpt_dev_desc) },
  255. { "INT33C1", LPSS_ADDR(lpt_dev_desc) },
  256. { "INT33C2", LPSS_ADDR(lpt_i2c_dev_desc) },
  257. { "INT33C3", LPSS_ADDR(lpt_i2c_dev_desc) },
  258. { "INT33C4", LPSS_ADDR(lpt_uart_dev_desc) },
  259. { "INT33C5", LPSS_ADDR(lpt_uart_dev_desc) },
  260. { "INT33C6", LPSS_ADDR(lpt_sdio_dev_desc) },
  261. { "INT33C7", },
  262. /* BayTrail LPSS devices */
  263. { "80860F09", LPSS_ADDR(byt_pwm_dev_desc) },
  264. { "80860F0A", LPSS_ADDR(byt_uart_dev_desc) },
  265. { "80860F0E", LPSS_ADDR(byt_spi_dev_desc) },
  266. { "80860F14", LPSS_ADDR(byt_sdio_dev_desc) },
  267. { "80860F41", LPSS_ADDR(byt_i2c_dev_desc) },
  268. { "INT33B2", },
  269. { "INT33FC", },
  270. /* Braswell LPSS devices */
  271. { "80862288", LPSS_ADDR(bsw_pwm_dev_desc) },
  272. { "8086228A", LPSS_ADDR(bsw_uart_dev_desc) },
  273. { "8086228E", LPSS_ADDR(bsw_spi_dev_desc) },
  274. { "808622C1", LPSS_ADDR(bsw_i2c_dev_desc) },
  275. /* Broadwell LPSS devices */
  276. { "INT3430", LPSS_ADDR(lpt_dev_desc) },
  277. { "INT3431", LPSS_ADDR(lpt_dev_desc) },
  278. { "INT3432", LPSS_ADDR(lpt_i2c_dev_desc) },
  279. { "INT3433", LPSS_ADDR(lpt_i2c_dev_desc) },
  280. { "INT3434", LPSS_ADDR(lpt_uart_dev_desc) },
  281. { "INT3435", LPSS_ADDR(lpt_uart_dev_desc) },
  282. { "INT3436", LPSS_ADDR(lpt_sdio_dev_desc) },
  283. { "INT3437", },
  284. /* Wildcat Point LPSS devices */
  285. { "INT3438", LPSS_ADDR(lpt_dev_desc) },
  286. { }
  287. };
  288. #ifdef CONFIG_X86_INTEL_LPSS
  289. static int is_memory(struct acpi_resource *res, void *not_used)
  290. {
  291. struct resource r;
  292. return !acpi_dev_resource_memory(res, &r);
  293. }
  294. /* LPSS main clock device. */
  295. static struct platform_device *lpss_clk_dev;
  296. static inline void lpt_register_clock_device(void)
  297. {
  298. lpss_clk_dev = platform_device_register_simple("clk-lpt", -1, NULL, 0);
  299. }
  300. static int register_device_clock(struct acpi_device *adev,
  301. struct lpss_private_data *pdata)
  302. {
  303. const struct lpss_device_desc *dev_desc = pdata->dev_desc;
  304. const char *devname = dev_name(&adev->dev);
  305. struct clk *clk;
  306. struct lpss_clk_data *clk_data;
  307. const char *parent, *clk_name;
  308. void __iomem *prv_base;
  309. if (!lpss_clk_dev)
  310. lpt_register_clock_device();
  311. clk_data = platform_get_drvdata(lpss_clk_dev);
  312. if (!clk_data)
  313. return -ENODEV;
  314. clk = clk_data->clk;
  315. if (!pdata->mmio_base
  316. || pdata->mmio_size < dev_desc->prv_offset + LPSS_CLK_SIZE)
  317. return -ENODATA;
  318. parent = clk_data->name;
  319. prv_base = pdata->mmio_base + dev_desc->prv_offset;
  320. if (pdata->fixed_clk_rate) {
  321. clk = clk_register_fixed_rate(NULL, devname, parent, 0,
  322. pdata->fixed_clk_rate);
  323. goto out;
  324. }
  325. if (dev_desc->flags & LPSS_CLK_GATE) {
  326. clk = clk_register_gate(NULL, devname, parent, 0,
  327. prv_base, 0, 0, NULL);
  328. parent = devname;
  329. }
  330. if (dev_desc->flags & LPSS_CLK_DIVIDER) {
  331. /* Prevent division by zero */
  332. if (!readl(prv_base))
  333. writel(LPSS_CLK_DIVIDER_DEF_MASK, prv_base);
  334. clk_name = kasprintf(GFP_KERNEL, "%s-div", devname);
  335. if (!clk_name)
  336. return -ENOMEM;
  337. clk = clk_register_fractional_divider(NULL, clk_name, parent,
  338. 0, prv_base,
  339. 1, 15, 16, 15, 0, NULL);
  340. parent = clk_name;
  341. clk_name = kasprintf(GFP_KERNEL, "%s-update", devname);
  342. if (!clk_name) {
  343. kfree(parent);
  344. return -ENOMEM;
  345. }
  346. clk = clk_register_gate(NULL, clk_name, parent,
  347. CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE,
  348. prv_base, 31, 0, NULL);
  349. kfree(parent);
  350. kfree(clk_name);
  351. }
  352. out:
  353. if (IS_ERR(clk))
  354. return PTR_ERR(clk);
  355. pdata->clk = clk;
  356. clk_register_clkdev(clk, dev_desc->clk_con_id, devname);
  357. return 0;
  358. }
  359. struct lpss_device_links {
  360. const char *supplier_hid;
  361. const char *supplier_uid;
  362. const char *consumer_hid;
  363. const char *consumer_uid;
  364. u32 flags;
  365. };
  366. /*
  367. * The _DEP method is used to identify dependencies but instead of creating
  368. * device links for every handle in _DEP, only links in the following list are
  369. * created. That is necessary because, in the general case, _DEP can refer to
  370. * devices that might not have drivers, or that are on different buses, or where
  371. * the supplier is not enumerated until after the consumer is probed.
  372. */
  373. static const struct lpss_device_links lpss_device_links[] = {
  374. {"808622C1", "7", "80860F14", "3", DL_FLAG_PM_RUNTIME},
  375. };
  376. static bool hid_uid_match(const char *hid1, const char *uid1,
  377. const char *hid2, const char *uid2)
  378. {
  379. return !strcmp(hid1, hid2) && uid1 && uid2 && !strcmp(uid1, uid2);
  380. }
  381. static bool acpi_lpss_is_supplier(struct acpi_device *adev,
  382. const struct lpss_device_links *link)
  383. {
  384. return hid_uid_match(acpi_device_hid(adev), acpi_device_uid(adev),
  385. link->supplier_hid, link->supplier_uid);
  386. }
  387. static bool acpi_lpss_is_consumer(struct acpi_device *adev,
  388. const struct lpss_device_links *link)
  389. {
  390. return hid_uid_match(acpi_device_hid(adev), acpi_device_uid(adev),
  391. link->consumer_hid, link->consumer_uid);
  392. }
  393. struct hid_uid {
  394. const char *hid;
  395. const char *uid;
  396. };
  397. static int match_hid_uid(struct device *dev, void *data)
  398. {
  399. struct acpi_device *adev = ACPI_COMPANION(dev);
  400. struct hid_uid *id = data;
  401. if (!adev)
  402. return 0;
  403. return hid_uid_match(acpi_device_hid(adev), acpi_device_uid(adev),
  404. id->hid, id->uid);
  405. }
  406. static struct device *acpi_lpss_find_device(const char *hid, const char *uid)
  407. {
  408. struct hid_uid data = {
  409. .hid = hid,
  410. .uid = uid,
  411. };
  412. return bus_find_device(&platform_bus_type, NULL, &data, match_hid_uid);
  413. }
  414. static bool acpi_lpss_dep(struct acpi_device *adev, acpi_handle handle)
  415. {
  416. struct acpi_handle_list dep_devices;
  417. acpi_status status;
  418. int i;
  419. if (!acpi_has_method(adev->handle, "_DEP"))
  420. return false;
  421. status = acpi_evaluate_reference(adev->handle, "_DEP", NULL,
  422. &dep_devices);
  423. if (ACPI_FAILURE(status)) {
  424. dev_dbg(&adev->dev, "Failed to evaluate _DEP.\n");
  425. return false;
  426. }
  427. for (i = 0; i < dep_devices.count; i++) {
  428. if (dep_devices.handles[i] == handle)
  429. return true;
  430. }
  431. return false;
  432. }
  433. static void acpi_lpss_link_consumer(struct device *dev1,
  434. const struct lpss_device_links *link)
  435. {
  436. struct device *dev2;
  437. dev2 = acpi_lpss_find_device(link->consumer_hid, link->consumer_uid);
  438. if (!dev2)
  439. return;
  440. if (acpi_lpss_dep(ACPI_COMPANION(dev2), ACPI_HANDLE(dev1)))
  441. device_link_add(dev2, dev1, link->flags);
  442. put_device(dev2);
  443. }
  444. static void acpi_lpss_link_supplier(struct device *dev1,
  445. const struct lpss_device_links *link)
  446. {
  447. struct device *dev2;
  448. dev2 = acpi_lpss_find_device(link->supplier_hid, link->supplier_uid);
  449. if (!dev2)
  450. return;
  451. if (acpi_lpss_dep(ACPI_COMPANION(dev1), ACPI_HANDLE(dev2)))
  452. device_link_add(dev1, dev2, link->flags);
  453. put_device(dev2);
  454. }
  455. static void acpi_lpss_create_device_links(struct acpi_device *adev,
  456. struct platform_device *pdev)
  457. {
  458. int i;
  459. for (i = 0; i < ARRAY_SIZE(lpss_device_links); i++) {
  460. const struct lpss_device_links *link = &lpss_device_links[i];
  461. if (acpi_lpss_is_supplier(adev, link))
  462. acpi_lpss_link_consumer(&pdev->dev, link);
  463. if (acpi_lpss_is_consumer(adev, link))
  464. acpi_lpss_link_supplier(&pdev->dev, link);
  465. }
  466. }
  467. static int acpi_lpss_create_device(struct acpi_device *adev,
  468. const struct acpi_device_id *id)
  469. {
  470. const struct lpss_device_desc *dev_desc;
  471. struct lpss_private_data *pdata;
  472. struct resource_entry *rentry;
  473. struct list_head resource_list;
  474. struct platform_device *pdev;
  475. int ret;
  476. dev_desc = (const struct lpss_device_desc *)id->driver_data;
  477. if (!dev_desc) {
  478. pdev = acpi_create_platform_device(adev, NULL);
  479. return IS_ERR_OR_NULL(pdev) ? PTR_ERR(pdev) : 1;
  480. }
  481. pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
  482. if (!pdata)
  483. return -ENOMEM;
  484. INIT_LIST_HEAD(&resource_list);
  485. ret = acpi_dev_get_resources(adev, &resource_list, is_memory, NULL);
  486. if (ret < 0)
  487. goto err_out;
  488. list_for_each_entry(rentry, &resource_list, node)
  489. if (resource_type(rentry->res) == IORESOURCE_MEM) {
  490. if (dev_desc->prv_size_override)
  491. pdata->mmio_size = dev_desc->prv_size_override;
  492. else
  493. pdata->mmio_size = resource_size(rentry->res);
  494. pdata->mmio_base = ioremap(rentry->res->start,
  495. pdata->mmio_size);
  496. break;
  497. }
  498. acpi_dev_free_resource_list(&resource_list);
  499. if (!pdata->mmio_base) {
  500. /* Avoid acpi_bus_attach() instantiating a pdev for this dev. */
  501. adev->pnp.type.platform_id = 0;
  502. /* Skip the device, but continue the namespace scan. */
  503. ret = 0;
  504. goto err_out;
  505. }
  506. pdata->adev = adev;
  507. pdata->dev_desc = dev_desc;
  508. if (dev_desc->setup)
  509. dev_desc->setup(pdata);
  510. if (dev_desc->flags & LPSS_CLK) {
  511. ret = register_device_clock(adev, pdata);
  512. if (ret) {
  513. /* Skip the device, but continue the namespace scan. */
  514. ret = 0;
  515. goto err_out;
  516. }
  517. }
  518. /*
  519. * This works around a known issue in ACPI tables where LPSS devices
  520. * have _PS0 and _PS3 without _PSC (and no power resources), so
  521. * acpi_bus_init_power() will assume that the BIOS has put them into D0.
  522. */
  523. ret = acpi_device_fix_up_power(adev);
  524. if (ret) {
  525. /* Skip the device, but continue the namespace scan. */
  526. ret = 0;
  527. goto err_out;
  528. }
  529. adev->driver_data = pdata;
  530. pdev = acpi_create_platform_device(adev, dev_desc->properties);
  531. if (!IS_ERR_OR_NULL(pdev)) {
  532. acpi_lpss_create_device_links(adev, pdev);
  533. return 1;
  534. }
  535. ret = PTR_ERR(pdev);
  536. adev->driver_data = NULL;
  537. err_out:
  538. kfree(pdata);
  539. return ret;
  540. }
  541. static u32 __lpss_reg_read(struct lpss_private_data *pdata, unsigned int reg)
  542. {
  543. return readl(pdata->mmio_base + pdata->dev_desc->prv_offset + reg);
  544. }
  545. static void __lpss_reg_write(u32 val, struct lpss_private_data *pdata,
  546. unsigned int reg)
  547. {
  548. writel(val, pdata->mmio_base + pdata->dev_desc->prv_offset + reg);
  549. }
  550. static int lpss_reg_read(struct device *dev, unsigned int reg, u32 *val)
  551. {
  552. struct acpi_device *adev;
  553. struct lpss_private_data *pdata;
  554. unsigned long flags;
  555. int ret;
  556. ret = acpi_bus_get_device(ACPI_HANDLE(dev), &adev);
  557. if (WARN_ON(ret))
  558. return ret;
  559. spin_lock_irqsave(&dev->power.lock, flags);
  560. if (pm_runtime_suspended(dev)) {
  561. ret = -EAGAIN;
  562. goto out;
  563. }
  564. pdata = acpi_driver_data(adev);
  565. if (WARN_ON(!pdata || !pdata->mmio_base)) {
  566. ret = -ENODEV;
  567. goto out;
  568. }
  569. *val = __lpss_reg_read(pdata, reg);
  570. out:
  571. spin_unlock_irqrestore(&dev->power.lock, flags);
  572. return ret;
  573. }
  574. static ssize_t lpss_ltr_show(struct device *dev, struct device_attribute *attr,
  575. char *buf)
  576. {
  577. u32 ltr_value = 0;
  578. unsigned int reg;
  579. int ret;
  580. reg = strcmp(attr->attr.name, "auto_ltr") ? LPSS_SW_LTR : LPSS_AUTO_LTR;
  581. ret = lpss_reg_read(dev, reg, &ltr_value);
  582. if (ret)
  583. return ret;
  584. return snprintf(buf, PAGE_SIZE, "%08x\n", ltr_value);
  585. }
  586. static ssize_t lpss_ltr_mode_show(struct device *dev,
  587. struct device_attribute *attr, char *buf)
  588. {
  589. u32 ltr_mode = 0;
  590. char *outstr;
  591. int ret;
  592. ret = lpss_reg_read(dev, LPSS_GENERAL, &ltr_mode);
  593. if (ret)
  594. return ret;
  595. outstr = (ltr_mode & LPSS_GENERAL_LTR_MODE_SW) ? "sw" : "auto";
  596. return sprintf(buf, "%s\n", outstr);
  597. }
  598. static DEVICE_ATTR(auto_ltr, S_IRUSR, lpss_ltr_show, NULL);
  599. static DEVICE_ATTR(sw_ltr, S_IRUSR, lpss_ltr_show, NULL);
  600. static DEVICE_ATTR(ltr_mode, S_IRUSR, lpss_ltr_mode_show, NULL);
  601. static struct attribute *lpss_attrs[] = {
  602. &dev_attr_auto_ltr.attr,
  603. &dev_attr_sw_ltr.attr,
  604. &dev_attr_ltr_mode.attr,
  605. NULL,
  606. };
  607. static const struct attribute_group lpss_attr_group = {
  608. .attrs = lpss_attrs,
  609. .name = "lpss_ltr",
  610. };
  611. static void acpi_lpss_set_ltr(struct device *dev, s32 val)
  612. {
  613. struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev));
  614. u32 ltr_mode, ltr_val;
  615. ltr_mode = __lpss_reg_read(pdata, LPSS_GENERAL);
  616. if (val < 0) {
  617. if (ltr_mode & LPSS_GENERAL_LTR_MODE_SW) {
  618. ltr_mode &= ~LPSS_GENERAL_LTR_MODE_SW;
  619. __lpss_reg_write(ltr_mode, pdata, LPSS_GENERAL);
  620. }
  621. return;
  622. }
  623. ltr_val = __lpss_reg_read(pdata, LPSS_SW_LTR) & ~LPSS_LTR_SNOOP_MASK;
  624. if (val >= LPSS_LTR_SNOOP_LAT_CUTOFF) {
  625. ltr_val |= LPSS_LTR_SNOOP_LAT_32US;
  626. val = LPSS_LTR_MAX_VAL;
  627. } else if (val > LPSS_LTR_MAX_VAL) {
  628. ltr_val |= LPSS_LTR_SNOOP_LAT_32US | LPSS_LTR_SNOOP_REQ;
  629. val >>= LPSS_LTR_SNOOP_LAT_SHIFT;
  630. } else {
  631. ltr_val |= LPSS_LTR_SNOOP_LAT_1US | LPSS_LTR_SNOOP_REQ;
  632. }
  633. ltr_val |= val;
  634. __lpss_reg_write(ltr_val, pdata, LPSS_SW_LTR);
  635. if (!(ltr_mode & LPSS_GENERAL_LTR_MODE_SW)) {
  636. ltr_mode |= LPSS_GENERAL_LTR_MODE_SW;
  637. __lpss_reg_write(ltr_mode, pdata, LPSS_GENERAL);
  638. }
  639. }
  640. #ifdef CONFIG_PM
  641. /**
  642. * acpi_lpss_save_ctx() - Save the private registers of LPSS device
  643. * @dev: LPSS device
  644. * @pdata: pointer to the private data of the LPSS device
  645. *
  646. * Most LPSS devices have private registers which may loose their context when
  647. * the device is powered down. acpi_lpss_save_ctx() saves those registers into
  648. * prv_reg_ctx array.
  649. */
  650. static void acpi_lpss_save_ctx(struct device *dev,
  651. struct lpss_private_data *pdata)
  652. {
  653. unsigned int i;
  654. for (i = 0; i < LPSS_PRV_REG_COUNT; i++) {
  655. unsigned long offset = i * sizeof(u32);
  656. pdata->prv_reg_ctx[i] = __lpss_reg_read(pdata, offset);
  657. dev_dbg(dev, "saving 0x%08x from LPSS reg at offset 0x%02lx\n",
  658. pdata->prv_reg_ctx[i], offset);
  659. }
  660. }
  661. /**
  662. * acpi_lpss_restore_ctx() - Restore the private registers of LPSS device
  663. * @dev: LPSS device
  664. * @pdata: pointer to the private data of the LPSS device
  665. *
  666. * Restores the registers that were previously stored with acpi_lpss_save_ctx().
  667. */
  668. static void acpi_lpss_restore_ctx(struct device *dev,
  669. struct lpss_private_data *pdata)
  670. {
  671. unsigned int i;
  672. for (i = 0; i < LPSS_PRV_REG_COUNT; i++) {
  673. unsigned long offset = i * sizeof(u32);
  674. __lpss_reg_write(pdata->prv_reg_ctx[i], pdata, offset);
  675. dev_dbg(dev, "restoring 0x%08x to LPSS reg at offset 0x%02lx\n",
  676. pdata->prv_reg_ctx[i], offset);
  677. }
  678. }
  679. static void acpi_lpss_d3_to_d0_delay(struct lpss_private_data *pdata)
  680. {
  681. /*
  682. * The following delay is needed or the subsequent write operations may
  683. * fail. The LPSS devices are actually PCI devices and the PCI spec
  684. * expects 10ms delay before the device can be accessed after D3 to D0
  685. * transition. However some platforms like BSW does not need this delay.
  686. */
  687. unsigned int delay = 10; /* default 10ms delay */
  688. if (pdata->dev_desc->flags & LPSS_NO_D3_DELAY)
  689. delay = 0;
  690. msleep(delay);
  691. }
  692. static int acpi_lpss_activate(struct device *dev)
  693. {
  694. struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev));
  695. int ret;
  696. ret = acpi_dev_resume(dev);
  697. if (ret)
  698. return ret;
  699. acpi_lpss_d3_to_d0_delay(pdata);
  700. /*
  701. * This is called only on ->probe() stage where a device is either in
  702. * known state defined by BIOS or most likely powered off. Due to this
  703. * we have to deassert reset line to be sure that ->probe() will
  704. * recognize the device.
  705. */
  706. if (pdata->dev_desc->flags & LPSS_SAVE_CTX)
  707. lpss_deassert_reset(pdata);
  708. return 0;
  709. }
  710. static void acpi_lpss_dismiss(struct device *dev)
  711. {
  712. acpi_dev_suspend(dev, false);
  713. }
  714. /* IOSF SB for LPSS island */
  715. #define LPSS_IOSF_UNIT_LPIOEP 0xA0
  716. #define LPSS_IOSF_UNIT_LPIO1 0xAB
  717. #define LPSS_IOSF_UNIT_LPIO2 0xAC
  718. #define LPSS_IOSF_PMCSR 0x84
  719. #define LPSS_PMCSR_D0 0
  720. #define LPSS_PMCSR_D3hot 3
  721. #define LPSS_PMCSR_Dx_MASK GENMASK(1, 0)
  722. #define LPSS_IOSF_GPIODEF0 0x154
  723. #define LPSS_GPIODEF0_DMA1_D3 BIT(2)
  724. #define LPSS_GPIODEF0_DMA2_D3 BIT(3)
  725. #define LPSS_GPIODEF0_DMA_D3_MASK GENMASK(3, 2)
  726. #define LPSS_GPIODEF0_DMA_LLP BIT(13)
  727. static DEFINE_MUTEX(lpss_iosf_mutex);
  728. static void lpss_iosf_enter_d3_state(void)
  729. {
  730. u32 value1 = 0;
  731. u32 mask1 = LPSS_GPIODEF0_DMA_D3_MASK | LPSS_GPIODEF0_DMA_LLP;
  732. u32 value2 = LPSS_PMCSR_D3hot;
  733. u32 mask2 = LPSS_PMCSR_Dx_MASK;
  734. /*
  735. * PMC provides an information about actual status of the LPSS devices.
  736. * Here we read the values related to LPSS power island, i.e. LPSS
  737. * devices, excluding both LPSS DMA controllers, along with SCC domain.
  738. */
  739. u32 func_dis, d3_sts_0, pmc_status, pmc_mask = 0xfe000ffe;
  740. int ret;
  741. ret = pmc_atom_read(PMC_FUNC_DIS, &func_dis);
  742. if (ret)
  743. return;
  744. mutex_lock(&lpss_iosf_mutex);
  745. ret = pmc_atom_read(PMC_D3_STS_0, &d3_sts_0);
  746. if (ret)
  747. goto exit;
  748. /*
  749. * Get the status of entire LPSS power island per device basis.
  750. * Shutdown both LPSS DMA controllers if and only if all other devices
  751. * are already in D3hot.
  752. */
  753. pmc_status = (~(d3_sts_0 | func_dis)) & pmc_mask;
  754. if (pmc_status)
  755. goto exit;
  756. iosf_mbi_modify(LPSS_IOSF_UNIT_LPIO1, MBI_CFG_WRITE,
  757. LPSS_IOSF_PMCSR, value2, mask2);
  758. iosf_mbi_modify(LPSS_IOSF_UNIT_LPIO2, MBI_CFG_WRITE,
  759. LPSS_IOSF_PMCSR, value2, mask2);
  760. iosf_mbi_modify(LPSS_IOSF_UNIT_LPIOEP, MBI_CR_WRITE,
  761. LPSS_IOSF_GPIODEF0, value1, mask1);
  762. exit:
  763. mutex_unlock(&lpss_iosf_mutex);
  764. }
  765. static void lpss_iosf_exit_d3_state(void)
  766. {
  767. u32 value1 = LPSS_GPIODEF0_DMA1_D3 | LPSS_GPIODEF0_DMA2_D3 |
  768. LPSS_GPIODEF0_DMA_LLP;
  769. u32 mask1 = LPSS_GPIODEF0_DMA_D3_MASK | LPSS_GPIODEF0_DMA_LLP;
  770. u32 value2 = LPSS_PMCSR_D0;
  771. u32 mask2 = LPSS_PMCSR_Dx_MASK;
  772. mutex_lock(&lpss_iosf_mutex);
  773. iosf_mbi_modify(LPSS_IOSF_UNIT_LPIOEP, MBI_CR_WRITE,
  774. LPSS_IOSF_GPIODEF0, value1, mask1);
  775. iosf_mbi_modify(LPSS_IOSF_UNIT_LPIO2, MBI_CFG_WRITE,
  776. LPSS_IOSF_PMCSR, value2, mask2);
  777. iosf_mbi_modify(LPSS_IOSF_UNIT_LPIO1, MBI_CFG_WRITE,
  778. LPSS_IOSF_PMCSR, value2, mask2);
  779. mutex_unlock(&lpss_iosf_mutex);
  780. }
  781. static int acpi_lpss_suspend(struct device *dev, bool wakeup)
  782. {
  783. struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev));
  784. int ret;
  785. if (pdata->dev_desc->flags & LPSS_SAVE_CTX)
  786. acpi_lpss_save_ctx(dev, pdata);
  787. ret = acpi_dev_suspend(dev, wakeup);
  788. /*
  789. * This call must be last in the sequence, otherwise PMC will return
  790. * wrong status for devices being about to be powered off. See
  791. * lpss_iosf_enter_d3_state() for further information.
  792. */
  793. if (lpss_quirks & LPSS_QUIRK_ALWAYS_POWER_ON && iosf_mbi_available())
  794. lpss_iosf_enter_d3_state();
  795. return ret;
  796. }
  797. static int acpi_lpss_resume(struct device *dev)
  798. {
  799. struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev));
  800. int ret;
  801. /*
  802. * This call is kept first to be in symmetry with
  803. * acpi_lpss_runtime_suspend() one.
  804. */
  805. if (lpss_quirks & LPSS_QUIRK_ALWAYS_POWER_ON && iosf_mbi_available())
  806. lpss_iosf_exit_d3_state();
  807. ret = acpi_dev_resume(dev);
  808. if (ret)
  809. return ret;
  810. acpi_lpss_d3_to_d0_delay(pdata);
  811. if (pdata->dev_desc->flags & LPSS_SAVE_CTX)
  812. acpi_lpss_restore_ctx(dev, pdata);
  813. return 0;
  814. }
  815. #ifdef CONFIG_PM_SLEEP
  816. static int acpi_lpss_suspend_late(struct device *dev)
  817. {
  818. int ret;
  819. if (dev_pm_smart_suspend_and_suspended(dev))
  820. return 0;
  821. ret = pm_generic_suspend_late(dev);
  822. return ret ? ret : acpi_lpss_suspend(dev, device_may_wakeup(dev));
  823. }
  824. static int acpi_lpss_resume_early(struct device *dev)
  825. {
  826. int ret = acpi_lpss_resume(dev);
  827. return ret ? ret : pm_generic_resume_early(dev);
  828. }
  829. #endif /* CONFIG_PM_SLEEP */
  830. static int acpi_lpss_runtime_suspend(struct device *dev)
  831. {
  832. int ret = pm_generic_runtime_suspend(dev);
  833. return ret ? ret : acpi_lpss_suspend(dev, true);
  834. }
  835. static int acpi_lpss_runtime_resume(struct device *dev)
  836. {
  837. int ret = acpi_lpss_resume(dev);
  838. return ret ? ret : pm_generic_runtime_resume(dev);
  839. }
  840. #endif /* CONFIG_PM */
  841. static struct dev_pm_domain acpi_lpss_pm_domain = {
  842. #ifdef CONFIG_PM
  843. .activate = acpi_lpss_activate,
  844. .dismiss = acpi_lpss_dismiss,
  845. #endif
  846. .ops = {
  847. #ifdef CONFIG_PM
  848. #ifdef CONFIG_PM_SLEEP
  849. .prepare = acpi_subsys_prepare,
  850. .complete = acpi_subsys_complete,
  851. .suspend = acpi_subsys_suspend,
  852. .suspend_late = acpi_lpss_suspend_late,
  853. .suspend_noirq = acpi_subsys_suspend_noirq,
  854. .resume_noirq = acpi_subsys_resume_noirq,
  855. .resume_early = acpi_lpss_resume_early,
  856. .freeze = acpi_subsys_freeze,
  857. .freeze_late = acpi_subsys_freeze_late,
  858. .freeze_noirq = acpi_subsys_freeze_noirq,
  859. .thaw_noirq = acpi_subsys_thaw_noirq,
  860. .poweroff = acpi_subsys_suspend,
  861. .poweroff_late = acpi_lpss_suspend_late,
  862. .poweroff_noirq = acpi_subsys_suspend_noirq,
  863. .restore_noirq = acpi_subsys_resume_noirq,
  864. .restore_early = acpi_lpss_resume_early,
  865. #endif
  866. .runtime_suspend = acpi_lpss_runtime_suspend,
  867. .runtime_resume = acpi_lpss_runtime_resume,
  868. #endif
  869. },
  870. };
  871. static int acpi_lpss_platform_notify(struct notifier_block *nb,
  872. unsigned long action, void *data)
  873. {
  874. struct platform_device *pdev = to_platform_device(data);
  875. struct lpss_private_data *pdata;
  876. struct acpi_device *adev;
  877. const struct acpi_device_id *id;
  878. id = acpi_match_device(acpi_lpss_device_ids, &pdev->dev);
  879. if (!id || !id->driver_data)
  880. return 0;
  881. if (acpi_bus_get_device(ACPI_HANDLE(&pdev->dev), &adev))
  882. return 0;
  883. pdata = acpi_driver_data(adev);
  884. if (!pdata)
  885. return 0;
  886. if (pdata->mmio_base &&
  887. pdata->mmio_size < pdata->dev_desc->prv_offset + LPSS_LTR_SIZE) {
  888. dev_err(&pdev->dev, "MMIO size insufficient to access LTR\n");
  889. return 0;
  890. }
  891. switch (action) {
  892. case BUS_NOTIFY_BIND_DRIVER:
  893. dev_pm_domain_set(&pdev->dev, &acpi_lpss_pm_domain);
  894. break;
  895. case BUS_NOTIFY_DRIVER_NOT_BOUND:
  896. case BUS_NOTIFY_UNBOUND_DRIVER:
  897. dev_pm_domain_set(&pdev->dev, NULL);
  898. break;
  899. case BUS_NOTIFY_ADD_DEVICE:
  900. dev_pm_domain_set(&pdev->dev, &acpi_lpss_pm_domain);
  901. if (pdata->dev_desc->flags & LPSS_LTR)
  902. return sysfs_create_group(&pdev->dev.kobj,
  903. &lpss_attr_group);
  904. break;
  905. case BUS_NOTIFY_DEL_DEVICE:
  906. if (pdata->dev_desc->flags & LPSS_LTR)
  907. sysfs_remove_group(&pdev->dev.kobj, &lpss_attr_group);
  908. dev_pm_domain_set(&pdev->dev, NULL);
  909. break;
  910. default:
  911. break;
  912. }
  913. return 0;
  914. }
  915. static struct notifier_block acpi_lpss_nb = {
  916. .notifier_call = acpi_lpss_platform_notify,
  917. };
  918. static void acpi_lpss_bind(struct device *dev)
  919. {
  920. struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev));
  921. if (!pdata || !pdata->mmio_base || !(pdata->dev_desc->flags & LPSS_LTR))
  922. return;
  923. if (pdata->mmio_size >= pdata->dev_desc->prv_offset + LPSS_LTR_SIZE)
  924. dev->power.set_latency_tolerance = acpi_lpss_set_ltr;
  925. else
  926. dev_err(dev, "MMIO size insufficient to access LTR\n");
  927. }
  928. static void acpi_lpss_unbind(struct device *dev)
  929. {
  930. dev->power.set_latency_tolerance = NULL;
  931. }
  932. static struct acpi_scan_handler lpss_handler = {
  933. .ids = acpi_lpss_device_ids,
  934. .attach = acpi_lpss_create_device,
  935. .bind = acpi_lpss_bind,
  936. .unbind = acpi_lpss_unbind,
  937. };
  938. void __init acpi_lpss_init(void)
  939. {
  940. const struct x86_cpu_id *id;
  941. int ret;
  942. ret = lpt_clk_init();
  943. if (ret)
  944. return;
  945. id = x86_match_cpu(lpss_cpu_ids);
  946. if (id)
  947. lpss_quirks |= LPSS_QUIRK_ALWAYS_POWER_ON;
  948. bus_register_notifier(&platform_bus_type, &acpi_lpss_nb);
  949. acpi_scan_add_handler(&lpss_handler);
  950. }
  951. #else
  952. static struct acpi_scan_handler lpss_handler = {
  953. .ids = acpi_lpss_device_ids,
  954. };
  955. void __init acpi_lpss_init(void)
  956. {
  957. acpi_scan_add_handler(&lpss_handler);
  958. }
  959. #endif /* CONFIG_X86_INTEL_LPSS */