Add Silicom Platform Driver
Subsystems (2)
PATCH v5 1/1 Add Silicom Platform Driver
The Silicom platform (silicom-platform) Linux driver for Swisscom Business Box (Swisscom BB) as well as Cordoba family products is a software solution designed to facilitate the efficient management and control of devices through the integration of various Linux frameworks. This platform driver provides seamless support for device management via the Linux LED framework, GPIO framework, Hardware Monitoring (HWMON), and device attributes. The Silicom platform driver's compatibility with these Linux frameworks allows applications to access and control Cordoba family devices using existing software that is compatible with these frameworks. This compatibility simplifies the development process, reduces dependencies on proprietary solutions, and promotes interoperability with other Linux-based systems and software.
---
Changes from v1 to v2:
===========================
Suggested by Hans de Goede <[email protected]>
.Use git send-email to submit patch.
.patch contents should be in message body.
.Kconfig bit for the driver should be in drivers/platform/x86/Kconfig.
changes from patch v2 to v3
===========================
chnages suggested by Guenter Roeck <[email protected]> .Removed unnecessary include file linux/thermal.h. .Removed EXPORT_SYMBOL for mutex lock/unlock function.
Changes suggested by Ilpo Järvinen <[email protected]>
.Remove extra new line in code on multiple position.
.Use table instead of space in code.
.Uss Linux defined bit operation MACRO define.
.Removed local variable in rpm_get().
.Corrected typo in comments.
.Corrected incorrect indentation.
.Removed unnecessary comments in silicom_mc_leds_register().
.Rewrite efuse_status_show() to used defined variable and removed uncessary local variables. .Rewrite uc_version_show() to used defined variable and removed uncessary local variables. .Removed unused MACRO define: #define CHANNEL_TO_BIT(chan) ((chan) & 0x07). .Rewrite powercycle_uc() to used defined variable and removed uncessary local variables. .use GENMASK() and use FIELD_GET() instead of bit shift.
.Added define for constant 0x28 used in efuse_status_show().
.Added define for constant 0x0 used in uc_version_show().
.Added define for constant 0x0 used in powercycle_uc().
.Rearrange functions to avoid uncessary pre-define.
.Rewrite rpm_get() to used defined variable and removed uncessary local variables. .Rewrite temp_get() to used defined variable and removed uncessary local variables. .Use FIELD_GET instead of bit shift in temp_get().
.Used #define for constant variable 0/1.
Changes suggested by Christophe JAILLET <[email protected]>:
.use "if (!led->subled_info)" instead of "if (IS_ERR_OR_NULL(led->subled_info))" in silicom_mc_leds_register
changes from patch v3 to v4
===========================
changes suggested by Guenter Roeck <[email protected]>
Changes suggested by Ilpo Järvinen <[email protected]>:
.Rewrite silicom_mec_led/gpip_set/get() functions to use two newly created silicom_mec_port_get()/silicom_mec_port_set() which have common code. .Remove duplicate code in silicom_mec_port_get()
.Rewrite uc_version_show() to use Linux bit operation MACRO, and add logic to check un-supported register value.
.Added "#define MEC_EFUSE_LSB_ADDR 0x28" and "#define MEC_POWER_CYCLE_ADDR 0x24"
.Added "#define MEC_VERSION_MAJOR GENMASK(15, 14)" and "#define MEC_VERSION_MINOR GENMASK(13, 8)".
Changes suggested by Christophe JAILLET <[email protected]>:
.Used a local variable to store "sizeof(struct mc_subled)" in function silicom_mc_leds_register().
change from patch v4 to v5 (current patch)
===========================================
changes suggested by Guenter Roeck <[email protected]>:
.Corrected return value in temp_get() to return 1/1000th degree.
.Removed local variable struct silicom_fan_control_data *ctl in silicom_fan_control_read_fan(), remove storing rpm value to ctl variable. .Removed local variable struct silicom_fan_control_data *ctl in silicom_fan_control_read_temp(), remove storing rpm value to ctl variable. .Changed return string in silicom_fan_control_read_labels() to specific string for Silicom platform driver. .Removed silicom_fan_control_data structure.
.Removed static variable mec_io_base and mec_io_len, and added "#define MEC_IO_BASE 0x0800 and #define MEC_IO_LEN 0x8". .Removed ".write = NULL" in silicom_fan_control_hwmon_ops structure defination.
.Removed unnecessary function silicom_fan_control_write().
.Removed unnecessary check for silicom_led_info in function silicom_platform_probe.
.Removed unnecessary local variable "silicom_fan_control_data *ctl" in silicom_platform_probe().
.Clean out driver initialization error handling in silicom_platform_init();
.Add patch version and changelog for patch submission.
Changes suggested by Ilpo Järvinen <[email protected]>:
.Rename "#define MEC_DATA(offset) to "#define MEC_DATA_OFFSET(offset).
.Use constant defined in include/linux/units.h instead of a literal.
.return directly instead of go to err condition when platform_device_register_simple() failed. .Remove unnecessary check for silicom_led_info and silicom_gpiochip.
.Use a local variable to how multiple use of array size.
.Align the arguments to the same column in silicom_mec_led_mc_brightness_set. .Add patch version and changelog that shows version to version changes for patch submission.
Changes suggested by Christophe JAILLET <[email protected]>:
.Use "sizeof(*led)" instead of "sizeof(struct led_classdev_mc)"
.Use "if (!led)" instead of "if (IS_ERR_OR_NULL(led))"
.Removed unnecessary error message: "dev_err(dev, "Failed to alloc led_classdev_mc[%d]: %ld\n", i, PTR_ERR(led)).
drivers/platform/x86/Kconfig | 11 + drivers/platform/x86/Makefile | 1 + drivers/platform/x86/silicom-platform.c | 1053 +++++++++++++++++++++++ 3 files changed, 1065 insertions(+) create mode 100644 drivers/platform/x86/silicom-platform.c
drivers/platform/x86/Kconfig +11 -0
@@ -188,6 +188,17 @@ config ACER_WMI If you have an ACPI-WMI compatible Acer/ Wistron laptop, say Y or M here. +config SILICOM_PLATFORM + tristate "Silicom Edge Networking device support" + depends on DMI + select LEDS_CLASS_MULTICOLOR + select GPIOLIB + help + This option enables support for the LEDs/GPIO/etc downstream of the + embedded controller on Silicom "Cordoba" hardware and derivatives. + + If you have a Silicom network appliance, say Y or M here. + source "drivers/platform/x86/amd/Kconfig" config ADV_SWBUTTON
drivers/platform/x86/Makefile +1 -0
@@ -113,6 +113,7 @@ obj-$(CONFIG_SERIAL_MULTI_INSTANTIATE) += serial-multi-instantiate.o obj-$(CONFIG_MLX_PLATFORM) += mlx-platform.o obj-$(CONFIG_TOUCHSCREEN_DMI) += touchscreen_dmi.o obj-$(CONFIG_WIRELESS_HOTKEY) += wireless-hotkey.o +obj-$(CONFIG_SILICOM_PLATFORM) += silicom-platform.o obj-$(CONFIG_X86_ANDROID_TABLETS) += x86-android-tablets/ # Intel uncore drivers
drivers/platform/x86/silicom-platform.c new file +1053 -0
1,053 lines not on this page · raw message
Signature · 1 line
2.21.3
Guenter Roeck
maintainerQuoted 14 lines · Henry Shi
The Silicom platform (silicom-platform) Linux driver for Swisscom Business Box (Swisscom BB) as well as Cordoba family products is a software solution designed to facilitate the efficient management and control of devices through the integration of various Linux frameworks. This platform driver provides seamless support for device management via the Linux LED framework, GPIO framework, Hardware Monitoring (HWMON), and device attributes. The Silicom platform driver's compatibility with these Linux frameworks allows applications to access and control Cordoba family devices using existing software that is compatible with these frameworks. This compatibility simplifies the development process, reduces dependencies on proprietary solutions, and promotes interoperability with other Linux-based systems and software.
Quoted 1 line
Signed-off-by Henry Shi <[email protected]>
Again, my feedback is only for hwmon code.
[ ... ]
drivers/platform/x86/silicom-platform.c line 838
Quoted 5 lines
drivers/platform/x86/silicom-platform.c new file +5
-0+ +static int silicom_fan_control_read (struct device *dev, +enum hwmon_sensor_types type, +u32 attr,int channel, +long *val)
Excessively long continuation lines.
That seeme to be the case for almost all continuation lines, except where it is too short. I'd suggest to run the patch through checkpatch --strict and fix what it reports.
total: 0 errors, 9 warnings, 18 checks, 1077 lines checked
is really a bit much.
[ ... ]
drivers/platform/x86/silicom-platform.c line 916
Quoted 3 lines
drivers/platform/x86/silicom-platform.c new file +3
-0+ + hwmon_dev =devm_hwmon_device_register_with_info (&device->dev, name,NULL , + &silicom_chip_info,NULL );
Did you try to compile this with CONFIG_HWMON=n or with CONFIG_HWMON=m and SILICOM_PLATFORM=y ?
Guenter
Hi Guenter,
Appreciate your feedback. Please see my comments below.
Thanks
Henry
-----Original Message-----
From: Guenter Roeck <[email protected]> On Behalf Of Guenter Roeck
Sent: Monday, August 28, 2023 8:41 PM
To: Henry Shi <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Huibin Shi <[email protected]>; Wen Wang <[email protected]>
Subject: Re: [PATCH v5] Add Silicom Platform Driver
Caution: This is an external email. Please take care when clicking links or opening attachments.
Quoted 14 lines · Henry Shi
The Silicom platform (silicom-platform) Linux driver for Swisscom Business Box (Swisscom BB) as well as Cordoba family products is a software solution designed to facilitate the efficient management and control of devices through the integration of various Linux frameworks. This platform driver provides seamless support for device management via the Linux LED framework, GPIO framework, Hardware Monitoring (HWMON), and device attributes. The Silicom platform driver's compatibility with these Linux frameworks allows applications to access and control Cordoba family devices using existing software that is compatible with these frameworks. This compatibility simplifies the development process, reduces dependencies on proprietary solutions, and promotes interoperability with other Linux-based systems and software.
Quoted 1 line
Signed-off-by Henry Shi <[email protected]>
Again, my feedback is only for hwmon code.
[ ... ]
drivers/platform/x86/silicom-platform.c
Quoted 6 lines
drivers/platform/x86/silicom-platform.c new file +6
-0+ +static int silicom_fan_control_read (struct device *dev, +enum hwmon_sensor_types type, +u32 attr,int channel, + +long *val)
Excessively long continuation lines.
That seeme to be the case for almost all continuation lines, except where it is too short. I'd suggest to run the patch through checkpatch --strict and fix what it reports.
total: 0 errors, 9 warnings, 18 checks, 1077 lines checked
is really a bit much.
Henry: OK, I will fix those warnings.
[ ... ]
drivers/platform/x86/silicom-platform.c line 916
Quoted 3 lines
drivers/platform/x86/silicom-platform.c new file +3
-0+ + hwmon_dev =devm_hwmon_device_register_with_info (&device->dev, name,NULL , + &silicom_chip_info,NULL );
Did you try to compile this with CONFIG_HWMON=n or with CONFIG_HWMON=m and SILICOM_PLATFORM=y ?
Henry: Great question. I did not try that before. When I force "CONFIG_HWMON=m and SILICOM_PLATFORM=y" and compile kernel, the build failed with message "silicom-platform.c:(.init.text+0x8ff5b): undefined reference to `devm_hwmon_device_register_with_info'". I tried following change in drivers/platform/x86/Kconfig:
config SILICOM_PLATFORM
tristate "Silicom Edge Networking device support"
depends on DMI
select LEDS_CLASS_MULTICOLOR
select GPIOLIB
select HWMON ----> added
help
This option enables support for the LEDs/GPIO/etc downstream of the embedded controller on Silicom "Cordoba" hardware and derivatives.
If you have a Silicom network appliance, say Y or M here.
After this change, kernel build can be completed. And "CONFIG_HWMON" was changed to "y" in .config file. Not sure whether there are any other better ways to resolve CONFIG dependence in when adding a new kernel driver.
Guenter
Guenter Roeck
maintainerQuoted 62 lines · Huibin Shi
Hi Guenter,
Appreciate your feedback. Please see my comments below.
Thanks
Henry-----Original Message-----
From: Guenter Roeck <[email protected]> On Behalf Of Guenter Roeck
Sent: Monday, August 28, 2023 8:41 PM
To: Henry Shi <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Huibin Shi <[email protected]>; Wen Wang <[email protected]>
Subject: Re: [PATCH v5] Add Silicom Platform DriverCaution: This is an external email. Please take care when clicking links or opening attachments.
Quoted 14 lines · Henry Shi
The Silicom platform (silicom-platform) Linux driver for Swisscom Business Box (Swisscom BB) as well as Cordoba family products is a software solution designed to facilitate the efficient management and control of devices through the integration of various Linux frameworks. This platform driver provides seamless support for device management via the Linux LED framework, GPIO framework, Hardware Monitoring (HWMON), and device attributes. The Silicom platform driver's compatibility with these Linux frameworks allows applications to access and control Cordoba family devices using existing software that is compatible with these frameworks. This compatibility simplifies the development process, reduces dependencies on proprietary solutions, and promotes interoperability with other Linux-based systems and software.
Quoted 1 line
Signed-off-by Henry Shi <[email protected]>Again, my feedback is only for hwmon code.
[ ... ]
drivers/platform/x86/silicom-platform.c
Quoted 6 lines
drivers/platform/x86/silicom-platform.c new file +6
-0+ +static int silicom_fan_control_read (struct device *dev, +enum hwmon_sensor_types type, +u32 attr,int channel, + +long *val)Excessively long continuation lines.
That seeme to be the case for almost all continuation lines, except where it is too short. I'd suggest to run the patch through checkpatch --strict and fix what it reports.total: 0 errors, 9 warnings, 18 checks, 1077 lines checked
is really a bit much.
Henry: OK, I will fix those warnings.
[ ... ]
drivers/platform/x86/silicom-platform.c line 916
Quoted 3 lines
drivers/platform/x86/silicom-platform.c new file +3
-0+ + hwmon_dev =devm_hwmon_device_register_with_info (&device->dev, name,NULL , + &silicom_chip_info,NULL );Did you try to compile this with
CONFIG_HWMON=nor withCONFIG_HWMON=mand SILICOM_PLATFORM=y ?
Quoted 8 lines
Henry: Great question. I did not try that before. When I force "
CONFIG_HWMON=mand SILICOM_PLATFORM=y" and compile kernel, the build failed with message "silicom-platform.c:(.init.text+0x8ff5b): undefined reference to `devm_hwmon_device_register_with_info'". I tried following change indrivers/platform/x86/Kconfig:config
SILICOM_PLATFORM
tristate "Silicom Edge Networking device support" depends on DMI
selectLEDS_CLASS_MULTICOLOR
select GPIOLIB
select HWMON ----> added
No, that is wrong. It needs to be "depends on HWMON", or the hwmon code needs to be conditional and the dependency must be something like "depends on HWMON || HWMON=n".
Guenter