Skip to content
Merged
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
10 changes: 5 additions & 5 deletions ixr7220h6-128/modules/Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
obj-m += i2c-ocores.o
obj-m += h6_i2c_oc.o
obj-m += sys_mux.o
obj-m += sys_cpld.o
obj-m += port_cpld0.o
obj-m += port_cpld1.o
obj-m += port_cpld2.o
obj-m += cb_pld.o
obj-m += mb_pld.o
obj-m += port_pld0.o
obj-m += port_pld1.o
obj-m += port_pld2.o
obj-m += eeprom_fru.o
obj-m += h6_fan_cpld.o
obj-m += sys_fpga.o
obj-m += embd_ctrl.o
obj-m += pmbus_psu.o
83 changes: 49 additions & 34 deletions ixr7220h6-128/modules/sys_fpga.c → ixr7220h6-128/modules/cb_pld.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// * CPLD driver for Nokia-7220-IXR-H6-128 Router
// * PLD driver for Nokia-7220-IXR-H6-128 Router
// *
// * Copyright (C) 2026 Nokia Corporation.
// *
Expand Down Expand Up @@ -26,14 +26,15 @@
#include <linux/mutex.h>
#include <linux/delay.h>

#define DRIVER_NAME "sys_fpga"
#define DRIVER_NAME "cb_pld"

// REGISTERS ADDRESS MAP
#define HW_BOARD_VER_REG 0x00
#define VER_MAJOR_REG 0x01
#define VER_MINOR_REG 0x02
#define PSU_PRESENT_REG 0x07
#define SSD_PRESENT_REG 0x08
#define MUX_SEL_REG 0x0F
#define PSU_POWERGOOD_REG 0x51

static const unsigned short cpld_address_list[] = {0x60, I2C_CLIENT_END};
Expand All @@ -51,7 +52,7 @@ static int cpld_i2c_read(struct cpld_data *data, u8 reg)

val = i2c_smbus_read_byte_data(client, reg);
if (val < 0) {
dev_warn(&client->dev, "SYS_FPGA READ ERROR: reg(0x%02x) err %d\n", reg, val);
dev_warn(&client->dev, "CB_PLD READ ERROR: reg(0x%02x) err %d\n", reg, val);
}

return val;
Expand All @@ -65,7 +66,7 @@ static void cpld_i2c_write(struct cpld_data *data, u8 reg, u8 value)
mutex_lock(&data->update_lock);
res = i2c_smbus_write_byte_data(client, reg, value);
if (res < 0) {
dev_warn(&client->dev, "SYS_FPGA WRITE ERROR: reg(0x%02x) err %d\n", reg, res);
dev_warn(&client->dev, "CB_PLD WRITE ERROR: reg(0x%02x) err %d\n", reg, res);
}
mutex_unlock(&data->update_lock);
}
Expand Down Expand Up @@ -120,21 +121,32 @@ static ssize_t show_ssd_present(struct device *dev, struct device_attribute *dev
return sprintf(buf, "%d\n", (val>>sda->index) & 0x1 ? 1:0);
}

static ssize_t show_mux_sel(struct device *dev, struct device_attribute *devattr, char *buf)
{
struct cpld_data *data = dev_get_drvdata(dev);
struct sensor_device_attribute *sda = to_sensor_dev_attr(devattr);
u8 val = 0;

val = cpld_i2c_read(data, MUX_SEL_REG);
return sprintf(buf, "%d\n", (val>>sda->index) & 0x1 ? 1:0);
}

// sysfs attributes
static SENSOR_DEVICE_ATTR(hw_board_version, S_IRUGO, show_hw_board_ver, NULL, 0);
static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_ver, NULL, 0);
static SENSOR_DEVICE_ATTR(psu1_ok, S_IRUGO, show_psu_ok, NULL, 0);
static SENSOR_DEVICE_ATTR(psu2_ok, S_IRUGO, show_psu_ok, NULL, 1);
static SENSOR_DEVICE_ATTR(psu3_ok, S_IRUGO, show_psu_ok, NULL, 2);
static SENSOR_DEVICE_ATTR(psu4_ok, S_IRUGO, show_psu_ok, NULL, 3);
static SENSOR_DEVICE_ATTR(psu1_ok, S_IRUGO, show_psu_ok, NULL, 4);
static SENSOR_DEVICE_ATTR(psu2_ok, S_IRUGO, show_psu_ok, NULL, 5);
static SENSOR_DEVICE_ATTR(psu3_ok, S_IRUGO, show_psu_ok, NULL, 6);
static SENSOR_DEVICE_ATTR(psu4_ok, S_IRUGO, show_psu_ok, NULL, 7);
static SENSOR_DEVICE_ATTR(psu1_pres, S_IRUGO, show_psu_present, NULL, 3);
static SENSOR_DEVICE_ATTR(psu2_pres, S_IRUGO, show_psu_present, NULL, 2);
static SENSOR_DEVICE_ATTR(psu3_pres, S_IRUGO, show_psu_present, NULL, 1);
static SENSOR_DEVICE_ATTR(psu4_pres, S_IRUGO, show_psu_present, NULL, 0);
static SENSOR_DEVICE_ATTR(ssd1_pres, S_IRUGO, show_ssd_present, NULL, 1);
static SENSOR_DEVICE_ATTR(ssd2_pres, S_IRUGO, show_ssd_present, NULL, 0);
static SENSOR_DEVICE_ATTR(mux_sel, S_IRUGO, show_mux_sel, NULL, 0);

