rsserial.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  1. /*******************************************************************************
  2. *
  3. * Module Name: rsserial - GPIO/serial_bus resource descriptors
  4. *
  5. ******************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2016, Intel Corp.
  8. * All rights reserved.
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions
  12. * are met:
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions, and the following disclaimer,
  15. * without modification.
  16. * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  17. * substantially similar to the "NO WARRANTY" disclaimer below
  18. * ("Disclaimer") and any redistribution must be conditioned upon
  19. * including a substantially similar Disclaimer requirement for further
  20. * binary redistribution.
  21. * 3. Neither the names of the above-listed copyright holders nor the names
  22. * of any contributors may be used to endorse or promote products derived
  23. * from this software without specific prior written permission.
  24. *
  25. * Alternatively, this software may be distributed under the terms of the
  26. * GNU General Public License ("GPL") version 2 as published by the Free
  27. * Software Foundation.
  28. *
  29. * NO WARRANTY
  30. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  31. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  32. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  33. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  34. * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  35. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  36. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  37. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  38. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  39. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  40. * POSSIBILITY OF SUCH DAMAGES.
  41. */
  42. #include <acpi/acpi.h>
  43. #include "accommon.h"
  44. #include "acresrc.h"
  45. #define _COMPONENT ACPI_RESOURCES
  46. ACPI_MODULE_NAME("rsserial")
  47. /*******************************************************************************
  48. *
  49. * acpi_rs_convert_gpio
  50. *
  51. ******************************************************************************/
  52. struct acpi_rsconvert_info acpi_rs_convert_gpio[18] = {
  53. {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_GPIO,
  54. ACPI_RS_SIZE(struct acpi_resource_gpio),
  55. ACPI_RSC_TABLE_SIZE(acpi_rs_convert_gpio)},
  56. {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_GPIO,
  57. sizeof(struct aml_resource_gpio),
  58. 0},
  59. /*
  60. * These fields are contiguous in both the source and destination:
  61. * revision_id
  62. * connection_type
  63. */
  64. {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.gpio.revision_id),
  65. AML_OFFSET(gpio.revision_id),
  66. 2},
  67. {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.gpio.producer_consumer),
  68. AML_OFFSET(gpio.flags),
  69. 0},
  70. {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.gpio.sharable),
  71. AML_OFFSET(gpio.int_flags),
  72. 3},
  73. {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.gpio.wake_capable),
  74. AML_OFFSET(gpio.int_flags),
  75. 4},
  76. {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.gpio.io_restriction),
  77. AML_OFFSET(gpio.int_flags),
  78. 0},
  79. {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.gpio.triggering),
  80. AML_OFFSET(gpio.int_flags),
  81. 0},
  82. {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.gpio.polarity),
  83. AML_OFFSET(gpio.int_flags),
  84. 1},
  85. {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.gpio.pin_config),
  86. AML_OFFSET(gpio.pin_config),
  87. 1},
  88. /*
  89. * These fields are contiguous in both the source and destination:
  90. * drive_strength
  91. * debounce_timeout
  92. */
  93. {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.gpio.drive_strength),
  94. AML_OFFSET(gpio.drive_strength),
  95. 2},
  96. /* Pin Table */
  97. {ACPI_RSC_COUNT_GPIO_PIN, ACPI_RS_OFFSET(data.gpio.pin_table_length),
  98. AML_OFFSET(gpio.pin_table_offset),
  99. AML_OFFSET(gpio.res_source_offset)},
  100. {ACPI_RSC_MOVE_GPIO_PIN, ACPI_RS_OFFSET(data.gpio.pin_table),
  101. AML_OFFSET(gpio.pin_table_offset),
  102. 0},
  103. /* Resource Source */
  104. {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.gpio.resource_source.index),
  105. AML_OFFSET(gpio.res_source_index),
  106. 1},
  107. {ACPI_RSC_COUNT_GPIO_RES,
  108. ACPI_RS_OFFSET(data.gpio.resource_source.string_length),
  109. AML_OFFSET(gpio.res_source_offset),
  110. AML_OFFSET(gpio.vendor_offset)},
  111. {ACPI_RSC_MOVE_GPIO_RES,
  112. ACPI_RS_OFFSET(data.gpio.resource_source.string_ptr),
  113. AML_OFFSET(gpio.res_source_offset),
  114. 0},
  115. /* Vendor Data */
  116. {ACPI_RSC_COUNT_GPIO_VEN, ACPI_RS_OFFSET(data.gpio.vendor_length),
  117. AML_OFFSET(gpio.vendor_length),
  118. 1},
  119. {ACPI_RSC_MOVE_GPIO_RES, ACPI_RS_OFFSET(data.gpio.vendor_data),
  120. AML_OFFSET(gpio.vendor_offset),
  121. 0},
  122. };
  123. /*******************************************************************************
  124. *
  125. * acpi_rs_convert_i2c_serial_bus
  126. *
  127. ******************************************************************************/
  128. struct acpi_rsconvert_info acpi_rs_convert_i2c_serial_bus[17] = {
  129. {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_SERIAL_BUS,
  130. ACPI_RS_SIZE(struct acpi_resource_i2c_serialbus),
  131. ACPI_RSC_TABLE_SIZE(acpi_rs_convert_i2c_serial_bus)},
  132. {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_SERIAL_BUS,
  133. sizeof(struct aml_resource_i2c_serialbus),
  134. 0},
  135. {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.common_serial_bus.revision_id),
  136. AML_OFFSET(common_serial_bus.revision_id),
  137. 1},
  138. {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.common_serial_bus.type),
  139. AML_OFFSET(common_serial_bus.type),
  140. 1},
  141. {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.common_serial_bus.slave_mode),
  142. AML_OFFSET(common_serial_bus.flags),
  143. 0},
  144. {ACPI_RSC_1BITFLAG,
  145. ACPI_RS_OFFSET(data.common_serial_bus.producer_consumer),
  146. AML_OFFSET(common_serial_bus.flags),
  147. 1},
  148. {ACPI_RSC_1BITFLAG,
  149. ACPI_RS_OFFSET(data.common_serial_bus.connection_sharing),
  150. AML_OFFSET(common_serial_bus.flags),
  151. 2},
  152. {ACPI_RSC_MOVE8,
  153. ACPI_RS_OFFSET(data.common_serial_bus.type_revision_id),
  154. AML_OFFSET(common_serial_bus.type_revision_id),
  155. 1},
  156. {ACPI_RSC_MOVE16,
  157. ACPI_RS_OFFSET(data.common_serial_bus.type_data_length),
  158. AML_OFFSET(common_serial_bus.type_data_length),
  159. 1},
  160. /* Vendor data */
  161. {ACPI_RSC_COUNT_SERIAL_VEN,
  162. ACPI_RS_OFFSET(data.common_serial_bus.vendor_length),
  163. AML_OFFSET(common_serial_bus.type_data_length),
  164. AML_RESOURCE_I2C_MIN_DATA_LEN},
  165. {ACPI_RSC_MOVE_SERIAL_VEN,
  166. ACPI_RS_OFFSET(data.common_serial_bus.vendor_data),
  167. 0,
  168. sizeof(struct aml_resource_i2c_serialbus)},
  169. /* Resource Source */
  170. {ACPI_RSC_MOVE8,
  171. ACPI_RS_OFFSET(data.common_serial_bus.resource_source.index),
  172. AML_OFFSET(common_serial_bus.res_source_index),
  173. 1},
  174. {ACPI_RSC_COUNT_SERIAL_RES,
  175. ACPI_RS_OFFSET(data.common_serial_bus.resource_source.string_length),
  176. AML_OFFSET(common_serial_bus.type_data_length),
  177. sizeof(struct aml_resource_common_serialbus)},
  178. {ACPI_RSC_MOVE_SERIAL_RES,
  179. ACPI_RS_OFFSET(data.common_serial_bus.resource_source.string_ptr),
  180. AML_OFFSET(common_serial_bus.type_data_length),
  181. sizeof(struct aml_resource_common_serialbus)},
  182. /* I2C bus type specific */
  183. {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.i2c_serial_bus.access_mode),
  184. AML_OFFSET(i2c_serial_bus.type_specific_flags),
  185. 0},
  186. {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.i2c_serial_bus.connection_speed),
  187. AML_OFFSET(i2c_serial_bus.connection_speed),
  188. 1},
  189. {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.i2c_serial_bus.slave_address),
  190. AML_OFFSET(i2c_serial_bus.slave_address),
  191. 1},
  192. };
  193. /*******************************************************************************
  194. *
  195. * acpi_rs_convert_spi_serial_bus
  196. *
  197. ******************************************************************************/
  198. struct acpi_rsconvert_info acpi_rs_convert_spi_serial_bus[21] = {
  199. {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_SERIAL_BUS,
  200. ACPI_RS_SIZE(struct acpi_resource_spi_serialbus),
  201. ACPI_RSC_TABLE_SIZE(acpi_rs_convert_spi_serial_bus)},
  202. {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_SERIAL_BUS,
  203. sizeof(struct aml_resource_spi_serialbus),
  204. 0},
  205. {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.common_serial_bus.revision_id),
  206. AML_OFFSET(common_serial_bus.revision_id),
  207. 1},
  208. {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.common_serial_bus.type),
  209. AML_OFFSET(common_serial_bus.type),
  210. 1},
  211. {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.common_serial_bus.slave_mode),
  212. AML_OFFSET(common_serial_bus.flags),
  213. 0},
  214. {ACPI_RSC_1BITFLAG,
  215. ACPI_RS_OFFSET(data.common_serial_bus.producer_consumer),
  216. AML_OFFSET(common_serial_bus.flags),
  217. 1},
  218. {ACPI_RSC_1BITFLAG,
  219. ACPI_RS_OFFSET(data.common_serial_bus.connection_sharing),
  220. AML_OFFSET(common_serial_bus.flags),
  221. 2},
  222. {ACPI_RSC_MOVE8,
  223. ACPI_RS_OFFSET(data.common_serial_bus.type_revision_id),
  224. AML_OFFSET(common_serial_bus.type_revision_id),
  225. 1},
  226. {ACPI_RSC_MOVE16,
  227. ACPI_RS_OFFSET(data.common_serial_bus.type_data_length),
  228. AML_OFFSET(common_serial_bus.type_data_length),
  229. 1},
  230. /* Vendor data */
  231. {ACPI_RSC_COUNT_SERIAL_VEN,
  232. ACPI_RS_OFFSET(data.common_serial_bus.vendor_length),
  233. AML_OFFSET(common_serial_bus.type_data_length),
  234. AML_RESOURCE_SPI_MIN_DATA_LEN},
  235. {ACPI_RSC_MOVE_SERIAL_VEN,
  236. ACPI_RS_OFFSET(data.common_serial_bus.vendor_data),
  237. 0,
  238. sizeof(struct aml_resource_spi_serialbus)},
  239. /* Resource Source */
  240. {ACPI_RSC_MOVE8,
  241. ACPI_RS_OFFSET(data.common_serial_bus.resource_source.index),
  242. AML_OFFSET(common_serial_bus.res_source_index),
  243. 1},
  244. {ACPI_RSC_COUNT_SERIAL_RES,
  245. ACPI_RS_OFFSET(data.common_serial_bus.resource_source.string_length),
  246. AML_OFFSET(common_serial_bus.type_data_length),
  247. sizeof(struct aml_resource_common_serialbus)},
  248. {ACPI_RSC_MOVE_SERIAL_RES,
  249. ACPI_RS_OFFSET(data.common_serial_bus.resource_source.string_ptr),
  250. AML_OFFSET(common_serial_bus.type_data_length),
  251. sizeof(struct aml_resource_common_serialbus)},
  252. /* Spi bus type specific */
  253. {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.spi_serial_bus.wire_mode),
  254. AML_OFFSET(spi_serial_bus.type_specific_flags),
  255. 0},
  256. {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.spi_serial_bus.device_polarity),
  257. AML_OFFSET(spi_serial_bus.type_specific_flags),
  258. 1},
  259. {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.spi_serial_bus.data_bit_length),
  260. AML_OFFSET(spi_serial_bus.data_bit_length),
  261. 1},
  262. {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.spi_serial_bus.clock_phase),
  263. AML_OFFSET(spi_serial_bus.clock_phase),
  264. 1},
  265. {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.spi_serial_bus.clock_polarity),
  266. AML_OFFSET(spi_serial_bus.clock_polarity),
  267. 1},
  268. {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.spi_serial_bus.device_selection),
  269. AML_OFFSET(spi_serial_bus.device_selection),
  270. 1},
  271. {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.spi_serial_bus.connection_speed),
  272. AML_OFFSET(spi_serial_bus.connection_speed),
  273. 1},
  274. };
  275. /*******************************************************************************
  276. *
  277. * acpi_rs_convert_uart_serial_bus
  278. *
  279. ******************************************************************************/
  280. struct acpi_rsconvert_info acpi_rs_convert_uart_serial_bus[23] = {
  281. {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_SERIAL_BUS,
  282. ACPI_RS_SIZE(struct acpi_resource_uart_serialbus),
  283. ACPI_RSC_TABLE_SIZE(acpi_rs_convert_uart_serial_bus)},
  284. {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_SERIAL_BUS,
  285. sizeof(struct aml_resource_uart_serialbus),
  286. 0},
  287. {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.common_serial_bus.revision_id),
  288. AML_OFFSET(common_serial_bus.revision_id),
  289. 1},
  290. {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.common_serial_bus.type),
  291. AML_OFFSET(common_serial_bus.type),
  292. 1},
  293. {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.common_serial_bus.slave_mode),
  294. AML_OFFSET(common_serial_bus.flags),
  295. 0},
  296. {ACPI_RSC_1BITFLAG,
  297. ACPI_RS_OFFSET(data.common_serial_bus.producer_consumer),
  298. AML_OFFSET(common_serial_bus.flags),
  299. 1},
  300. {ACPI_RSC_1BITFLAG,
  301. ACPI_RS_OFFSET(data.common_serial_bus.connection_sharing),
  302. AML_OFFSET(common_serial_bus.flags),
  303. 2},
  304. {ACPI_RSC_MOVE8,
  305. ACPI_RS_OFFSET(data.common_serial_bus.type_revision_id),
  306. AML_OFFSET(common_serial_bus.type_revision_id),
  307. 1},
  308. {ACPI_RSC_MOVE16,
  309. ACPI_RS_OFFSET(data.common_serial_bus.type_data_length),
  310. AML_OFFSET(common_serial_bus.type_data_length),
  311. 1},
  312. /* Vendor data */
  313. {ACPI_RSC_COUNT_SERIAL_VEN,
  314. ACPI_RS_OFFSET(data.common_serial_bus.vendor_length),
  315. AML_OFFSET(common_serial_bus.type_data_length),
  316. AML_RESOURCE_UART_MIN_DATA_LEN},
  317. {ACPI_RSC_MOVE_SERIAL_VEN,
  318. ACPI_RS_OFFSET(data.common_serial_bus.vendor_data),
  319. 0,
  320. sizeof(struct aml_resource_uart_serialbus)},
  321. /* Resource Source */
  322. {ACPI_RSC_MOVE8,
  323. ACPI_RS_OFFSET(data.common_serial_bus.resource_source.index),
  324. AML_OFFSET(common_serial_bus.res_source_index),
  325. 1},
  326. {ACPI_RSC_COUNT_SERIAL_RES,
  327. ACPI_RS_OFFSET(data.common_serial_bus.resource_source.string_length),
  328. AML_OFFSET(common_serial_bus.type_data_length),
  329. sizeof(struct aml_resource_common_serialbus)},
  330. {ACPI_RSC_MOVE_SERIAL_RES,
  331. ACPI_RS_OFFSET(data.common_serial_bus.resource_source.string_ptr),
  332. AML_OFFSET(common_serial_bus.type_data_length),
  333. sizeof(struct aml_resource_common_serialbus)},
  334. /* Uart bus type specific */
  335. {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.uart_serial_bus.flow_control),
  336. AML_OFFSET(uart_serial_bus.type_specific_flags),
  337. 0},
  338. {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.uart_serial_bus.stop_bits),
  339. AML_OFFSET(uart_serial_bus.type_specific_flags),
  340. 2},
  341. {ACPI_RSC_3BITFLAG, ACPI_RS_OFFSET(data.uart_serial_bus.data_bits),
  342. AML_OFFSET(uart_serial_bus.type_specific_flags),
  343. 4},
  344. {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.uart_serial_bus.endian),
  345. AML_OFFSET(uart_serial_bus.type_specific_flags),
  346. 7},
  347. {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.uart_serial_bus.parity),
  348. AML_OFFSET(uart_serial_bus.parity),
  349. 1},
  350. {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.uart_serial_bus.lines_enabled),
  351. AML_OFFSET(uart_serial_bus.lines_enabled),
  352. 1},
  353. {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.uart_serial_bus.rx_fifo_size),
  354. AML_OFFSET(uart_serial_bus.rx_fifo_size),
  355. 1},
  356. {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.uart_serial_bus.tx_fifo_size),
  357. AML_OFFSET(uart_serial_bus.tx_fifo_size),
  358. 1},
  359. {ACPI_RSC_MOVE32,
  360. ACPI_RS_OFFSET(data.uart_serial_bus.default_baud_rate),
  361. AML_OFFSET(uart_serial_bus.default_baud_rate),
  362. 1},
  363. };