rsserial.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. /*******************************************************************************
  2. *
  3. * Module Name: rsserial - GPIO/serial_bus resource descriptors
  4. *
  5. ******************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2015, 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[16] = {
  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_MOVE8,
  149. ACPI_RS_OFFSET(data.common_serial_bus.type_revision_id),
  150. AML_OFFSET(common_serial_bus.type_revision_id),
  151. 1},
  152. {ACPI_RSC_MOVE16,
  153. ACPI_RS_OFFSET(data.common_serial_bus.type_data_length),
  154. AML_OFFSET(common_serial_bus.type_data_length),
  155. 1},
  156. /* Vendor data */
  157. {ACPI_RSC_COUNT_SERIAL_VEN,
  158. ACPI_RS_OFFSET(data.common_serial_bus.vendor_length),
  159. AML_OFFSET(common_serial_bus.type_data_length),
  160. AML_RESOURCE_I2C_MIN_DATA_LEN},
  161. {ACPI_RSC_MOVE_SERIAL_VEN,
  162. ACPI_RS_OFFSET(data.common_serial_bus.vendor_data),
  163. 0,
  164. sizeof(struct aml_resource_i2c_serialbus)},
  165. /* Resource Source */
  166. {ACPI_RSC_MOVE8,
  167. ACPI_RS_OFFSET(data.common_serial_bus.resource_source.index),
  168. AML_OFFSET(common_serial_bus.res_source_index),
  169. 1},
  170. {ACPI_RSC_COUNT_SERIAL_RES,
  171. ACPI_RS_OFFSET(data.common_serial_bus.resource_source.string_length),
  172. AML_OFFSET(common_serial_bus.type_data_length),
  173. sizeof(struct aml_resource_common_serialbus)},
  174. {ACPI_RSC_MOVE_SERIAL_RES,
  175. ACPI_RS_OFFSET(data.common_serial_bus.resource_source.string_ptr),
  176. AML_OFFSET(common_serial_bus.type_data_length),
  177. sizeof(struct aml_resource_common_serialbus)},
  178. /* I2C bus type specific */
  179. {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.i2c_serial_bus.access_mode),
  180. AML_OFFSET(i2c_serial_bus.type_specific_flags),
  181. 0},
  182. {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.i2c_serial_bus.connection_speed),
  183. AML_OFFSET(i2c_serial_bus.connection_speed),
  184. 1},
  185. {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.i2c_serial_bus.slave_address),
  186. AML_OFFSET(i2c_serial_bus.slave_address),
  187. 1},
  188. };
  189. /*******************************************************************************
  190. *
  191. * acpi_rs_convert_spi_serial_bus
  192. *
  193. ******************************************************************************/
  194. struct acpi_rsconvert_info acpi_rs_convert_spi_serial_bus[20] = {
  195. {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_SERIAL_BUS,
  196. ACPI_RS_SIZE(struct acpi_resource_spi_serialbus),
  197. ACPI_RSC_TABLE_SIZE(acpi_rs_convert_spi_serial_bus)},
  198. {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_SERIAL_BUS,
  199. sizeof(struct aml_resource_spi_serialbus),
  200. 0},
  201. {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.common_serial_bus.revision_id),
  202. AML_OFFSET(common_serial_bus.revision_id),
  203. 1},
  204. {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.common_serial_bus.type),
  205. AML_OFFSET(common_serial_bus.type),
  206. 1},
  207. {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.common_serial_bus.slave_mode),
  208. AML_OFFSET(common_serial_bus.flags),
  209. 0},
  210. {ACPI_RSC_1BITFLAG,
  211. ACPI_RS_OFFSET(data.common_serial_bus.producer_consumer),
  212. AML_OFFSET(common_serial_bus.flags),
  213. 1},
  214. {ACPI_RSC_MOVE8,
  215. ACPI_RS_OFFSET(data.common_serial_bus.type_revision_id),
  216. AML_OFFSET(common_serial_bus.type_revision_id),
  217. 1},
  218. {ACPI_RSC_MOVE16,
  219. ACPI_RS_OFFSET(data.common_serial_bus.type_data_length),
  220. AML_OFFSET(common_serial_bus.type_data_length),
  221. 1},
  222. /* Vendor data */
  223. {ACPI_RSC_COUNT_SERIAL_VEN,
  224. ACPI_RS_OFFSET(data.common_serial_bus.vendor_length),
  225. AML_OFFSET(common_serial_bus.type_data_length),
  226. AML_RESOURCE_SPI_MIN_DATA_LEN},
  227. {ACPI_RSC_MOVE_SERIAL_VEN,
  228. ACPI_RS_OFFSET(data.common_serial_bus.vendor_data),
  229. 0,
  230. sizeof(struct aml_resource_spi_serialbus)},
  231. /* Resource Source */
  232. {ACPI_RSC_MOVE8,
  233. ACPI_RS_OFFSET(data.common_serial_bus.resource_source.index),
  234. AML_OFFSET(common_serial_bus.res_source_index),
  235. 1},
  236. {ACPI_RSC_COUNT_SERIAL_RES,
  237. ACPI_RS_OFFSET(data.common_serial_bus.resource_source.string_length),
  238. AML_OFFSET(common_serial_bus.type_data_length),
  239. sizeof(struct aml_resource_common_serialbus)},
  240. {ACPI_RSC_MOVE_SERIAL_RES,
  241. ACPI_RS_OFFSET(data.common_serial_bus.resource_source.string_ptr),
  242. AML_OFFSET(common_serial_bus.type_data_length),
  243. sizeof(struct aml_resource_common_serialbus)},
  244. /* Spi bus type specific */
  245. {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.spi_serial_bus.wire_mode),
  246. AML_OFFSET(spi_serial_bus.type_specific_flags),
  247. 0},
  248. {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.spi_serial_bus.device_polarity),
  249. AML_OFFSET(spi_serial_bus.type_specific_flags),
  250. 1},
  251. {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.spi_serial_bus.data_bit_length),
  252. AML_OFFSET(spi_serial_bus.data_bit_length),
  253. 1},
  254. {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.spi_serial_bus.clock_phase),
  255. AML_OFFSET(spi_serial_bus.clock_phase),
  256. 1},
  257. {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.spi_serial_bus.clock_polarity),
  258. AML_OFFSET(spi_serial_bus.clock_polarity),
  259. 1},
  260. {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.spi_serial_bus.device_selection),
  261. AML_OFFSET(spi_serial_bus.device_selection),
  262. 1},
  263. {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.spi_serial_bus.connection_speed),
  264. AML_OFFSET(spi_serial_bus.connection_speed),
  265. 1},
  266. };
  267. /*******************************************************************************
  268. *
  269. * acpi_rs_convert_uart_serial_bus
  270. *
  271. ******************************************************************************/
  272. struct acpi_rsconvert_info acpi_rs_convert_uart_serial_bus[22] = {
  273. {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_SERIAL_BUS,
  274. ACPI_RS_SIZE(struct acpi_resource_uart_serialbus),
  275. ACPI_RSC_TABLE_SIZE(acpi_rs_convert_uart_serial_bus)},
  276. {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_SERIAL_BUS,
  277. sizeof(struct aml_resource_uart_serialbus),
  278. 0},
  279. {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.common_serial_bus.revision_id),
  280. AML_OFFSET(common_serial_bus.revision_id),
  281. 1},
  282. {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.common_serial_bus.type),
  283. AML_OFFSET(common_serial_bus.type),
  284. 1},
  285. {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.common_serial_bus.slave_mode),
  286. AML_OFFSET(common_serial_bus.flags),
  287. 0},
  288. {ACPI_RSC_1BITFLAG,
  289. ACPI_RS_OFFSET(data.common_serial_bus.producer_consumer),
  290. AML_OFFSET(common_serial_bus.flags),
  291. 1},
  292. {ACPI_RSC_MOVE8,
  293. ACPI_RS_OFFSET(data.common_serial_bus.type_revision_id),
  294. AML_OFFSET(common_serial_bus.type_revision_id),
  295. 1},
  296. {ACPI_RSC_MOVE16,
  297. ACPI_RS_OFFSET(data.common_serial_bus.type_data_length),
  298. AML_OFFSET(common_serial_bus.type_data_length),
  299. 1},
  300. /* Vendor data */
  301. {ACPI_RSC_COUNT_SERIAL_VEN,
  302. ACPI_RS_OFFSET(data.common_serial_bus.vendor_length),
  303. AML_OFFSET(common_serial_bus.type_data_length),
  304. AML_RESOURCE_UART_MIN_DATA_LEN},
  305. {ACPI_RSC_MOVE_SERIAL_VEN,
  306. ACPI_RS_OFFSET(data.common_serial_bus.vendor_data),
  307. 0,
  308. sizeof(struct aml_resource_uart_serialbus)},
  309. /* Resource Source */
  310. {ACPI_RSC_MOVE8,
  311. ACPI_RS_OFFSET(data.common_serial_bus.resource_source.index),
  312. AML_OFFSET(common_serial_bus.res_source_index),
  313. 1},
  314. {ACPI_RSC_COUNT_SERIAL_RES,
  315. ACPI_RS_OFFSET(data.common_serial_bus.resource_source.string_length),
  316. AML_OFFSET(common_serial_bus.type_data_length),
  317. sizeof(struct aml_resource_common_serialbus)},
  318. {ACPI_RSC_MOVE_SERIAL_RES,
  319. ACPI_RS_OFFSET(data.common_serial_bus.resource_source.string_ptr),
  320. AML_OFFSET(common_serial_bus.type_data_length),
  321. sizeof(struct aml_resource_common_serialbus)},
  322. /* Uart bus type specific */
  323. {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.uart_serial_bus.flow_control),
  324. AML_OFFSET(uart_serial_bus.type_specific_flags),
  325. 0},
  326. {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.uart_serial_bus.stop_bits),
  327. AML_OFFSET(uart_serial_bus.type_specific_flags),
  328. 2},
  329. {ACPI_RSC_3BITFLAG, ACPI_RS_OFFSET(data.uart_serial_bus.data_bits),
  330. AML_OFFSET(uart_serial_bus.type_specific_flags),
  331. 4},
  332. {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.uart_serial_bus.endian),
  333. AML_OFFSET(uart_serial_bus.type_specific_flags),
  334. 7},
  335. {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.uart_serial_bus.parity),
  336. AML_OFFSET(uart_serial_bus.parity),
  337. 1},
  338. {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.uart_serial_bus.lines_enabled),
  339. AML_OFFSET(uart_serial_bus.lines_enabled),
  340. 1},
  341. {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.uart_serial_bus.rx_fifo_size),
  342. AML_OFFSET(uart_serial_bus.rx_fifo_size),
  343. 1},
  344. {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.uart_serial_bus.tx_fifo_size),
  345. AML_OFFSET(uart_serial_bus.tx_fifo_size),
  346. 1},
  347. {ACPI_RSC_MOVE32,
  348. ACPI_RS_OFFSET(data.uart_serial_bus.default_baud_rate),
  349. AML_OFFSET(uart_serial_bus.default_baud_rate),
  350. 1},
  351. };