static struct attribute *sys_fpga_attributes[] = {
static struct attribute *cb_pld_attributes[] = {
&sensor_dev_attr_hw_board_version.dev_attr.attr,
&sensor_dev_attr_version.dev_attr.attr,
&sensor_dev_attr_psu1_ok.dev_attr.attr,
Expand All @@ -147,14 +159,15 @@ static struct attribute *sys_fpga_attributes[] = {
&sensor_dev_attr_psu4_pres.dev_attr.attr,
&sensor_dev_attr_ssd1_pres.dev_attr.attr,
&sensor_dev_attr_ssd2_pres.dev_attr.attr,
&sensor_dev_attr_mux_sel.dev_attr.attr,
NULL
};

static const struct attribute_group sys_fpga_group = {
.attrs = sys_fpga_attributes,
static const struct attribute_group cb_pld_group = {
.attrs = cb_pld_attributes,
};

static int sys_fpga_probe(struct i2c_client *client)
static int cb_pld_probe(struct i2c_client *client)
{
int status;
struct cpld_data *data = NULL;
Expand All @@ -165,7 +178,7 @@ static int sys_fpga_probe(struct i2c_client *client)
goto exit;
}

dev_info(&client->dev, "Nokia SYS_FPGA chip found.\n");
dev_info(&client->dev, "Nokia CB_PLD chip found.\n");
data = kzalloc(sizeof(struct cpld_data), GFP_KERNEL);

if (!data) {
Expand All @@ -178,64 +191,66 @@ static int sys_fpga_probe(struct i2c_client *client)
i2c_set_clientdata(client, data);
mutex_init(&data->update_lock);

status = sysfs_create_group(&client->dev.kobj, &sys_fpga_group);
status = sysfs_create_group(&client->dev.kobj, &cb_pld_group);
if (status) {
dev_err(&client->dev, "CPLD INIT ERROR: Cannot create sysfs\n");
goto exit;
goto exit_sysfs_create_group;
}

return 0;

exit_sysfs_create_group:
kfree(data);
exit:
return status;
}

static void sys_fpga_remove(struct i2c_client *client)
static void cb_pld_remove(struct i2c_client *client)
{
struct cpld_data *data = i2c_get_clientdata(client);
sysfs_remove_group(&client->dev.kobj, &sys_fpga_group);
sysfs_remove_group(&client->dev.kobj, &cb_pld_group);
kfree(data);
}

static const struct of_device_id sys_fpga_of_ids[] = {
static const struct of_device_id cb_pld_of_ids[] = {
{
.compatible = "sys_fpga",
.compatible = "cb_pld",
.data = (void *) 0,
},
{ },
};
MODULE_DEVICE_TABLE(of, sys_fpga_of_ids);
MODULE_DEVICE_TABLE(of, cb_pld_of_ids);

static const struct i2c_device_id sys_fpga_ids[] = {
static const struct i2c_device_id cb_pld_ids[] = {
{ DRIVER_NAME, 0 },
{ }
};
MODULE_DEVICE_TABLE(i2c, sys_fpga_ids);
MODULE_DEVICE_TABLE(i2c, cb_pld_ids);

static struct i2c_driver sys_fpga_driver = {
static struct i2c_driver cb_pld_driver = {
.driver = {
.name = DRIVER_NAME,
.of_match_table = of_match_ptr(sys_fpga_of_ids),
.of_match_table = of_match_ptr(cb_pld_of_ids),
},
.probe = sys_fpga_probe,
.remove = sys_fpga_remove,
.id_table = sys_fpga_ids,
.probe = cb_pld_probe,
.remove = cb_pld_remove,
.id_table = cb_pld_ids,
.address_list = cpld_address_list,
};

static int __init sys_fpga_init(void)
static int __init cb_pld_init(void)
{
return i2c_add_driver(&sys_fpga_driver);
return i2c_add_driver(&cb_pld_driver);
}

static void __exit sys_fpga_exit(void)
static void __exit cb_pld_exit(void)
{
i2c_del_driver(&sys_fpga_driver);
i2c_del_driver(&cb_pld_driver);
}

MODULE_AUTHOR("Nokia");
MODULE_DESCRIPTION("NOKIA H6-128 SYS_FPGA driver");
MODULE_DESCRIPTION("NOKIA H6-128 CB_PLD driver");
MODULE_LICENSE("GPL");

module_init(sys_fpga_init);
module_exit(sys_fpga_exit);
module_init(cb_pld_init);
module_exit(cb_pld_exit);
37 changes: 35 additions & 2 deletions ixr7220h6-128/modules/embd_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
#define CPU_TEMP_REG 0x10
#define MEM0_TEMP_REG 0x12
#define MEM1_TEMP_REG 0x13
#define DATE_YEAR_REG 0xFB
#define DATE_MONTH_REG 0xFC
#define DATE_DAY_REG 0xFD
#define VER_MAJOR_REG 0xFE
#define VER_MINOR_REG 0xFF

static const unsigned short ec_address_list[] = {0x21, I2C_CLIENT_END};

Expand Down Expand Up @@ -92,15 +97,41 @@ static ssize_t show_mem1_temperature(struct device *dev, struct device_attribute
return sprintf(buf, "%d\n", (s8)val * 1000);
}

static ssize_t show_ec_date(struct device *dev, struct device_attribute *devattr, char *buf)
{
struct ec_data *data = dev_get_drvdata(dev);
u8 year = 0;
u8 month = 0;
u8 day = 0;
year = ec_i2c_read(data, DATE_YEAR_REG);
month = ec_i2c_read(data, DATE_MONTH_REG);
day = ec_i2c_read(data, DATE_DAY_REG);
return sprintf(buf, "%d/%d/%d\n", day, month, year);
}

static ssize_t show_ec_ver(struct device *dev, struct device_attribute *devattr, char *buf)
{
struct ec_data *data = dev_get_drvdata(dev);
u8 ver_major = 0;
u8 ver_minor = 0;
ver_major = ec_i2c_read(data, DATE_YEAR_REG);
ver_major = ec_i2c_read(data, DATE_MONTH_REG);
return sprintf(buf, "%02x.%02x\n", ver_major, ver_minor);
}

// sysfs attributes
static SENSOR_DEVICE_ATTR(cpu_temperature, S_IRUGO, show_cpu_temperature, NULL, 0);
static SENSOR_DEVICE_ATTR(mem0_temperature, S_IRUGO, show_mem0_temperature, NULL, 0);
static SENSOR_DEVICE_ATTR(mem1_temperature, S_IRUGO, show_mem1_temperature, NULL, 0);
static SENSOR_DEVICE_ATTR(ec_date, S_IRUGO, show_ec_date, NULL, 0);
static SENSOR_DEVICE_ATTR(ec_ver, S_IRUGO, show_ec_ver, NULL, 0);

static struct attribute *embd_ctrl_attributes[] = {
&sensor_dev_attr_cpu_temperature.dev_attr.attr,
&sensor_dev_attr_mem0_temperature.dev_attr.attr,
&sensor_dev_attr_mem1_temperature.dev_attr.attr,
&sensor_dev_attr_ec_date.dev_attr.attr,
&sensor_dev_attr_ec_ver.dev_attr.attr,
NULL
};

Expand Down Expand Up @@ -135,11 +166,13 @@ static int embd_ctrl_probe(struct i2c_client *client)
status = sysfs_create_group(&client->dev.kobj, &embd_ctrl_group);
if (status) {
dev_warn(&client->dev, "EC INIT WARN: Cannot create sysfs\n");
goto exit;
goto exit_sysfs_create_group;
}

return 0;

exit_sysfs_create_group:
kfree(data);
exit:
return status;
}
Expand All @@ -153,7 +186,7 @@ static void embd_ctrl_remove(struct i2c_client *client)

static const struct of_device_id embd_ctrl_of_ids[] = {
{
.compatible = "Nokia,embd_ctrl",
.compatible = "embd_ctrl",
.data = (void *) 0,
},
{ },
Expand Down
Loading
Loading