Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,238 changes: 1,238 additions & 0 deletions arch/powerpc/boot/dts/powerpc-quanta-ly6-p2020-r0.dts

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions arch/powerpc/configs/85xx/onl_mpc85xx_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,7 @@ CONFIG_I2C_MUX=y
# CONFIG_I2C_MUX_PCA9541 is not set
CONFIG_I2C_MUX_PCA954x=y
CONFIG_I2C_MUX_QUANTA_LY2=y
CONFIG_I2C_MUX_QUANTA_LY6=y
CONFIG_I2C_MUX_QUANTA_LY5=y
CONFIG_I2C_HELPER_AUTO=y

Expand Down Expand Up @@ -1459,6 +1460,7 @@ CONFIG_SENSORS_EMC2305=y
# CONFIG_SENSORS_W83L785TS is not set
# CONFIG_SENSORS_W83L786NG is not set
CONFIG_SENSORS_QUANTA_LY_HWMON=y
CONFIG_SENSORS_QUANTA_LY6_HWMON=y
# CONFIG_THERMAL is not set
CONFIG_WATCHDOG=y
CONFIG_WATCHDOG_CORE=y
Expand Down
1 change: 0 additions & 1 deletion arch/powerpc/platforms/85xx/mpc85xx_rdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
#define DBG(fmt, args...)
#endif


void __init mpc85xx_rdb_pic_init(void)
{
struct mpic *mpic;
Expand Down
7 changes: 7 additions & 0 deletions drivers/hwmon/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1489,6 +1489,13 @@ config SENSORS_QUANTA_LY_HWMON
If you say yes here you get support for the Quanta LYx hardware
monitor.

config SENSORS_QUANTA_LY6_HWMON
tristate "Quanta LY6 hardware monitor"
depends on I2C
help
If you say yes here you get support for the Quanta LY6 hardware
monitor.

if ACPI

comment "ACPI drivers"
Expand Down
1 change: 1 addition & 0 deletions drivers/hwmon/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ obj-$(CONFIG_SENSORS_W83L786NG) += w83l786ng.o
obj-$(CONFIG_SENSORS_WM831X) += wm831x-hwmon.o
obj-$(CONFIG_SENSORS_WM8350) += wm8350-hwmon.o
obj-$(CONFIG_SENSORS_QUANTA_LY_HWMON) += quanta-ly-hwmon.o
obj-$(CONFIG_SENSORS_QUANTA_LY6_HWMON) += quanta-ly6-hwmon.o

obj-$(CONFIG_PMBUS) += pmbus/

Expand Down
217 changes: 217 additions & 0 deletions drivers/hwmon/quanta-ly6-hwmon.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
/*
* <bsn.cl fy=2013 v=gpl>
*
* Copyright 2013, 2014 BigSwitch Networks, Inc.
*
* This program is free software; you can redistribute it
* and/or modify it under the terms ofthe GNU General Public License as
* published by the Free Software Foundation; either version 2 of the License,
* or (at your option) any later version.
*
*
* </bsn.cl>
*
* A hwmon driver for the Quanta LY6
*/

#include <linux/module.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h>
#include <linux/err.h>
#include <linux/mutex.h>
#include <linux/delay.h>
#include <linux/log2.h>
#include <linux/kthread.h>
#include <linux/slab.h>

static const unsigned short normal_i2c[] = { 0x4E, I2C_CLIENT_END };

#define QUANTA_LY6_HWMON_REG_TEMP_INPUT_BASE 0x20
#define QUANTA_LY6_HWMON_REG_FAN_MODE 0x33
#define QUANTA_LY6_HWMON_REG_FAN_DIR 0x56
#define QUANTA_LY6_HWMON_REG_FAN_PWM_BASE 0x3C
#define QUANTA_LY6_HWMON_REG_FAN_INPUT_BASE 0x40

#define QUANTA_LY6_HWMON_FAN_MANUAL_MODE 1
#define QUANTA_LY6_HWMON_FAN_SMART_MODE 3

#define QUANTA_LY6_HWMON_NUM_FANS 6

struct quanta_ly6_hwmon_data {
struct device *hwmon_dev;
struct attribute_group attrs;
struct mutex lock;
};

static int quanta_ly6_hwmon_probe(struct i2c_client *client,
const struct i2c_device_id *id);
static int quanta_ly6_hwmon_remove(struct i2c_client *client);

static const struct i2c_device_id quanta_ly6_hwmon_id[] = {
{ "quanta_ly6_hwmon", 0xf600 },
{ }
};
MODULE_DEVICE_TABLE(i2c, quanta_ly6_hwmon_id);

static struct i2c_driver quanta_ly6_hwmon_driver = {
.class = I2C_CLASS_HWMON,
.driver = {
.name = "quanta_ly6_hwmon",
},
.probe = quanta_ly6_hwmon_probe,
.remove = quanta_ly6_hwmon_remove,
.id_table = quanta_ly6_hwmon_id,
.address_list = normal_i2c,
};

static ssize_t show_temp(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);
struct quanta_ly6_hwmon_data *data = i2c_get_clientdata(client);
int temp;

mutex_lock(&data->lock);
temp = i2c_smbus_read_byte_data(client,
QUANTA_LY6_HWMON_REG_TEMP_INPUT_BASE
+ attr->index);
mutex_unlock(&data->lock);
return sprintf(buf, "%d\n", 1000 * temp);
}

static ssize_t show_fan(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);
struct quanta_ly6_hwmon_data *data = i2c_get_clientdata(client);
int fan;

mutex_lock(&data->lock);
fan = i2c_smbus_read_word_swapped(client,
QUANTA_LY6_HWMON_REG_FAN_INPUT_BASE
+ 2 * attr->index);
mutex_unlock(&data->lock);
return sprintf(buf, "%d\n", fan);
}

