acpi_lpss.c 30 KB

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