ic.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * Copyright 2012 Nouveau community
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. * Authors: Martin Peres
  23. */
  24. #include "priv.h"
  25. #include <subdev/bios/extdev.h>
  26. #include <subdev/i2c.h>
  27. static bool
  28. probe_monitoring_device(struct nvkm_i2c_bus *bus,
  29. struct i2c_board_info *info, void *data)
  30. {
  31. struct nvkm_therm *therm = data;
  32. struct nvbios_therm_sensor *sensor = &therm->bios_sensor;
  33. struct i2c_client *client;
  34. request_module("%s%s", I2C_MODULE_PREFIX, info->type);
  35. client = i2c_new_device(&bus->i2c, info);
  36. if (!client)
  37. return false;
  38. if (!client->dev.driver ||
  39. to_i2c_driver(client->dev.driver)->detect(client, info)) {
  40. i2c_unregister_device(client);
  41. return false;
  42. }
  43. nvkm_debug(&therm->subdev,
  44. "Found an %s at address 0x%x (controlled by lm_sensors, "
  45. "temp offset %+i C)\n",
  46. info->type, info->addr, sensor->offset_constant);
  47. therm->ic = client;
  48. return true;
  49. }
  50. static struct nvkm_i2c_bus_probe
  51. nv_board_infos[] = {
  52. { { I2C_BOARD_INFO("w83l785ts", 0x2d) }, 0 },
  53. { { I2C_BOARD_INFO("w83781d", 0x2d) }, 0 },
  54. { { I2C_BOARD_INFO("adt7473", 0x2e) }, 40 },
  55. { { I2C_BOARD_INFO("adt7473", 0x2d) }, 40 },
  56. { { I2C_BOARD_INFO("adt7473", 0x2c) }, 40 },
  57. { { I2C_BOARD_INFO("f75375", 0x2e) }, 0 },
  58. { { I2C_BOARD_INFO("lm99", 0x4c) }, 0 },
  59. { { I2C_BOARD_INFO("lm90", 0x4c) }, 0 },
  60. { { I2C_BOARD_INFO("lm90", 0x4d) }, 0 },
  61. { { I2C_BOARD_INFO("adm1021", 0x18) }, 0 },
  62. { { I2C_BOARD_INFO("adm1021", 0x19) }, 0 },
  63. { { I2C_BOARD_INFO("adm1021", 0x1a) }, 0 },
  64. { { I2C_BOARD_INFO("adm1021", 0x29) }, 0 },
  65. { { I2C_BOARD_INFO("adm1021", 0x2a) }, 0 },
  66. { { I2C_BOARD_INFO("adm1021", 0x2b) }, 0 },
  67. { { I2C_BOARD_INFO("adm1021", 0x4c) }, 0 },
  68. { { I2C_BOARD_INFO("adm1021", 0x4d) }, 0 },
  69. { { I2C_BOARD_INFO("adm1021", 0x4e) }, 0 },
  70. { { I2C_BOARD_INFO("lm63", 0x18) }, 0 },
  71. { { I2C_BOARD_INFO("lm63", 0x4e) }, 0 },
  72. { }
  73. };
  74. void
  75. nvkm_therm_ic_ctor(struct nvkm_therm *therm)
  76. {
  77. struct nvkm_device *device = therm->subdev.device;
  78. struct nvkm_bios *bios = device->bios;
  79. struct nvkm_i2c *i2c = device->i2c;
  80. struct nvkm_i2c_bus *bus;
  81. struct nvbios_extdev_func extdev_entry;
  82. bus = nvkm_i2c_bus_find(i2c, NVKM_I2C_BUS_PRI);
  83. if (!bus)
  84. return;
  85. if (!nvbios_extdev_find(bios, NVBIOS_EXTDEV_LM89, &extdev_entry)) {
  86. struct nvkm_i2c_bus_probe board[] = {
  87. { { I2C_BOARD_INFO("lm90", extdev_entry.addr >> 1) }, 0},
  88. { }
  89. };
  90. nvkm_i2c_bus_probe(bus, "monitoring device", board,
  91. probe_monitoring_device, therm);
  92. if (therm->ic)
  93. return;
  94. }
  95. if (!nvbios_extdev_find(bios, NVBIOS_EXTDEV_ADT7473, &extdev_entry)) {
  96. struct nvkm_i2c_bus_probe board[] = {
  97. { { I2C_BOARD_INFO("adt7473", extdev_entry.addr >> 1) }, 20 },
  98. { }
  99. };
  100. nvkm_i2c_bus_probe(bus, "monitoring device", board,
  101. probe_monitoring_device, therm);
  102. if (therm->ic)
  103. return;
  104. }
  105. /* The vbios doesn't provide the address of an exisiting monitoring
  106. device. Let's try our static list.
  107. */
  108. nvkm_i2c_bus_probe(bus, "monitoring device", nv_board_infos,
  109. probe_monitoring_device, therm);
  110. }