Lines Matching +full:factory +full:- +full:programmed
1 // SPDX-License-Identifier: GPL-2.0-only
3 * drivers/hwmon/nsa320-hwmon.c
8 * Copyright (C) 2016 Adam Baker <linux@baker-net.org.uk>
18 #include <linux/hwmon-sysfs.h>
29 * The Zyxel hwmon MCU is a Holtek HT46R065 that is factory programmed
72 mutex_lock(&hwmon->update_lock); in nsa320_hwmon_update()
74 mcu_data = hwmon->mcu_data; in nsa320_hwmon_update()
76 if (time_after(jiffies, hwmon->last_updated + HZ) || mcu_data == 0) { in nsa320_hwmon_update()
77 gpiod_set_value(hwmon->act, 1); in nsa320_hwmon_update()
82 gpiod_set_value(hwmon->clk, 0); in nsa320_hwmon_update()
84 gpiod_set_value(hwmon->clk, 1); in nsa320_hwmon_update()
86 if (gpiod_get_value(hwmon->data)) in nsa320_hwmon_update()
90 gpiod_set_value(hwmon->act, 0); in nsa320_hwmon_update()
95 mcu_data = -EIO; in nsa320_hwmon_update()
97 hwmon->mcu_data = mcu_data; in nsa320_hwmon_update()
98 hwmon->last_updated = jiffies; in nsa320_hwmon_update()
102 mutex_unlock(&hwmon->update_lock); in nsa320_hwmon_update()
110 int channel = to_sensor_dev_attr(attr)->index; in label_show()
153 { .compatible = "zyxel,nsa320-mcu", },
162 hwmon = devm_kzalloc(&pdev->dev, sizeof(*hwmon), GFP_KERNEL); in nsa320_hwmon_probe()
164 return -ENOMEM; in nsa320_hwmon_probe()
167 hwmon->act = devm_gpiod_get(&pdev->dev, "act", GPIOD_OUT_LOW); in nsa320_hwmon_probe()
168 if (IS_ERR(hwmon->act)) in nsa320_hwmon_probe()
169 return PTR_ERR(hwmon->act); in nsa320_hwmon_probe()
171 hwmon->clk = devm_gpiod_get(&pdev->dev, "clk", GPIOD_OUT_HIGH); in nsa320_hwmon_probe()
172 if (IS_ERR(hwmon->clk)) in nsa320_hwmon_probe()
173 return PTR_ERR(hwmon->clk); in nsa320_hwmon_probe()
175 hwmon->data = devm_gpiod_get(&pdev->dev, "data", GPIOD_IN); in nsa320_hwmon_probe()
176 if (IS_ERR(hwmon->data)) in nsa320_hwmon_probe()
177 return PTR_ERR(hwmon->data); in nsa320_hwmon_probe()
179 mutex_init(&hwmon->update_lock); in nsa320_hwmon_probe()
181 classdev = devm_hwmon_device_register_with_groups(&pdev->dev, in nsa320_hwmon_probe()
193 .name = "nsa320-hwmon",
202 MODULE_AUTHOR("Adam Baker <linux@baker-net.org.uk>");
205 MODULE_ALIAS("platform:nsa320-hwmon");