From: Felix Fietkau Date: Tue, 10 Jan 2017 10:57:57 +0000 (+0100) Subject: kernel: move the gateworks system controller driver to an out-of-tree package X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=acd0c8c178cc709fe6ce0bf3c4a77ee249c730e4;p=openwrt%2Fstaging%2Fldir.git kernel: move the gateworks system controller driver to an out-of-tree package Signed-off-by: Felix Fietkau --- diff --git a/package/kernel/hwmon-gsc/Makefile b/package/kernel/hwmon-gsc/Makefile new file mode 100644 index 0000000000..1892e027ca --- /dev/null +++ b/package/kernel/hwmon-gsc/Makefile @@ -0,0 +1,30 @@ +include $(TOPDIR)/rules.mk +include $(INCLUDE_DIR)/kernel.mk + +PKG_NAME:=hwmon-gsc +PKG_RELEASE:=1 + +include $(INCLUDE_DIR)/package.mk + +define KernelPackage/hwmon-gsc + SUBMENU:=Hardware Monitoring Support + DEPENDS:=@TARGET_imx6||TARGET_cns3xxx kmod-hwmon-core +kmod-i2c-core + TITLE:=Driver for the Gateworks System Controller + AUTOLOAD:=$(call AutoLoad,60,gsc) + FILES:=$(PKG_BUILD_DIR)/gsc.ko +endef + +define KernelPackage/hwmon-gsc/description + Kernel module for the Gateworks System Controller chips. +endef + +define Build/Compile + $(MAKE) -C "$(LINUX_DIR)" \ + CROSS_COMPILE="$(TARGET_CROSS)" \ + ARCH="$(LINUX_KARCH)" \ + SUBDIRS="$(PKG_BUILD_DIR)" \ + EXTRA_CFLAGS="$(BUILDFLAGS)" \ + modules +endef + +$(eval $(call KernelPackage,hwmon-gsc)) diff --git a/package/kernel/hwmon-gsc/src/Makefile b/package/kernel/hwmon-gsc/src/Makefile new file mode 100644 index 0000000000..0e54aed2e3 --- /dev/null +++ b/package/kernel/hwmon-gsc/src/Makefile @@ -0,0 +1 @@ +obj-m := gsc.o diff --git a/package/kernel/hwmon-gsc/src/gsc.c b/package/kernel/hwmon-gsc/src/gsc.c new file mode 100644 index 0000000000..737cc599b4 --- /dev/null +++ b/package/kernel/hwmon-gsc/src/gsc.c @@ -0,0 +1,308 @@ +/* + * A hwmon driver for the Gateworks System Controller + * Copyright (C) 2009 Gateworks Corporation + * + * Author: Chris Lang + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, + * as published by the Free Software Foundation - version 2. + */ + +#include +#include +#include +#include +#include +#include + +#define DRV_VERSION "0.2" + +enum chips { gsp }; + +/* AD7418 registers */ +#define GSP_REG_TEMP_IN 0x00 +#define GSP_REG_VIN 0x02 +#define GSP_REG_3P3 0x05 +#define GSP_REG_BAT 0x08 +#define GSP_REG_5P0 0x0b +#define GSP_REG_CORE 0x0e +#define GSP_REG_CPU1 0x11 +#define GSP_REG_CPU2 0x14 +#define GSP_REG_DRAM 0x17 +#define GSP_REG_EXT_BAT 0x1a +#define GSP_REG_IO1 0x1d +#define GSP_REG_IO2 0x20 +#define GSP_REG_PCIE 0x23 +#define GSP_REG_CURRENT 0x26 +#define GSP_FAN_0 0x2C +#define GSP_FAN_1 0x2E +#define GSP_FAN_2 0x30 +#define GSP_FAN_3 0x32 +#define GSP_FAN_4 0x34 +#define GSP_FAN_5 0x36 + +struct gsp_sensor_info { + const char* name; + int reg; +}; + +static const struct gsp_sensor_info gsp_sensors[] = { + {"temp", GSP_REG_TEMP_IN}, + {"vin", GSP_REG_VIN}, + {"3p3", GSP_REG_3P3}, + {"bat", GSP_REG_BAT}, + {"5p0", GSP_REG_5P0}, + {"core", GSP_REG_CORE}, + {"cpu1", GSP_REG_CPU1}, + {"cpu2", GSP_REG_CPU2}, + {"dram", GSP_REG_DRAM}, + {"ext_bat", GSP_REG_EXT_BAT}, + {"io1", GSP_REG_IO1}, + {"io2", GSP_REG_IO2}, + {"pci2", GSP_REG_PCIE}, + {"current", GSP_REG_CURRENT}, + {"fan_point0", GSP_FAN_0}, + {"fan_point1", GSP_FAN_1}, + {"fan_point2", GSP_FAN_2}, + {"fan_point3", GSP_FAN_3}, + {"fan_point4", GSP_FAN_4}, + {"fan_point5", GSP_FAN_5}, +}; + +struct gsp_data { + struct device *hwmon_dev; + struct attribute_group attrs; + enum chips type; +}; + +static int gsp_probe(struct i2c_client *client, + const struct i2c_device_id *id); +static int gsp_remove(struct i2c_client *client); + +static const struct i2c_device_id gsp_id[] = { + { "gsp", 0 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, gsp_id); + +static struct i2c_driver gsp_driver = { + .driver = { + .name = "gsp", + }, + .probe = gsp_probe, + .remove = gsp_remove, + .id_table = gsp_id, +}; + +/* All registers are word-sized, except for the configuration registers. + * AD7418 uses a high-byte first convention. Do NOT use those functions to + * access the configuration registers CONF and CONF2, as they are byte-sized. + */ +static inline int gsp_read(struct i2c_client *client, u8 reg) +{ + unsigned int adc = 0; + if (reg == GSP_REG_TEMP_IN || reg > GSP_REG_CURRENT) + { + adc |= i2c_smbus_read_byte_data(client, reg); + adc |= i2c_smbus_read_byte_data(client, reg + 1) << 8; + return adc; + } + else + { + adc |= i2c_smbus_read_byte_data(client, reg); + adc |= i2c_smbus_read_byte_data(client, reg + 1) << 8; + adc |= i2c_smbus_read_byte_data(client, reg + 2) << 16; + return adc; + } +} + +static inline int gsp_write(struct i2c_client *client, u8 reg, u16 value) +{ + i2c_smbus_write_byte_data(client, reg, value & 0xff); + i2c_smbus_write_byte_data(client, reg + 1, ((value >> 8) & 0xff)); + return 1; +} + +static ssize_t show_adc(struct device *dev, struct device_attribute *devattr, + char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct i2c_client *client = to_i2c_client(dev); + return sprintf(buf, "%d\n", gsp_read(client, gsp_sensors[attr->index].reg)); +} + +static ssize_t show_label(struct device *dev, + struct device_attribute *devattr, char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + + return sprintf(buf, "%s\n", gsp_sensors[attr->index].name); +} + +static ssize_t store_fan(struct device *dev, + struct device_attribute *devattr, const char *buf, size_t count) +{ + u16 val; + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct i2c_client *client = to_i2c_client(dev); + val = simple_strtoul(buf, NULL, 10); + gsp_write(client, gsp_sensors[attr->index].reg, val); + return count; +} + +static SENSOR_DEVICE_ATTR(temp0_input, S_IRUGO, show_adc, NULL, 0); +static SENSOR_DEVICE_ATTR(temp0_label, S_IRUGO, show_label, NULL, 0); + +static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, show_adc, NULL, 1); +static SENSOR_DEVICE_ATTR(in0_label, S_IRUGO, show_label, NULL, 1); +static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, show_adc, NULL, 2); +static SENSOR_DEVICE_ATTR(in1_label, S_IRUGO, show_label, NULL, 2); +static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, show_adc, NULL, 3); +static SENSOR_DEVICE_ATTR(in2_label, S_IRUGO, show_label, NULL, 3); +static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, show_adc, NULL, 4); +static SENSOR_DEVICE_ATTR(in3_label, S_IRUGO, show_label, NULL, 4); +static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, show_adc, NULL, 5); +static SENSOR_DEVICE_ATTR(in4_label, S_IRUGO, show_label, NULL, 5); +static SENSOR_DEVICE_ATTR(in5_input, S_IRUGO, show_adc, NULL, 6); +static SENSOR_DEVICE_ATTR(in5_label, S_IRUGO, show_label, NULL, 6); +static SENSOR_DEVICE_ATTR(in6_input, S_IRUGO, show_adc, NULL, 7); +static SENSOR_DEVICE_ATTR(in6_label, S_IRUGO, show_label, NULL, 7); +static SENSOR_DEVICE_ATTR(in7_input, S_IRUGO, show_adc, NULL, 8); +static SENSOR_DEVICE_ATTR(in7_label, S_IRUGO, show_label, NULL, 8); +static SENSOR_DEVICE_ATTR(in8_input, S_IRUGO, show_adc, NULL, 9); +static SENSOR_DEVICE_ATTR(in8_label, S_IRUGO, show_label, NULL, 9); +static SENSOR_DEVICE_ATTR(in9_input, S_IRUGO, show_adc, NULL, 10); +static SENSOR_DEVICE_ATTR(in9_label, S_IRUGO, show_label, NULL, 10); +static SENSOR_DEVICE_ATTR(in10_input, S_IRUGO, show_adc, NULL, 11); +static SENSOR_DEVICE_ATTR(in10_label, S_IRUGO, show_label, NULL, 11); +static SENSOR_DEVICE_ATTR(in11_input, S_IRUGO, show_adc, NULL, 12); +static SENSOR_DEVICE_ATTR(in11_label, S_IRUGO, show_label, NULL, 12); +static SENSOR_DEVICE_ATTR(in12_input, S_IRUGO, show_adc, NULL, 13); +static SENSOR_DEVICE_ATTR(in12_label, S_IRUGO, show_label, NULL, 13); + +static SENSOR_DEVICE_ATTR(fan0_point0, S_IRUGO | S_IWUSR, show_adc, store_fan, 14); +static SENSOR_DEVICE_ATTR(fan0_point1, S_IRUGO | S_IWUSR, show_adc, store_fan, 15); +static SENSOR_DEVICE_ATTR(fan0_point2, S_IRUGO | S_IWUSR, show_adc, store_fan, 16); +static SENSOR_DEVICE_ATTR(fan0_point3, S_IRUGO | S_IWUSR, show_adc, store_fan, 17); +static SENSOR_DEVICE_ATTR(fan0_point4, S_IRUGO | S_IWUSR, show_adc, store_fan, 18); +static SENSOR_DEVICE_ATTR(fan0_point5, S_IRUGO | S_IWUSR, show_adc, store_fan, 19); + +static struct attribute *gsp_attributes[] = { + &sensor_dev_attr_temp0_input.dev_attr.attr, + &sensor_dev_attr_in0_input.dev_attr.attr, + &sensor_dev_attr_in1_input.dev_attr.attr, + &sensor_dev_attr_in2_input.dev_attr.attr, + &sensor_dev_attr_in3_input.dev_attr.attr, + &sensor_dev_attr_in4_input.dev_attr.attr, + &sensor_dev_attr_in5_input.dev_attr.attr, + &sensor_dev_attr_in6_input.dev_attr.attr, + &sensor_dev_attr_in7_input.dev_attr.attr, + &sensor_dev_attr_in8_input.dev_attr.attr, + &sensor_dev_attr_in9_input.dev_attr.attr, + &sensor_dev_attr_in10_input.dev_attr.attr, + &sensor_dev_attr_in11_input.dev_attr.attr, + &sensor_dev_attr_in12_input.dev_attr.attr, + + &sensor_dev_attr_temp0_label.dev_attr.attr, + &sensor_dev_attr_in0_label.dev_attr.attr, + &sensor_dev_attr_in1_label.dev_attr.attr, + &sensor_dev_attr_in2_label.dev_attr.attr, + &sensor_dev_attr_in3_label.dev_attr.attr, + &sensor_dev_attr_in4_label.dev_attr.attr, + &sensor_dev_attr_in5_label.dev_attr.attr, + &sensor_dev_attr_in6_label.dev_attr.attr, + &sensor_dev_attr_in7_label.dev_attr.attr, + &sensor_dev_attr_in8_label.dev_attr.attr, + &sensor_dev_attr_in9_label.dev_attr.attr, + &sensor_dev_attr_in10_label.dev_attr.attr, + &sensor_dev_attr_in11_label.dev_attr.attr, + &sensor_dev_attr_in12_label.dev_attr.attr, + + &sensor_dev_attr_fan0_point0.dev_attr.attr, + &sensor_dev_attr_fan0_point1.dev_attr.attr, + &sensor_dev_attr_fan0_point2.dev_attr.attr, + &sensor_dev_attr_fan0_point3.dev_attr.attr, + &sensor_dev_attr_fan0_point4.dev_attr.attr, + &sensor_dev_attr_fan0_point5.dev_attr.attr, + NULL +}; + + +static int gsp_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct i2c_adapter *adapter = client->adapter; + struct gsp_data *data; + int err; + + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | + I2C_FUNC_SMBUS_WORD_DATA)) { + err = -EOPNOTSUPP; + goto exit; + } + + if (!(data = kzalloc(sizeof(struct gsp_data), GFP_KERNEL))) { + err = -ENOMEM; + goto exit; + } + + i2c_set_clientdata(client, data); + + data->type = id->driver_data; + + switch (data->type) { + case 0: + data->attrs.attrs = gsp_attributes; + break; + } + + dev_info(&client->dev, "%s chip found\n", client->name); + + /* Register sysfs hooks */ + if ((err = sysfs_create_group(&client->dev.kobj, &data->attrs))) + goto exit_free; + + data->hwmon_dev = hwmon_device_register(&client->dev); + if (IS_ERR(data->hwmon_dev)) { + err = PTR_ERR(data->hwmon_dev); + goto exit_remove; + } + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &data->attrs); +exit_free: + kfree(data); +exit: + return err; +} + +static int gsp_remove(struct i2c_client *client) +{ + struct gsp_data *data = i2c_get_clientdata(client); + hwmon_device_unregister(data->hwmon_dev); + sysfs_remove_group(&client->dev.kobj, &data->attrs); + kfree(data); + return 0; +} + +static int __init gsp_init(void) +{ + return i2c_add_driver(&gsp_driver); +} + +static void __exit gsp_exit(void) +{ + i2c_del_driver(&gsp_driver); +} + +module_init(gsp_init); +module_exit(gsp_exit); + +MODULE_AUTHOR("Chris Lang "); +MODULE_DESCRIPTION("GSC HWMON driver"); +MODULE_LICENSE("GPL"); +MODULE_VERSION(DRV_VERSION); + diff --git a/package/kernel/linux/modules/hwmon.mk b/package/kernel/linux/modules/hwmon.mk index 0c52f03d0b..e2962058aa 100644 --- a/package/kernel/linux/modules/hwmon.mk +++ b/package/kernel/linux/modules/hwmon.mk @@ -313,21 +313,6 @@ endef $(eval $(call KernelPackage,hwmon-w83793)) -define KernelPackage/hwmon-gsc - TITLE:=Gateworks GSC monitoring support - KCONFIG:=CONFIG_SENSORS_GSC - FILES:=$(LINUX_DIR)/drivers/hwmon/gsc.ko - AUTOLOAD:=$(call AutoLoad,60,gsc) - $(call AddDepends/hwmon,+kmod-i2c-core) -endef - -define KernelPackage/hwmon-gsc/description - Kernel module for the Gateworks System Controller chips. -endef - -$(eval $(call KernelPackage,hwmon-gsc)) - - define KernelPackage/hwmon-tmp102 TITLE:=Texas Instruments TMP102 monitoring support KCONFIG:=CONFIG_SENSORS_TMP102 diff --git a/target/linux/generic/patches-3.18/880-gateworks_system_controller.patch b/target/linux/generic/patches-3.18/880-gateworks_system_controller.patch deleted file mode 100644 index 55e95be706..0000000000 --- a/target/linux/generic/patches-3.18/880-gateworks_system_controller.patch +++ /dev/null @@ -1,339 +0,0 @@ ---- a/drivers/hwmon/Kconfig -+++ b/drivers/hwmon/Kconfig -@@ -507,6 +507,15 @@ config SENSORS_G762 - This driver can also be built as a module. If so, the module - will be called g762. - -+config SENSORS_GSC -+ tristate "Gateworks System Controller" -+ depends on I2C -+ help -+ If you say yes here you get support for the Gateworks System Controller. -+ -+ This driver can also be built as a module. If so, the module -+ will be called gsc. -+ - config SENSORS_GPIO_FAN - tristate "GPIO fan" - depends on GPIOLIB ---- a/drivers/hwmon/Makefile -+++ b/drivers/hwmon/Makefile -@@ -153,6 +153,7 @@ obj-$(CONFIG_SENSORS_W83L785TS) += w83l7 - obj-$(CONFIG_SENSORS_W83L786NG) += w83l786ng.o - obj-$(CONFIG_SENSORS_WM831X) += wm831x-hwmon.o - obj-$(CONFIG_SENSORS_WM8350) += wm8350-hwmon.o -+obj-$(CONFIG_SENSORS_GSC) += gsc.o - - obj-$(CONFIG_PMBUS) += pmbus/ - ---- /dev/null -+++ b/drivers/hwmon/gsc.c -@@ -0,0 +1,308 @@ -+/* -+ * A hwmon driver for the Gateworks System Controller -+ * Copyright (C) 2009 Gateworks Corporation -+ * -+ * Author: Chris Lang -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License, -+ * as published by the Free Software Foundation - version 2. -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#define DRV_VERSION "0.2" -+ -+enum chips { gsp }; -+ -+/* AD7418 registers */ -+#define GSP_REG_TEMP_IN 0x00 -+#define GSP_REG_VIN 0x02 -+#define GSP_REG_3P3 0x05 -+#define GSP_REG_BAT 0x08 -+#define GSP_REG_5P0 0x0b -+#define GSP_REG_CORE 0x0e -+#define GSP_REG_CPU1 0x11 -+#define GSP_REG_CPU2 0x14 -+#define GSP_REG_DRAM 0x17 -+#define GSP_REG_EXT_BAT 0x1a -+#define GSP_REG_IO1 0x1d -+#define GSP_REG_IO2 0x20 -+#define GSP_REG_PCIE 0x23 -+#define GSP_REG_CURRENT 0x26 -+#define GSP_FAN_0 0x2C -+#define GSP_FAN_1 0x2E -+#define GSP_FAN_2 0x30 -+#define GSP_FAN_3 0x32 -+#define GSP_FAN_4 0x34 -+#define GSP_FAN_5 0x36 -+ -+struct gsp_sensor_info { -+ const char* name; -+ int reg; -+}; -+ -+static const struct gsp_sensor_info gsp_sensors[] = { -+ {"temp", GSP_REG_TEMP_IN}, -+ {"vin", GSP_REG_VIN}, -+ {"3p3", GSP_REG_3P3}, -+ {"bat", GSP_REG_BAT}, -+ {"5p0", GSP_REG_5P0}, -+ {"core", GSP_REG_CORE}, -+ {"cpu1", GSP_REG_CPU1}, -+ {"cpu2", GSP_REG_CPU2}, -+ {"dram", GSP_REG_DRAM}, -+ {"ext_bat", GSP_REG_EXT_BAT}, -+ {"io1", GSP_REG_IO1}, -+ {"io2", GSP_REG_IO2}, -+ {"pci2", GSP_REG_PCIE}, -+ {"current", GSP_REG_CURRENT}, -+ {"fan_point0", GSP_FAN_0}, -+ {"fan_point1", GSP_FAN_1}, -+ {"fan_point2", GSP_FAN_2}, -+ {"fan_point3", GSP_FAN_3}, -+ {"fan_point4", GSP_FAN_4}, -+ {"fan_point5", GSP_FAN_5}, -+}; -+ -+struct gsp_data { -+ struct device *hwmon_dev; -+ struct attribute_group attrs; -+ enum chips type; -+}; -+ -+static int gsp_probe(struct i2c_client *client, -+ const struct i2c_device_id *id); -+static int gsp_remove(struct i2c_client *client); -+ -+static const struct i2c_device_id gsp_id[] = { -+ { "gsp", 0 }, -+ { } -+}; -+MODULE_DEVICE_TABLE(i2c, gsp_id); -+ -+static struct i2c_driver gsp_driver = { -+ .driver = { -+ .name = "gsp", -+ }, -+ .probe = gsp_probe, -+ .remove = gsp_remove, -+ .id_table = gsp_id, -+}; -+ -+/* All registers are word-sized, except for the configuration registers. -+ * AD7418 uses a high-byte first convention. Do NOT use those functions to -+ * access the configuration registers CONF and CONF2, as they are byte-sized. -+ */ -+static inline int gsp_read(struct i2c_client *client, u8 reg) -+{ -+ unsigned int adc = 0; -+ if (reg == GSP_REG_TEMP_IN || reg > GSP_REG_CURRENT) -+ { -+ adc |= i2c_smbus_read_byte_data(client, reg); -+ adc |= i2c_smbus_read_byte_data(client, reg + 1) << 8; -+ return adc; -+ } -+ else -+ { -+ adc |= i2c_smbus_read_byte_data(client, reg); -+ adc |= i2c_smbus_read_byte_data(client, reg + 1) << 8; -+ adc |= i2c_smbus_read_byte_data(client, reg + 2) << 16; -+ return adc; -+ } -+} -+ -+static inline int gsp_write(struct i2c_client *client, u8 reg, u16 value) -+{ -+ i2c_smbus_write_byte_data(client, reg, value & 0xff); -+ i2c_smbus_write_byte_data(client, reg + 1, ((value >> 8) & 0xff)); -+ return 1; -+} -+ -+static ssize_t show_adc(struct device *dev, struct device_attribute *devattr, -+ char *buf) -+{ -+ struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); -+ struct i2c_client *client = to_i2c_client(dev); -+ return sprintf(buf, "%d\n", gsp_read(client, gsp_sensors[attr->index].reg)); -+} -+ -+static ssize_t show_label(struct device *dev, -+ struct device_attribute *devattr, char *buf) -+{ -+ struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); -+ -+ return sprintf(buf, "%s\n", gsp_sensors[attr->index].name); -+} -+ -+static ssize_t store_fan(struct device *dev, -+ struct device_attribute *devattr, const char *buf, size_t count) -+{ -+ u16 val; -+ struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); -+ struct i2c_client *client = to_i2c_client(dev); -+ val = simple_strtoul(buf, NULL, 10); -+ gsp_write(client, gsp_sensors[attr->index].reg, val); -+ return count; -+} -+ -+static SENSOR_DEVICE_ATTR(temp0_input, S_IRUGO, show_adc, NULL, 0); -+static SENSOR_DEVICE_ATTR(temp0_label, S_IRUGO, show_label, NULL, 0); -+ -+static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, show_adc, NULL, 1); -+static SENSOR_DEVICE_ATTR(in0_label, S_IRUGO, show_label, NULL, 1); -+static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, show_adc, NULL, 2); -+static SENSOR_DEVICE_ATTR(in1_label, S_IRUGO, show_label, NULL, 2); -+static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, show_adc, NULL, 3); -+static SENSOR_DEVICE_ATTR(in2_label, S_IRUGO, show_label, NULL, 3); -+static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, show_adc, NULL, 4); -+static SENSOR_DEVICE_ATTR(in3_label, S_IRUGO, show_label, NULL, 4); -+static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, show_adc, NULL, 5); -+static SENSOR_DEVICE_ATTR(in4_label, S_IRUGO, show_label, NULL, 5); -+static SENSOR_DEVICE_ATTR(in5_input, S_IRUGO, show_adc, NULL, 6); -+static SENSOR_DEVICE_ATTR(in5_label, S_IRUGO, show_label, NULL, 6); -+static SENSOR_DEVICE_ATTR(in6_input, S_IRUGO, show_adc, NULL, 7); -+static SENSOR_DEVICE_ATTR(in6_label, S_IRUGO, show_label, NULL, 7); -+static SENSOR_DEVICE_ATTR(in7_input, S_IRUGO, show_adc, NULL, 8); -+static SENSOR_DEVICE_ATTR(in7_label, S_IRUGO, show_label, NULL, 8); -+static SENSOR_DEVICE_ATTR(in8_input, S_IRUGO, show_adc, NULL, 9); -+static SENSOR_DEVICE_ATTR(in8_label, S_IRUGO, show_label, NULL, 9); -+static SENSOR_DEVICE_ATTR(in9_input, S_IRUGO, show_adc, NULL, 10); -+static SENSOR_DEVICE_ATTR(in9_label, S_IRUGO, show_label, NULL, 10); -+static SENSOR_DEVICE_ATTR(in10_input, S_IRUGO, show_adc, NULL, 11); -+static SENSOR_DEVICE_ATTR(in10_label, S_IRUGO, show_label, NULL, 11); -+static SENSOR_DEVICE_ATTR(in11_input, S_IRUGO, show_adc, NULL, 12); -+static SENSOR_DEVICE_ATTR(in11_label, S_IRUGO, show_label, NULL, 12); -+static SENSOR_DEVICE_ATTR(in12_input, S_IRUGO, show_adc, NULL, 13); -+static SENSOR_DEVICE_ATTR(in12_label, S_IRUGO, show_label, NULL, 13); -+ -+static SENSOR_DEVICE_ATTR(fan0_point0, S_IRUGO | S_IWUSR, show_adc, store_fan, 14); -+static SENSOR_DEVICE_ATTR(fan0_point1, S_IRUGO | S_IWUSR, show_adc, store_fan, 15); -+static SENSOR_DEVICE_ATTR(fan0_point2, S_IRUGO | S_IWUSR, show_adc, store_fan, 16); -+static SENSOR_DEVICE_ATTR(fan0_point3, S_IRUGO | S_IWUSR, show_adc, store_fan, 17); -+static SENSOR_DEVICE_ATTR(fan0_point4, S_IRUGO | S_IWUSR, show_adc, store_fan, 18); -+static SENSOR_DEVICE_ATTR(fan0_point5, S_IRUGO | S_IWUSR, show_adc, store_fan, 19); -+ -+static struct attribute *gsp_attributes[] = { -+ &sensor_dev_attr_temp0_input.dev_attr.attr, -+ &sensor_dev_attr_in0_input.dev_attr.attr, -+ &sensor_dev_attr_in1_input.dev_attr.attr, -+ &sensor_dev_attr_in2_input.dev_attr.attr, -+ &sensor_dev_attr_in3_input.dev_attr.attr, -+ &sensor_dev_attr_in4_input.dev_attr.attr, -+ &sensor_dev_attr_in5_input.dev_attr.attr, -+ &sensor_dev_attr_in6_input.dev_attr.attr, -+ &sensor_dev_attr_in7_input.dev_attr.attr, -+ &sensor_dev_attr_in8_input.dev_attr.attr, -+ &sensor_dev_attr_in9_input.dev_attr.attr, -+ &sensor_dev_attr_in10_input.dev_attr.attr, -+ &sensor_dev_attr_in11_input.dev_attr.attr, -+ &sensor_dev_attr_in12_input.dev_attr.attr, -+ -+ &sensor_dev_attr_temp0_label.dev_attr.attr, -+ &sensor_dev_attr_in0_label.dev_attr.attr, -+ &sensor_dev_attr_in1_label.dev_attr.attr, -+ &sensor_dev_attr_in2_label.dev_attr.attr, -+ &sensor_dev_attr_in3_label.dev_attr.attr, -+ &sensor_dev_attr_in4_label.dev_attr.attr, -+ &sensor_dev_attr_in5_label.dev_attr.attr, -+ &sensor_dev_attr_in6_label.dev_attr.attr, -+ &sensor_dev_attr_in7_label.dev_attr.attr, -+ &sensor_dev_attr_in8_label.dev_attr.attr, -+ &sensor_dev_attr_in9_label.dev_attr.attr, -+ &sensor_dev_attr_in10_label.dev_attr.attr, -+ &sensor_dev_attr_in11_label.dev_attr.attr, -+ &sensor_dev_attr_in12_label.dev_attr.attr, -+ -+ &sensor_dev_attr_fan0_point0.dev_attr.attr, -+ &sensor_dev_attr_fan0_point1.dev_attr.attr, -+ &sensor_dev_attr_fan0_point2.dev_attr.attr, -+ &sensor_dev_attr_fan0_point3.dev_attr.attr, -+ &sensor_dev_attr_fan0_point4.dev_attr.attr, -+ &sensor_dev_attr_fan0_point5.dev_attr.attr, -+ NULL -+}; -+ -+ -+static int gsp_probe(struct i2c_client *client, -+ const struct i2c_device_id *id) -+{ -+ struct i2c_adapter *adapter = client->adapter; -+ struct gsp_data *data; -+ int err; -+ -+ if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | -+ I2C_FUNC_SMBUS_WORD_DATA)) { -+ err = -EOPNOTSUPP; -+ goto exit; -+ } -+ -+ if (!(data = kzalloc(sizeof(struct gsp_data), GFP_KERNEL))) { -+ err = -ENOMEM; -+ goto exit; -+ } -+ -+ i2c_set_clientdata(client, data); -+ -+ data->type = id->driver_data; -+ -+ switch (data->type) { -+ case 0: -+ data->attrs.attrs = gsp_attributes; -+ break; -+ } -+ -+ dev_info(&client->dev, "%s chip found\n", client->name); -+ -+ /* Register sysfs hooks */ -+ if ((err = sysfs_create_group(&client->dev.kobj, &data->attrs))) -+ goto exit_free; -+ -+ data->hwmon_dev = hwmon_device_register(&client->dev); -+ if (IS_ERR(data->hwmon_dev)) { -+ err = PTR_ERR(data->hwmon_dev); -+ goto exit_remove; -+ } -+ -+ return 0; -+ -+exit_remove: -+ sysfs_remove_group(&client->dev.kobj, &data->attrs); -+exit_free: -+ kfree(data); -+exit: -+ return err; -+} -+ -+static int gsp_remove(struct i2c_client *client) -+{ -+ struct gsp_data *data = i2c_get_clientdata(client); -+ hwmon_device_unregister(data->hwmon_dev); -+ sysfs_remove_group(&client->dev.kobj, &data->attrs); -+ kfree(data); -+ return 0; -+} -+ -+static int __init gsp_init(void) -+{ -+ return i2c_add_driver(&gsp_driver); -+} -+ -+static void __exit gsp_exit(void) -+{ -+ i2c_del_driver(&gsp_driver); -+} -+ -+module_init(gsp_init); -+module_exit(gsp_exit); -+ -+MODULE_AUTHOR("Chris Lang "); -+MODULE_DESCRIPTION("GSC HWMON driver"); -+MODULE_LICENSE("GPL"); -+MODULE_VERSION(DRV_VERSION); -+ diff --git a/target/linux/generic/patches-4.1/880-gateworks_system_controller.patch b/target/linux/generic/patches-4.1/880-gateworks_system_controller.patch deleted file mode 100644 index 265772309b..0000000000 --- a/target/linux/generic/patches-4.1/880-gateworks_system_controller.patch +++ /dev/null @@ -1,339 +0,0 @@ ---- a/drivers/hwmon/Kconfig -+++ b/drivers/hwmon/Kconfig -@@ -507,6 +507,15 @@ config SENSORS_G762 - This driver can also be built as a module. If so, the module - will be called g762. - -+config SENSORS_GSC -+ tristate "Gateworks System Controller" -+ depends on I2C -+ help -+ If you say yes here you get support for the Gateworks System Controller. -+ -+ This driver can also be built as a module. If so, the module -+ will be called gsc. -+ - config SENSORS_GPIO_FAN - tristate "GPIO fan" - depends on GPIOLIB ---- a/drivers/hwmon/Makefile -+++ b/drivers/hwmon/Makefile -@@ -156,6 +156,7 @@ obj-$(CONFIG_SENSORS_W83L785TS) += w83l7 - obj-$(CONFIG_SENSORS_W83L786NG) += w83l786ng.o - obj-$(CONFIG_SENSORS_WM831X) += wm831x-hwmon.o - obj-$(CONFIG_SENSORS_WM8350) += wm8350-hwmon.o -+obj-$(CONFIG_SENSORS_GSC) += gsc.o - - obj-$(CONFIG_PMBUS) += pmbus/ - ---- /dev/null -+++ b/drivers/hwmon/gsc.c -@@ -0,0 +1,308 @@ -+/* -+ * A hwmon driver for the Gateworks System Controller -+ * Copyright (C) 2009 Gateworks Corporation -+ * -+ * Author: Chris Lang -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License, -+ * as published by the Free Software Foundation - version 2. -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#define DRV_VERSION "0.2" -+ -+enum chips { gsp }; -+ -+/* AD7418 registers */ -+#define GSP_REG_TEMP_IN 0x00 -+#define GSP_REG_VIN 0x02 -+#define GSP_REG_3P3 0x05 -+#define GSP_REG_BAT 0x08 -+#define GSP_REG_5P0 0x0b -+#define GSP_REG_CORE 0x0e -+#define GSP_REG_CPU1 0x11 -+#define GSP_REG_CPU2 0x14 -+#define GSP_REG_DRAM 0x17 -+#define GSP_REG_EXT_BAT 0x1a -+#define GSP_REG_IO1 0x1d -+#define GSP_REG_IO2 0x20 -+#define GSP_REG_PCIE 0x23 -+#define GSP_REG_CURRENT 0x26 -+#define GSP_FAN_0 0x2C -+#define GSP_FAN_1 0x2E -+#define GSP_FAN_2 0x30 -+#define GSP_FAN_3 0x32 -+#define GSP_FAN_4 0x34 -+#define GSP_FAN_5 0x36 -+ -+struct gsp_sensor_info { -+ const char* name; -+ int reg; -+}; -+ -+static const struct gsp_sensor_info gsp_sensors[] = { -+ {"temp", GSP_REG_TEMP_IN}, -+ {"vin", GSP_REG_VIN}, -+ {"3p3", GSP_REG_3P3}, -+ {"bat", GSP_REG_BAT}, -+ {"5p0", GSP_REG_5P0}, -+ {"core", GSP_REG_CORE}, -+ {"cpu1", GSP_REG_CPU1}, -+ {"cpu2", GSP_REG_CPU2}, -+ {"dram", GSP_REG_DRAM}, -+ {"ext_bat", GSP_REG_EXT_BAT}, -+ {"io1", GSP_REG_IO1}, -+ {"io2", GSP_REG_IO2}, -+ {"pci2", GSP_REG_PCIE}, -+ {"current", GSP_REG_CURRENT}, -+ {"fan_point0", GSP_FAN_0}, -+ {"fan_point1", GSP_FAN_1}, -+ {"fan_point2", GSP_FAN_2}, -+ {"fan_point3", GSP_FAN_3}, -+ {"fan_point4", GSP_FAN_4}, -+ {"fan_point5", GSP_FAN_5}, -+}; -+ -+struct gsp_data { -+ struct device *hwmon_dev; -+ struct attribute_group attrs; -+ enum chips type; -+}; -+ -+static int gsp_probe(struct i2c_client *client, -+ const struct i2c_device_id *id); -+static int gsp_remove(struct i2c_client *client); -+ -+static const struct i2c_device_id gsp_id[] = { -+ { "gsp", 0 }, -+ { } -+}; -+MODULE_DEVICE_TABLE(i2c, gsp_id); -+ -+static struct i2c_driver gsp_driver = { -+ .driver = { -+ .name = "gsp", -+ }, -+ .probe = gsp_probe, -+ .remove = gsp_remove, -+ .id_table = gsp_id, -+}; -+ -+/* All registers are word-sized, except for the configuration registers. -+ * AD7418 uses a high-byte first convention. Do NOT use those functions to -+ * access the configuration registers CONF and CONF2, as they are byte-sized. -+ */ -+static inline int gsp_read(struct i2c_client *client, u8 reg) -+{ -+ unsigned int adc = 0; -+ if (reg == GSP_REG_TEMP_IN || reg > GSP_REG_CURRENT) -+ { -+ adc |= i2c_smbus_read_byte_data(client, reg); -+ adc |= i2c_smbus_read_byte_data(client, reg + 1) << 8; -+ return adc; -+ } -+ else -+ { -+ adc |= i2c_smbus_read_byte_data(client, reg); -+ adc |= i2c_smbus_read_byte_data(client, reg + 1) << 8; -+ adc |= i2c_smbus_read_byte_data(client, reg + 2) << 16; -+ return adc; -+ } -+} -+ -+static inline int gsp_write(struct i2c_client *client, u8 reg, u16 value) -+{ -+ i2c_smbus_write_byte_data(client, reg, value & 0xff); -+ i2c_smbus_write_byte_data(client, reg + 1, ((value >> 8) & 0xff)); -+ return 1; -+} -+ -+static ssize_t show_adc(struct device *dev, struct device_attribute *devattr, -+ char *buf) -+{ -+ struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); -+ struct i2c_client *client = to_i2c_client(dev); -+ return sprintf(buf, "%d\n", gsp_read(client, gsp_sensors[attr->index].reg)); -+} -+ -+static ssize_t show_label(struct device *dev, -+ struct device_attribute *devattr, char *buf) -+{ -+ struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); -+ -+ return sprintf(buf, "%s\n", gsp_sensors[attr->index].name); -+} -+ -+static ssize_t store_fan(struct device *dev, -+ struct device_attribute *devattr, const char *buf, size_t count) -+{ -+ u16 val; -+ struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); -+ struct i2c_client *client = to_i2c_client(dev); -+ val = simple_strtoul(buf, NULL, 10); -+ gsp_write(client, gsp_sensors[attr->index].reg, val); -+ return count; -+} -+ -+static SENSOR_DEVICE_ATTR(temp0_input, S_IRUGO, show_adc, NULL, 0); -+static SENSOR_DEVICE_ATTR(temp0_label, S_IRUGO, show_label, NULL, 0); -+ -+static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, show_adc, NULL, 1); -+static SENSOR_DEVICE_ATTR(in0_label, S_IRUGO, show_label, NULL, 1); -+static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, show_adc, NULL, 2); -+static SENSOR_DEVICE_ATTR(in1_label, S_IRUGO, show_label, NULL, 2); -+static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, show_adc, NULL, 3); -+static SENSOR_DEVICE_ATTR(in2_label, S_IRUGO, show_label, NULL, 3); -+static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, show_adc, NULL, 4); -+static SENSOR_DEVICE_ATTR(in3_label, S_IRUGO, show_label, NULL, 4); -+static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, show_adc, NULL, 5); -+static SENSOR_DEVICE_ATTR(in4_label, S_IRUGO, show_label, NULL, 5); -+static SENSOR_DEVICE_ATTR(in5_input, S_IRUGO, show_adc, NULL, 6); -+static SENSOR_DEVICE_ATTR(in5_label, S_IRUGO, show_label, NULL, 6); -+static SENSOR_DEVICE_ATTR(in6_input, S_IRUGO, show_adc, NULL, 7); -+static SENSOR_DEVICE_ATTR(in6_label, S_IRUGO, show_label, NULL, 7); -+static SENSOR_DEVICE_ATTR(in7_input, S_IRUGO, show_adc, NULL, 8); -+static SENSOR_DEVICE_ATTR(in7_label, S_IRUGO, show_label, NULL, 8); -+static SENSOR_DEVICE_ATTR(in8_input, S_IRUGO, show_adc, NULL, 9); -+static SENSOR_DEVICE_ATTR(in8_label, S_IRUGO, show_label, NULL, 9); -+static SENSOR_DEVICE_ATTR(in9_input, S_IRUGO, show_adc, NULL, 10); -+static SENSOR_DEVICE_ATTR(in9_label, S_IRUGO, show_label, NULL, 10); -+static SENSOR_DEVICE_ATTR(in10_input, S_IRUGO, show_adc, NULL, 11); -+static SENSOR_DEVICE_ATTR(in10_label, S_IRUGO, show_label, NULL, 11); -+static SENSOR_DEVICE_ATTR(in11_input, S_IRUGO, show_adc, NULL, 12); -+static SENSOR_DEVICE_ATTR(in11_label, S_IRUGO, show_label, NULL, 12); -+static SENSOR_DEVICE_ATTR(in12_input, S_IRUGO, show_adc, NULL, 13); -+static SENSOR_DEVICE_ATTR(in12_label, S_IRUGO, show_label, NULL, 13); -+ -+static SENSOR_DEVICE_ATTR(fan0_point0, S_IRUGO | S_IWUSR, show_adc, store_fan, 14); -+static SENSOR_DEVICE_ATTR(fan0_point1, S_IRUGO | S_IWUSR, show_adc, store_fan, 15); -+static SENSOR_DEVICE_ATTR(fan0_point2, S_IRUGO | S_IWUSR, show_adc, store_fan, 16); -+static SENSOR_DEVICE_ATTR(fan0_point3, S_IRUGO | S_IWUSR, show_adc, store_fan, 17); -+static SENSOR_DEVICE_ATTR(fan0_point4, S_IRUGO | S_IWUSR, show_adc, store_fan, 18); -+static SENSOR_DEVICE_ATTR(fan0_point5, S_IRUGO | S_IWUSR, show_adc, store_fan, 19); -+ -+static struct attribute *gsp_attributes[] = { -+ &sensor_dev_attr_temp0_input.dev_attr.attr, -+ &sensor_dev_attr_in0_input.dev_attr.attr, -+ &sensor_dev_attr_in1_input.dev_attr.attr, -+ &sensor_dev_attr_in2_input.dev_attr.attr, -+ &sensor_dev_attr_in3_input.dev_attr.attr, -+ &sensor_dev_attr_in4_input.dev_attr.attr, -+ &sensor_dev_attr_in5_input.dev_attr.attr, -+ &sensor_dev_attr_in6_input.dev_attr.attr, -+ &sensor_dev_attr_in7_input.dev_attr.attr, -+ &sensor_dev_attr_in8_input.dev_attr.attr, -+ &sensor_dev_attr_in9_input.dev_attr.attr, -+ &sensor_dev_attr_in10_input.dev_attr.attr, -+ &sensor_dev_attr_in11_input.dev_attr.attr, -+ &sensor_dev_attr_in12_input.dev_attr.attr, -+ -+ &sensor_dev_attr_temp0_label.dev_attr.attr, -+ &sensor_dev_attr_in0_label.dev_attr.attr, -+ &sensor_dev_attr_in1_label.dev_attr.attr, -+ &sensor_dev_attr_in2_label.dev_attr.attr, -+ &sensor_dev_attr_in3_label.dev_attr.attr, -+ &sensor_dev_attr_in4_label.dev_attr.attr, -+ &sensor_dev_attr_in5_label.dev_attr.attr, -+ &sensor_dev_attr_in6_label.dev_attr.attr, -+ &sensor_dev_attr_in7_label.dev_attr.attr, -+ &sensor_dev_attr_in8_label.dev_attr.attr, -+ &sensor_dev_attr_in9_label.dev_attr.attr, -+ &sensor_dev_attr_in10_label.dev_attr.attr, -+ &sensor_dev_attr_in11_label.dev_attr.attr, -+ &sensor_dev_attr_in12_label.dev_attr.attr, -+ -+ &sensor_dev_attr_fan0_point0.dev_attr.attr, -+ &sensor_dev_attr_fan0_point1.dev_attr.attr, -+ &sensor_dev_attr_fan0_point2.dev_attr.attr, -+ &sensor_dev_attr_fan0_point3.dev_attr.attr, -+ &sensor_dev_attr_fan0_point4.dev_attr.attr, -+ &sensor_dev_attr_fan0_point5.dev_attr.attr, -+ NULL -+}; -+ -+ -+static int gsp_probe(struct i2c_client *client, -+ const struct i2c_device_id *id) -+{ -+ struct i2c_adapter *adapter = client->adapter; -+ struct gsp_data *data; -+ int err; -+ -+ if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | -+ I2C_FUNC_SMBUS_WORD_DATA)) { -+ err = -EOPNOTSUPP; -+ goto exit; -+ } -+ -+ if (!(data = kzalloc(sizeof(struct gsp_data), GFP_KERNEL))) { -+ err = -ENOMEM; -+ goto exit; -+ } -+ -+ i2c_set_clientdata(client, data); -+ -+ data->type = id->driver_data; -+ -+ switch (data->type) { -+ case 0: -+ data->attrs.attrs = gsp_attributes; -+ break; -+ } -+ -+ dev_info(&client->dev, "%s chip found\n", client->name); -+ -+ /* Register sysfs hooks */ -+ if ((err = sysfs_create_group(&client->dev.kobj, &data->attrs))) -+ goto exit_free; -+ -+ data->hwmon_dev = hwmon_device_register(&client->dev); -+ if (IS_ERR(data->hwmon_dev)) { -+ err = PTR_ERR(data->hwmon_dev); -+ goto exit_remove; -+ } -+ -+ return 0; -+ -+exit_remove: -+ sysfs_remove_group(&client->dev.kobj, &data->attrs); -+exit_free: -+ kfree(data); -+exit: -+ return err; -+} -+ -+static int gsp_remove(struct i2c_client *client) -+{ -+ struct gsp_data *data = i2c_get_clientdata(client); -+ hwmon_device_unregister(data->hwmon_dev); -+ sysfs_remove_group(&client->dev.kobj, &data->attrs); -+ kfree(data); -+ return 0; -+} -+ -+static int __init gsp_init(void) -+{ -+ return i2c_add_driver(&gsp_driver); -+} -+ -+static void __exit gsp_exit(void) -+{ -+ i2c_del_driver(&gsp_driver); -+} -+ -+module_init(gsp_init); -+module_exit(gsp_exit); -+ -+MODULE_AUTHOR("Chris Lang "); -+MODULE_DESCRIPTION("GSC HWMON driver"); -+MODULE_LICENSE("GPL"); -+MODULE_VERSION(DRV_VERSION); -+ diff --git a/target/linux/generic/patches-4.4/880-gateworks_system_controller.patch b/target/linux/generic/patches-4.4/880-gateworks_system_controller.patch deleted file mode 100644 index a19f30082e..0000000000 --- a/target/linux/generic/patches-4.4/880-gateworks_system_controller.patch +++ /dev/null @@ -1,339 +0,0 @@ ---- a/drivers/hwmon/Kconfig -+++ b/drivers/hwmon/Kconfig -@@ -527,6 +527,15 @@ config SENSORS_G762 - This driver can also be built as a module. If so, the module - will be called g762. - -+config SENSORS_GSC -+ tristate "Gateworks System Controller" -+ depends on I2C -+ help -+ If you say yes here you get support for the Gateworks System Controller. -+ -+ This driver can also be built as a module. If so, the module -+ will be called gsc. -+ - config SENSORS_GPIO_FAN - tristate "GPIO fan" - depends on GPIOLIB || COMPILE_TEST ---- a/drivers/hwmon/Makefile -+++ b/drivers/hwmon/Makefile -@@ -160,6 +160,7 @@ obj-$(CONFIG_SENSORS_W83L785TS) += w83l7 - obj-$(CONFIG_SENSORS_W83L786NG) += w83l786ng.o - obj-$(CONFIG_SENSORS_WM831X) += wm831x-hwmon.o - obj-$(CONFIG_SENSORS_WM8350) += wm8350-hwmon.o -+obj-$(CONFIG_SENSORS_GSC) += gsc.o - - obj-$(CONFIG_PMBUS) += pmbus/ - ---- /dev/null -+++ b/drivers/hwmon/gsc.c -@@ -0,0 +1,308 @@ -+/* -+ * A hwmon driver for the Gateworks System Controller -+ * Copyright (C) 2009 Gateworks Corporation -+ * -+ * Author: Chris Lang -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License, -+ * as published by the Free Software Foundation - version 2. -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#define DRV_VERSION "0.2" -+ -+enum chips { gsp }; -+ -+/* AD7418 registers */ -+#define GSP_REG_TEMP_IN 0x00 -+#define GSP_REG_VIN 0x02 -+#define GSP_REG_3P3 0x05 -+#define GSP_REG_BAT 0x08 -+#define GSP_REG_5P0 0x0b -+#define GSP_REG_CORE 0x0e -+#define GSP_REG_CPU1 0x11 -+#define GSP_REG_CPU2 0x14 -+#define GSP_REG_DRAM 0x17 -+#define GSP_REG_EXT_BAT 0x1a -+#define GSP_REG_IO1 0x1d -+#define GSP_REG_IO2 0x20 -+#define GSP_REG_PCIE 0x23 -+#define GSP_REG_CURRENT 0x26 -+#define GSP_FAN_0 0x2C -+#define GSP_FAN_1 0x2E -+#define GSP_FAN_2 0x30 -+#define GSP_FAN_3 0x32 -+#define GSP_FAN_4 0x34 -+#define GSP_FAN_5 0x36 -+ -+struct gsp_sensor_info { -+ const char* name; -+ int reg; -+}; -+ -+static const struct gsp_sensor_info gsp_sensors[] = { -+ {"temp", GSP_REG_TEMP_IN}, -+ {"vin", GSP_REG_VIN}, -+ {"3p3", GSP_REG_3P3}, -+ {"bat", GSP_REG_BAT}, -+ {"5p0", GSP_REG_5P0}, -+ {"core", GSP_REG_CORE}, -+ {"cpu1", GSP_REG_CPU1}, -+ {"cpu2", GSP_REG_CPU2}, -+ {"dram", GSP_REG_DRAM}, -+ {"ext_bat", GSP_REG_EXT_BAT}, -+ {"io1", GSP_REG_IO1}, -+ {"io2", GSP_REG_IO2}, -+ {"pci2", GSP_REG_PCIE}, -+ {"current", GSP_REG_CURRENT}, -+ {"fan_point0", GSP_FAN_0}, -+ {"fan_point1", GSP_FAN_1}, -+ {"fan_point2", GSP_FAN_2}, -+ {"fan_point3", GSP_FAN_3}, -+ {"fan_point4", GSP_FAN_4}, -+ {"fan_point5", GSP_FAN_5}, -+}; -+ -+struct gsp_data { -+ struct device *hwmon_dev; -+ struct attribute_group attrs; -+ enum chips type; -+}; -+ -+static int gsp_probe(struct i2c_client *client, -+ const struct i2c_device_id *id); -+static int gsp_remove(struct i2c_client *client); -+ -+static const struct i2c_device_id gsp_id[] = { -+ { "gsp", 0 }, -+ { } -+}; -+MODULE_DEVICE_TABLE(i2c, gsp_id); -+ -+static struct i2c_driver gsp_driver = { -+ .driver = { -+ .name = "gsp", -+ }, -+ .probe = gsp_probe, -+ .remove = gsp_remove, -+ .id_table = gsp_id, -+}; -+ -+/* All registers are word-sized, except for the configuration registers. -+ * AD7418 uses a high-byte first convention. Do NOT use those functions to -+ * access the configuration registers CONF and CONF2, as they are byte-sized. -+ */ -+static inline int gsp_read(struct i2c_client *client, u8 reg) -+{ -+ unsigned int adc = 0; -+ if (reg == GSP_REG_TEMP_IN || reg > GSP_REG_CURRENT) -+ { -+ adc |= i2c_smbus_read_byte_data(client, reg); -+ adc |= i2c_smbus_read_byte_data(client, reg + 1) << 8; -+ return adc; -+ } -+ else -+ { -+ adc |= i2c_smbus_read_byte_data(client, reg); -+ adc |= i2c_smbus_read_byte_data(client, reg + 1) << 8; -+ adc |= i2c_smbus_read_byte_data(client, reg + 2) << 16; -+ return adc; -+ } -+} -+ -+static inline int gsp_write(struct i2c_client *client, u8 reg, u16 value) -+{ -+ i2c_smbus_write_byte_data(client, reg, value & 0xff); -+ i2c_smbus_write_byte_data(client, reg + 1, ((value >> 8) & 0xff)); -+ return 1; -+} -+ -+static ssize_t show_adc(struct device *dev, struct device_attribute *devattr, -+ char *buf) -+{ -+ struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); -+ struct i2c_client *client = to_i2c_client(dev); -+ return sprintf(buf, "%d\n", gsp_read(client, gsp_sensors[attr->index].reg)); -+} -+ -+static ssize_t show_label(struct device *dev, -+ struct device_attribute *devattr, char *buf) -+{ -+ struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); -+ -+ return sprintf(buf, "%s\n", gsp_sensors[attr->index].name); -+} -+ -+static ssize_t store_fan(struct device *dev, -+ struct device_attribute *devattr, const char *buf, size_t count) -+{ -+ u16 val; -+ struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); -+ struct i2c_client *client = to_i2c_client(dev); -+ val = simple_strtoul(buf, NULL, 10); -+ gsp_write(client, gsp_sensors[attr->index].reg, val); -+ return count; -+} -+ -+static SENSOR_DEVICE_ATTR(temp0_input, S_IRUGO, show_adc, NULL, 0); -+static SENSOR_DEVICE_ATTR(temp0_label, S_IRUGO, show_label, NULL, 0); -+ -+static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, show_adc, NULL, 1); -+static SENSOR_DEVICE_ATTR(in0_label, S_IRUGO, show_label, NULL, 1); -+static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, show_adc, NULL, 2); -+static SENSOR_DEVICE_ATTR(in1_label, S_IRUGO, show_label, NULL, 2); -+static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, show_adc, NULL, 3); -+static SENSOR_DEVICE_ATTR(in2_label, S_IRUGO, show_label, NULL, 3); -+static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, show_adc, NULL, 4); -+static SENSOR_DEVICE_ATTR(in3_label, S_IRUGO, show_label, NULL, 4); -+static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, show_adc, NULL, 5); -+static SENSOR_DEVICE_ATTR(in4_label, S_IRUGO, show_label, NULL, 5); -+static SENSOR_DEVICE_ATTR(in5_input, S_IRUGO, show_adc, NULL, 6); -+static SENSOR_DEVICE_ATTR(in5_label, S_IRUGO, show_label, NULL, 6); -+static SENSOR_DEVICE_ATTR(in6_input, S_IRUGO, show_adc, NULL, 7); -+static SENSOR_DEVICE_ATTR(in6_label, S_IRUGO, show_label, NULL, 7); -+static SENSOR_DEVICE_ATTR(in7_input, S_IRUGO, show_adc, NULL, 8); -+static SENSOR_DEVICE_ATTR(in7_label, S_IRUGO, show_label, NULL, 8); -+static SENSOR_DEVICE_ATTR(in8_input, S_IRUGO, show_adc, NULL, 9); -+static SENSOR_DEVICE_ATTR(in8_label, S_IRUGO, show_label, NULL, 9); -+static SENSOR_DEVICE_ATTR(in9_input, S_IRUGO, show_adc, NULL, 10); -+static SENSOR_DEVICE_ATTR(in9_label, S_IRUGO, show_label, NULL, 10); -+static SENSOR_DEVICE_ATTR(in10_input, S_IRUGO, show_adc, NULL, 11); -+static SENSOR_DEVICE_ATTR(in10_label, S_IRUGO, show_label, NULL, 11); -+static SENSOR_DEVICE_ATTR(in11_input, S_IRUGO, show_adc, NULL, 12); -+static SENSOR_DEVICE_ATTR(in11_label, S_IRUGO, show_label, NULL, 12); -+static SENSOR_DEVICE_ATTR(in12_input, S_IRUGO, show_adc, NULL, 13); -+static SENSOR_DEVICE_ATTR(in12_label, S_IRUGO, show_label, NULL, 13); -+ -+static SENSOR_DEVICE_ATTR(fan0_point0, S_IRUGO | S_IWUSR, show_adc, store_fan, 14); -+static SENSOR_DEVICE_ATTR(fan0_point1, S_IRUGO | S_IWUSR, show_adc, store_fan, 15); -+static SENSOR_DEVICE_ATTR(fan0_point2, S_IRUGO | S_IWUSR, show_adc, store_fan, 16); -+static SENSOR_DEVICE_ATTR(fan0_point3, S_IRUGO | S_IWUSR, show_adc, store_fan, 17); -+static SENSOR_DEVICE_ATTR(fan0_point4, S_IRUGO | S_IWUSR, show_adc, store_fan, 18); -+static SENSOR_DEVICE_ATTR(fan0_point5, S_IRUGO | S_IWUSR, show_adc, store_fan, 19); -+ -+static struct attribute *gsp_attributes[] = { -+ &sensor_dev_attr_temp0_input.dev_attr.attr, -+ &sensor_dev_attr_in0_input.dev_attr.attr, -+ &sensor_dev_attr_in1_input.dev_attr.attr, -+ &sensor_dev_attr_in2_input.dev_attr.attr, -+ &sensor_dev_attr_in3_input.dev_attr.attr, -+ &sensor_dev_attr_in4_input.dev_attr.attr, -+ &sensor_dev_attr_in5_input.dev_attr.attr, -+ &sensor_dev_attr_in6_input.dev_attr.attr, -+ &sensor_dev_attr_in7_input.dev_attr.attr, -+ &sensor_dev_attr_in8_input.dev_attr.attr, -+ &sensor_dev_attr_in9_input.dev_attr.attr, -+ &sensor_dev_attr_in10_input.dev_attr.attr, -+ &sensor_dev_attr_in11_input.dev_attr.attr, -+ &sensor_dev_attr_in12_input.dev_attr.attr, -+ -+ &sensor_dev_attr_temp0_label.dev_attr.attr, -+ &sensor_dev_attr_in0_label.dev_attr.attr, -+ &sensor_dev_attr_in1_label.dev_attr.attr, -+ &sensor_dev_attr_in2_label.dev_attr.attr, -+ &sensor_dev_attr_in3_label.dev_attr.attr, -+ &sensor_dev_attr_in4_label.dev_attr.attr, -+ &sensor_dev_attr_in5_label.dev_attr.attr, -+ &sensor_dev_attr_in6_label.dev_attr.attr, -+ &sensor_dev_attr_in7_label.dev_attr.attr, -+ &sensor_dev_attr_in8_label.dev_attr.attr, -+ &sensor_dev_attr_in9_label.dev_attr.attr, -+ &sensor_dev_attr_in10_label.dev_attr.attr, -+ &sensor_dev_attr_in11_label.dev_attr.attr, -+ &sensor_dev_attr_in12_label.dev_attr.attr, -+ -+ &sensor_dev_attr_fan0_point0.dev_attr.attr, -+ &sensor_dev_attr_fan0_point1.dev_attr.attr, -+ &sensor_dev_attr_fan0_point2.dev_attr.attr, -+ &sensor_dev_attr_fan0_point3.dev_attr.attr, -+ &sensor_dev_attr_fan0_point4.dev_attr.attr, -+ &sensor_dev_attr_fan0_point5.dev_attr.attr, -+ NULL -+}; -+ -+ -+static int gsp_probe(struct i2c_client *client, -+ const struct i2c_device_id *id) -+{ -+ struct i2c_adapter *adapter = client->adapter; -+ struct gsp_data *data; -+ int err; -+ -+ if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | -+ I2C_FUNC_SMBUS_WORD_DATA)) { -+ err = -EOPNOTSUPP; -+ goto exit; -+ } -+ -+ if (!(data = kzalloc(sizeof(struct gsp_data), GFP_KERNEL))) { -+ err = -ENOMEM; -+ goto exit; -+ } -+ -+ i2c_set_clientdata(client, data); -+ -+ data->type = id->driver_data; -+ -+ switch (data->type) { -+ case 0: -+ data->attrs.attrs = gsp_attributes; -+ break; -+ } -+ -+ dev_info(&client->dev, "%s chip found\n", client->name); -+ -+ /* Register sysfs hooks */ -+ if ((err = sysfs_create_group(&client->dev.kobj, &data->attrs))) -+ goto exit_free; -+ -+ data->hwmon_dev = hwmon_device_register(&client->dev); -+ if (IS_ERR(data->hwmon_dev)) { -+ err = PTR_ERR(data->hwmon_dev); -+ goto exit_remove; -+ } -+ -+ return 0; -+ -+exit_remove: -+ sysfs_remove_group(&client->dev.kobj, &data->attrs); -+exit_free: -+ kfree(data); -+exit: -+ return err; -+} -+ -+static int gsp_remove(struct i2c_client *client) -+{ -+ struct gsp_data *data = i2c_get_clientdata(client); -+ hwmon_device_unregister(data->hwmon_dev); -+ sysfs_remove_group(&client->dev.kobj, &data->attrs); -+ kfree(data); -+ return 0; -+} -+ -+static int __init gsp_init(void) -+{ -+ return i2c_add_driver(&gsp_driver); -+} -+ -+static void __exit gsp_exit(void) -+{ -+ i2c_del_driver(&gsp_driver); -+} -+ -+module_init(gsp_init); -+module_exit(gsp_exit); -+ -+MODULE_AUTHOR("Chris Lang "); -+MODULE_DESCRIPTION("GSC HWMON driver"); -+MODULE_LICENSE("GPL"); -+MODULE_VERSION(DRV_VERSION); -+