• Home
  • Raw
  • Download

Lines Matching refs:pv

73 	struct wf_fcu_priv *pv = container_of(ref, struct wf_fcu_priv, ref);  in wf_fcu_release()  local
75 kfree(pv); in wf_fcu_release()
86 static int wf_fcu_read_reg(struct wf_fcu_priv *pv, int reg, in wf_fcu_read_reg() argument
91 mutex_lock(&pv->lock); in wf_fcu_read_reg()
96 nw = i2c_master_send(pv->i2c, buf, 1); in wf_fcu_read_reg()
109 nr = i2c_master_recv(pv->i2c, buf, nb); in wf_fcu_read_reg()
118 mutex_unlock(&pv->lock); in wf_fcu_read_reg()
122 static int wf_fcu_write_reg(struct wf_fcu_priv *pv, int reg, in wf_fcu_write_reg() argument
133 nw = i2c_master_send(pv->i2c, buf, nb); in wf_fcu_write_reg()
147 struct wf_fcu_priv *pv = fan->fcu_priv; in wf_fcu_fan_set_rpm() local
148 int rc, shift = pv->rpm_shift; in wf_fcu_fan_set_rpm()
160 rc = wf_fcu_write_reg(pv, 0x10 + (fan->id * 2), buf, 2); in wf_fcu_fan_set_rpm()
169 struct wf_fcu_priv *pv = fan->fcu_priv; in wf_fcu_fan_get_rpm() local
170 int rc, reg_base, shift = pv->rpm_shift; in wf_fcu_fan_get_rpm()
175 rc = wf_fcu_read_reg(pv, 0xb, &failure, 1); in wf_fcu_fan_get_rpm()
180 rc = wf_fcu_read_reg(pv, 0xd, &active, 1); in wf_fcu_fan_get_rpm()
192 rc = wf_fcu_read_reg(pv, reg_base + (fan->id * 2), buf, 2); in wf_fcu_fan_get_rpm()
204 struct wf_fcu_priv *pv = fan->fcu_priv; in wf_fcu_fan_set_pwm() local
217 rc = wf_fcu_write_reg(pv, 0x30 + (fan->id * 2), buf, 1); in wf_fcu_fan_set_pwm()
226 struct wf_fcu_priv *pv = fan->fcu_priv; in wf_fcu_fan_get_pwm() local
232 rc = wf_fcu_read_reg(pv, 0x2b, &failure, 1); in wf_fcu_fan_get_pwm()
237 rc = wf_fcu_read_reg(pv, 0x2d, &active, 1); in wf_fcu_fan_get_pwm()
243 rc = wf_fcu_read_reg(pv, 0x30 + (fan->id * 2), buf, 1); in wf_fcu_fan_get_pwm()
321 struct wf_fcu_priv *pv = fan->fcu_priv; in wf_fcu_get_rpmfan_minmax() local
326 fan->min = 2400 >> pv->rpm_shift; in wf_fcu_get_rpmfan_minmax()
327 fan->max = 56000 >> pv->rpm_shift; in wf_fcu_get_rpmfan_minmax()
361 static void wf_fcu_add_fan(struct wf_fcu_priv *pv, const char *name, in wf_fcu_add_fan() argument
369 fan->fcu_priv = pv; in wf_fcu_add_fan()
396 list_add(&fan->link, &pv->fan_list); in wf_fcu_add_fan()
397 kref_get(&pv->ref); in wf_fcu_add_fan()
400 static void wf_fcu_lookup_fans(struct wf_fcu_priv *pv) in wf_fcu_lookup_fans() argument
427 struct device_node *np, *fcu = pv->i2c->dev.of_node; in wf_fcu_lookup_fans()
474 wf_fcu_add_fan(pv, name, type, id); in wf_fcu_lookup_fans()
480 static void wf_fcu_default_fans(struct wf_fcu_priv *pv) in wf_fcu_default_fans() argument
486 wf_fcu_add_fan(pv, "backside-fan", FCU_FAN_PWM, 1); in wf_fcu_default_fans()
487 wf_fcu_add_fan(pv, "drive-bay-fan", FCU_FAN_RPM, 2); in wf_fcu_default_fans()
488 wf_fcu_add_fan(pv, "slots-fan", FCU_FAN_PWM, 2); in wf_fcu_default_fans()
489 wf_fcu_add_fan(pv, "cpu-front-fan-0", FCU_FAN_RPM, 3); in wf_fcu_default_fans()
490 wf_fcu_add_fan(pv, "cpu-rear-fan-0", FCU_FAN_RPM, 4); in wf_fcu_default_fans()
491 wf_fcu_add_fan(pv, "cpu-front-fan-1", FCU_FAN_RPM, 5); in wf_fcu_default_fans()
492 wf_fcu_add_fan(pv, "cpu-rear-fan-1", FCU_FAN_RPM, 6); in wf_fcu_default_fans()
495 static int wf_fcu_init_chip(struct wf_fcu_priv *pv) in wf_fcu_init_chip() argument
500 rc = wf_fcu_write_reg(pv, 0xe, &buf, 1); in wf_fcu_init_chip()
503 rc = wf_fcu_write_reg(pv, 0x2e, &buf, 1); in wf_fcu_init_chip()
506 rc = wf_fcu_read_reg(pv, 0, &buf, 1); in wf_fcu_init_chip()
509 pv->rpm_shift = (buf == 1) ? 2 : 3; in wf_fcu_init_chip()
512 pv->rpm_shift); in wf_fcu_init_chip()
520 struct wf_fcu_priv *pv; in wf_fcu_probe() local
522 pv = kzalloc(sizeof(*pv), GFP_KERNEL); in wf_fcu_probe()
523 if (!pv) in wf_fcu_probe()
526 kref_init(&pv->ref); in wf_fcu_probe()
527 mutex_init(&pv->lock); in wf_fcu_probe()
528 INIT_LIST_HEAD(&pv->fan_list); in wf_fcu_probe()
529 pv->i2c = client; in wf_fcu_probe()
535 if (wf_fcu_init_chip(pv)) { in wf_fcu_probe()
537 kfree(pv); in wf_fcu_probe()
542 wf_fcu_lookup_fans(pv); in wf_fcu_probe()
548 if (list_empty(&pv->fan_list)) in wf_fcu_probe()
549 wf_fcu_default_fans(pv); in wf_fcu_probe()
552 if (list_empty(&pv->fan_list)) { in wf_fcu_probe()
554 kfree(pv); in wf_fcu_probe()
558 dev_set_drvdata(&client->dev, pv); in wf_fcu_probe()
565 struct wf_fcu_priv *pv = dev_get_drvdata(&client->dev); in wf_fcu_remove() local
568 while (!list_empty(&pv->fan_list)) { in wf_fcu_remove()
569 fan = list_first_entry(&pv->fan_list, struct wf_fcu_fan, link); in wf_fcu_remove()
573 kref_put(&pv->ref, wf_fcu_release); in wf_fcu_remove()