static ssize_t show_pwm(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);
struct quanta_ly6_hwmon_data *data = i2c_get_clientdata(client);
int pwm;

mutex_lock(&data->lock);
pwm = i2c_smbus_read_word_swapped(client,
QUANTA_LY6_HWMON_REG_FAN_PWM_BASE
+ 2 * attr->index);
mutex_unlock(&data->lock);
return sprintf(buf, "%d\n", pwm * 255 / 10000);
}

static ssize_t set_pwm(struct device *dev, struct device_attribute *devattr,
const char *buf, size_t count)
{
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct i2c_client *client = to_i2c_client(dev);
struct quanta_ly6_hwmon_data *data = i2c_get_clientdata(client);
long val;
int ret;

ret = kstrtol(buf, 10, &val);
if (ret)
return ret;
mutex_lock(&data->lock);
i2c_smbus_write_word_swapped(client,
QUANTA_LY6_HWMON_REG_FAN_PWM_BASE
+ 2 * attr->index, val * 10000 / 255);
mutex_unlock(&data->lock);
return count;
}

static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0);
static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1);
static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2);
static SENSOR_DEVICE_ATTR(temp5_input, S_IRUGO, show_temp, NULL, 4);
static SENSOR_DEVICE_ATTR(temp6_input, S_IRUGO, show_temp, NULL, 5);
static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0);
static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1);
static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2);
static SENSOR_DEVICE_ATTR(fan5_input, S_IRUGO, show_fan, NULL, 4);
static SENSOR_DEVICE_ATTR(fan6_input, S_IRUGO, show_fan, NULL, 5);
static SENSOR_DEVICE_ATTR(fan7_input, S_IRUGO, show_fan, NULL, 6);
static SENSOR_DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 0);

static struct attribute *quanta_ly6_hwmon_attr[] = {
&sensor_dev_attr_temp1_input.dev_attr.attr,
&sensor_dev_attr_temp2_input.dev_attr.attr,
&sensor_dev_attr_temp3_input.dev_attr.attr,
&sensor_dev_attr_temp5_input.dev_attr.attr,
&sensor_dev_attr_temp6_input.dev_attr.attr,
&sensor_dev_attr_fan1_input.dev_attr.attr,
&sensor_dev_attr_fan2_input.dev_attr.attr,
&sensor_dev_attr_fan3_input.dev_attr.attr,
&sensor_dev_attr_fan5_input.dev_attr.attr,
&sensor_dev_attr_fan6_input.dev_attr.attr,
&sensor_dev_attr_fan7_input.dev_attr.attr,
&sensor_dev_attr_pwm1.dev_attr.attr,
NULL
};

static int quanta_ly6_hwmon_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct quanta_ly6_hwmon_data *data;
int err;

data = devm_kzalloc(&client->dev, sizeof(struct quanta_ly6_hwmon_data),
GFP_KERNEL);
if (!data)
return -ENOMEM;

i2c_set_clientdata(client, data);
mutex_init(&data->lock);

dev_info(&client->dev, "%s chip found\n", client->name);

data->attrs.attrs = quanta_ly6_hwmon_attr;
err = sysfs_create_group(&client->dev.kobj, &data->attrs);
if (err)
return err;

data->hwmon_dev = hwmon_device_register(&client->dev);
if (IS_ERR(data->hwmon_dev)) {
err = PTR_ERR(data->hwmon_dev);
goto exit_remove;
}

i2c_smbus_write_byte_data(client,
QUANTA_LY6_HWMON_REG_FAN_MODE,
QUANTA_LY6_HWMON_FAN_SMART_MODE);

return 0;

exit_remove:
sysfs_remove_group(&client->dev.kobj, &data->attrs);
return err;
}

static int quanta_ly6_hwmon_remove(struct i2c_client *client)
{
struct quanta_ly6_hwmon_data *data = i2c_get_clientdata(client);

hwmon_device_unregister(data->hwmon_dev);
sysfs_remove_group(&client->dev.kobj, &data->attrs);
return 0;
}

module_i2c_driver(quanta_ly6_hwmon_driver);

MODULE_AUTHOR("QCT Technical <support@quantaqct.com>");
MODULE_DESCRIPTION("Quanta LY6 hardware monitor driver");
MODULE_LICENSE("LGPL");
6 changes: 6 additions & 0 deletions drivers/i2c/muxes/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ config I2C_MUX_QUANTA_LY2
If you say yes here you get support for the Quanta LY2 I2C/GPIO
multiplexer.

config I2C_MUX_QUANTA_LY6
tristate "Quanta LY6 I2C multiplexer"
help
If you say yes here you get support for the Quanta LY6 I2C/GPIO
multiplexer.

config I2C_MUX_QUANTA_LY5
tristate "Quanta LY5 I2C multiplexer"
help
Expand Down
1 change: 1 addition & 0 deletions drivers/i2c/muxes/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ obj-$(CONFIG_I2C_MUX_PCA9541) += i2c-mux-pca9541.o
obj-$(CONFIG_I2C_MUX_PCA954x) += i2c-mux-pca954x.o
obj-$(CONFIG_I2C_MUX_PINCTRL) += i2c-mux-pinctrl.o
obj-$(CONFIG_I2C_MUX_QUANTA_LY2) += quanta-ly2-i2c-mux.o
obj-$(CONFIG_I2C_MUX_QUANTA_LY6) += quanta-ly6-i2c-mux.o
obj-$(CONFIG_I2C_MUX_QUANTA_LY5) += quanta-ly5-i2c-mux.o

ccflags-$(CONFIG_I2C_DEBUG_BUS) := -DDEBUG
Loading