Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright 2012 Nouveau community
0003  *
0004  * Permission is hereby granted, free of charge, to any person obtaining a
0005  * copy of this software and associated documentation files (the "Software"),
0006  * to deal in the Software without restriction, including without limitation
0007  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0008  * and/or sell copies of the Software, and to permit persons to whom the
0009  * Software is furnished to do so, subject to the following conditions:
0010  *
0011  * The above copyright notice and this permission notice shall be included in
0012  * all copies or substantial portions of the Software.
0013  *
0014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0015  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0016  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
0017  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
0018  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0019  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0020  * OTHER DEALINGS IN THE SOFTWARE.
0021  *
0022  * Authors: Martin Peres
0023  */
0024 #include "priv.h"
0025 
0026 #include <subdev/bios/extdev.h>
0027 #include <subdev/i2c.h>
0028 
0029 static bool
0030 probe_monitoring_device(struct nvkm_i2c_bus *bus,
0031             struct i2c_board_info *info, void *data)
0032 {
0033     struct nvkm_therm *therm = data;
0034     struct nvbios_therm_sensor *sensor = &therm->bios_sensor;
0035     struct i2c_client *client;
0036 
0037     request_module("%s%s", I2C_MODULE_PREFIX, info->type);
0038 
0039     client = i2c_new_client_device(&bus->i2c, info);
0040     if (IS_ERR(client))
0041         return false;
0042 
0043     if (!client->dev.driver ||
0044         to_i2c_driver(client->dev.driver)->detect(client, info)) {
0045         i2c_unregister_device(client);
0046         return false;
0047     }
0048 
0049     nvkm_debug(&therm->subdev,
0050            "Found an %s at address 0x%x (controlled by lm_sensors, "
0051            "temp offset %+i C)\n",
0052            info->type, info->addr, sensor->offset_constant);
0053     therm->ic = client;
0054     return true;
0055 }
0056 
0057 static struct nvkm_i2c_bus_probe
0058 nv_board_infos[] = {
0059     { { I2C_BOARD_INFO("w83l785ts", 0x2d) }, 0 },
0060     { { I2C_BOARD_INFO("w83781d", 0x2d) }, 0  },
0061     { { I2C_BOARD_INFO("adt7473", 0x2e) }, 40  },
0062     { { I2C_BOARD_INFO("adt7473", 0x2d) }, 40  },
0063     { { I2C_BOARD_INFO("adt7473", 0x2c) }, 40  },
0064     { { I2C_BOARD_INFO("f75375", 0x2e) }, 0  },
0065     { { I2C_BOARD_INFO("lm99", 0x4c) }, 0  },
0066     { { I2C_BOARD_INFO("lm90", 0x4c) }, 0  },
0067     { { I2C_BOARD_INFO("lm90", 0x4d) }, 0  },
0068     { { I2C_BOARD_INFO("adm1021", 0x18) }, 0  },
0069     { { I2C_BOARD_INFO("adm1021", 0x19) }, 0  },
0070     { { I2C_BOARD_INFO("adm1021", 0x1a) }, 0  },
0071     { { I2C_BOARD_INFO("adm1021", 0x29) }, 0  },
0072     { { I2C_BOARD_INFO("adm1021", 0x2a) }, 0  },
0073     { { I2C_BOARD_INFO("adm1021", 0x2b) }, 0  },
0074     { { I2C_BOARD_INFO("adm1021", 0x4c) }, 0  },
0075     { { I2C_BOARD_INFO("adm1021", 0x4d) }, 0  },
0076     { { I2C_BOARD_INFO("adm1021", 0x4e) }, 0  },
0077     { { I2C_BOARD_INFO("lm63", 0x18) }, 0  },
0078     { { I2C_BOARD_INFO("lm63", 0x4e) }, 0  },
0079     { }
0080 };
0081 
0082 void
0083 nvkm_therm_ic_ctor(struct nvkm_therm *therm)
0084 {
0085     struct nvkm_device *device = therm->subdev.device;
0086     struct nvkm_bios *bios = device->bios;
0087     struct nvkm_i2c *i2c = device->i2c;
0088     struct nvkm_i2c_bus *bus;
0089     struct nvbios_extdev_func extdev_entry;
0090 
0091     bus = nvkm_i2c_bus_find(i2c, NVKM_I2C_BUS_PRI);
0092     if (!bus)
0093         return;
0094 
0095     if (!nvbios_extdev_find(bios, NVBIOS_EXTDEV_LM89, &extdev_entry)) {
0096         struct nvkm_i2c_bus_probe board[] = {
0097           { { I2C_BOARD_INFO("lm90", extdev_entry.addr >> 1) }, 0},
0098           { }
0099         };
0100 
0101         nvkm_i2c_bus_probe(bus, "monitoring device", board,
0102                    probe_monitoring_device, therm);
0103         if (therm->ic)
0104             return;
0105     }
0106 
0107     if (!nvbios_extdev_find(bios, NVBIOS_EXTDEV_ADT7473, &extdev_entry)) {
0108         struct nvkm_i2c_bus_probe board[] = {
0109           { { I2C_BOARD_INFO("adt7473", extdev_entry.addr >> 1) }, 20 },
0110           { }
0111         };
0112 
0113         nvkm_i2c_bus_probe(bus, "monitoring device", board,
0114                    probe_monitoring_device, therm);
0115         if (therm->ic)
0116             return;
0117     }
0118 
0119     if (nvbios_extdev_skip_probe(bios))
0120         return;
0121 
0122     /* The vbios doesn't provide the address of an exisiting monitoring
0123        device. Let's try our static list.
0124      */
0125     nvkm_i2c_bus_probe(bus, "monitoring device", nv_board_infos,
0126                probe_monitoring_device, therm);
0127 }