Lines Matching +full:gsc +full:- +full:fan

1 // SPDX-License-Identifier: GPL-2.0
3 * The Gateworks System Controller (GSC) is a multi-function
6 * system functions such as push-button monitoring, multiple ADC's for
7 * voltage and temperature monitoring, fan controller and watchdog monitor.
15 #include <linux/mfd/gsc.h>
26 * The GSC suffers from an errata where occasionally during
40 * -EAGAIN returned when the i2c host controller is busy in gsc_write()
41 * -EIO returned when i2c device is busy in gsc_write()
43 if (ret != -EAGAIN && ret != -EIO) in gsc_write()
59 * -EAGAIN returned when the i2c host controller is busy in gsc_read()
60 * -EIO returned when i2c device is busy in gsc_read()
62 if (ret != -EAGAIN && ret != -EIO) in gsc_read()
72 * gsc_powerdown - API to use GSC to power down board for a specific time
74 * secs - number of seconds to remain powered off
76 static int gsc_powerdown(struct gsc_dev *gsc, unsigned long secs) in gsc_powerdown() argument
81 dev_info(&gsc->i2c->dev, "GSC powerdown for %ld seconds\n", in gsc_powerdown()
85 ret = regmap_bulk_write(gsc->regmap, GSC_TIME_ADD, regs, 4); in gsc_powerdown()
89 ret = regmap_update_bits(gsc->regmap, GSC_CTRL_1, in gsc_powerdown()
95 ret = regmap_update_bits(gsc->regmap, GSC_CTRL_1, in gsc_powerdown()
108 struct gsc_dev *gsc = dev_get_drvdata(dev); in gsc_show() local
109 const char *name = attr->attr.name; in gsc_show()
113 rz = sprintf(buf, "%d\n", gsc->fwver); in gsc_show()
115 rz = sprintf(buf, "0x%04x\n", gsc->fwcrc); in gsc_show()
125 struct gsc_dev *gsc = dev_get_drvdata(dev); in gsc_store() local
126 const char *name = attr->attr.name; in gsc_store()
131 gsc_powerdown(gsc, value); in gsc_store()
158 { .compatible = "gw,gsc", },
187 .name = "gateworks-gsc",
199 struct device *dev = &client->dev; in gsc_probe()
200 struct gsc_dev *gsc; in gsc_probe() local
205 gsc = devm_kzalloc(dev, sizeof(*gsc), GFP_KERNEL); in gsc_probe()
206 if (!gsc) in gsc_probe()
207 return -ENOMEM; in gsc_probe()
209 gsc->dev = &client->dev; in gsc_probe()
210 gsc->i2c = client; in gsc_probe()
211 i2c_set_clientdata(client, gsc); in gsc_probe()
213 gsc->regmap = devm_regmap_init(dev, &gsc_regmap_bus, client, in gsc_probe()
215 if (IS_ERR(gsc->regmap)) in gsc_probe()
216 return PTR_ERR(gsc->regmap); in gsc_probe()
218 if (regmap_read(gsc->regmap, GSC_FW_VER, &reg)) in gsc_probe()
219 return -EIO; in gsc_probe()
220 gsc->fwver = reg; in gsc_probe()
222 regmap_read(gsc->regmap, GSC_FW_CRC, &reg); in gsc_probe()
223 gsc->fwcrc = reg; in gsc_probe()
224 regmap_read(gsc->regmap, GSC_FW_CRC + 1, &reg); in gsc_probe()
225 gsc->fwcrc |= reg << 8; in gsc_probe()
227 gsc->i2c_hwmon = devm_i2c_new_dummy_device(dev, client->adapter, in gsc_probe()
229 if (IS_ERR(gsc->i2c_hwmon)) { in gsc_probe()
231 return PTR_ERR(gsc->i2c_hwmon); in gsc_probe()
234 ret = devm_regmap_add_irq_chip(dev, gsc->regmap, client->irq, in gsc_probe()
242 gsc->fwver, gsc->fwcrc); in gsc_probe()
244 ret = sysfs_create_group(&dev->kobj, &attr_group); in gsc_probe()
250 sysfs_remove_group(&dev->kobj, &attr_group); in gsc_probe()
259 sysfs_remove_group(&client->dev.kobj, &attr_group); in gsc_remove()
264 .name = "gateworks-gsc",
273 MODULE_DESCRIPTION("I2C Core interface for GSC");