示例#1
0
static struct nouveau_i2c_port *
init_i2c(struct nvbios_init *init, int index)
{
	struct nouveau_i2c *i2c = nouveau_i2c(init->bios);

	if (index == 0xff) {
		index = NV_I2C_DEFAULT(0);
		if (init->outp && init->outp->i2c_upper_default)
			index = NV_I2C_DEFAULT(1);
	} else
	if (index < 0) {
		if (!init->outp) {
			if (init_exec(init))
				error("script needs output for i2c\n");
			return NULL;
		}

		if (index == -2 && init->outp->location) {
			index = NV_I2C_TYPE_EXTAUX(init->outp->extdev);
			return i2c->find_type(i2c, index);
		}

		index = init->outp->i2c_index;
	}

	return i2c->find(i2c, index);
}
示例#2
0
文件: base.c 项目: adakite/nouveau
static struct nvkm_i2c_port *
nvkm_i2c_find(struct nvkm_i2c *i2c, u8 index)
{
	struct nvkm_bios *bios = nvkm_bios(i2c);
	struct nvkm_i2c_port *port;

	if (index == NV_I2C_DEFAULT(0) ||
	    index == NV_I2C_DEFAULT(1)) {
		u8  ver, hdr, cnt, len;
		u16 i2c = dcb_i2c_table(bios, &ver, &hdr, &cnt, &len);
		if (i2c && ver >= 0x30) {
			u8 auxidx = nv_ro08(bios, i2c + 4);
			if (index == NV_I2C_DEFAULT(0))
				index = (auxidx & 0x0f) >> 0;
			else
示例#3
0
void
nouveau_therm_ic_ctor(struct nouveau_therm *therm)
{
	struct nouveau_therm_priv *priv = (void *)therm;
	struct nouveau_bios *bios = nouveau_bios(therm);
	struct nouveau_i2c *i2c = nouveau_i2c(therm);
	struct nvbios_extdev_func extdev_entry;

	if (!nvbios_extdev_find(bios, NVBIOS_EXTDEV_LM89, &extdev_entry)) {
		struct nouveau_i2c_board_info board[] = {
		  { { I2C_BOARD_INFO("lm90", extdev_entry.addr >> 1) }, 0},
		  { }
		};

		i2c->identify(i2c, NV_I2C_DEFAULT(0), "monitoring device",
			      board, probe_monitoring_device, therm);
		if (priv->ic)
			return;
	}

	if (!nvbios_extdev_find(bios, NVBIOS_EXTDEV_ADT7473, &extdev_entry)) {
		struct nouveau_i2c_board_info board[] = {
		  { { I2C_BOARD_INFO("adt7473", extdev_entry.addr >> 1) }, 20 },
		  { }
		};

		i2c->identify(i2c, NV_I2C_DEFAULT(0), "monitoring device",
			      board, probe_monitoring_device, therm);
		if (priv->ic)
			return;
示例#4
0
bool nvclock_i2c_sensor_init(nouveau_device *device)
{
    int num_busses = 0;
    I2CBusPtr busses[4];
    
    struct nouveau_i2c_port *port = NULL;
    
    for (int i = 0; i <= 4; i++) {
        if ((port = nouveau_i2c_find(&device->i2c, NV_I2C_DEFAULT(i)))) {
            char name[16];
            
            snprintf(name, 16, "NV_I2C_DEFAULT%X", i);
            
            busses[num_busses++] = nvclock_i2c_create_bus_ptr(device, STRDUP(name, sizeof(name)), port->drive);
        }
    }
    
    if (num_busses > 0) {
        device->nvclock_i2c_sensor = nvclock_i2c_probe_devices(device, busses, num_busses);
        
        /* When a sensor is available, enable the correct function pointers */
        if(device->nvclock_i2c_sensor) {
            nv_info(device, "found %s monitoring chip\n", device->nvclock_i2c_sensor->chip_name);
            
            switch(device->nvclock_i2c_sensor->chip_id)
            {
                case LM99:
                case MAX6559:
                    device->board_temp_get = lm99_get_board_temp;
                    device->diode_temp_get = lm99_get_gpu_temp;
                    break;
                case F75375:
                    device->board_temp_get = f75375_get_board_temp;
                    device->diode_temp_get = f75375_get_gpu_temp;
                    device->rpm_fan_get = f75375_get_fanspeed_rpm;
                    device->pwm_fan_get = f75375_get_fanspeed_pwm;
                    break;
                case W83781D:
                    device->board_temp_get = w83781d_get_board_temp;
                    device->diode_temp_get = w83781d_get_gpu_temp;
                    //nv_card->get_i2c_fanspeed_rpm = w83781d_get_fanspeed_rpm;
                    //nv_card->get_i2c_fanspeed_pwm = w83781d_get_fanspeed_pwm;
                    break;
                case W83L785R:
                    device->board_temp_get = w83l785r_get_board_temp;
                    device->diode_temp_get = w83l785r_get_gpu_temp;
                    device->rpm_fan_get = w83l785r_get_fanspeed_rpm;
                    device->pwm_fan_get = w83l785r_get_fanspeed_pwm;
                    break;
                case ADT7473:
                    device->board_temp_get = adt7473_get_board_temp;
                    device->diode_temp_get = adt7473_get_gpu_temp;
                    device->rpm_fan_get = adt7473_get_fanspeed_rpm;
                    device->pwm_fan_get = adt7473_get_fanspeed_pwm;
                    break;
                default:
                    break;
            }
        }
            
        return true;
    }
    
    return false;
}