hwmon: npcm: add Arbel NPCM8XX support
Subsystems (2)
Tomer Maimon
maintainerv3 cover hwmon: npcm: add Arbel NPCM8XX support
This patch set adds Arbel NPCM8XX Pulse Width Modulation (PWM) and Fan tachometer (Fan) support to PWM FAN NPCM driver.
The NPCM8XX supports up to 16 Fan tachometer inputs and up to 12 PWM outputs.
The NPCM PWM FAN driver was tested on the NPCM845 evaluation board.
Addressed comments from:
- Guenter Roeck : https://www.spinics.net/lists/linux-hwmon/msg21801.html
Changes since version 2:
- dt-binding commit applied and remove from the patchset.
- Using _is_visible() function to support NPCM8XX.
Changes since version 1:
- Add Rob Ack to the dt-binding commit.
Tomer Maimon (1):
hwmon: npcm750-pwm-fan: Add NPCM8xx support
drivers/hwmon/npcm750-pwm-fan.c | 34 +++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-)
Signature · 1 line
2.33.0
Tomer Maimon
maintainerPATCH v3 1/1 hwmon: npcm750-pwm-fan: Add NPCM8xx support
Adding Pulse Width Modulation (PWM) and fan tacho NPCM8xx support to NPCM PWM and fan tacho driver.
NPCM8xx uses a different number of PWM devices.
As part of adding NPCM8XX support:
- Add NPCM8xx specific compatible string.
- Add data to handle architecture-specific PWM and fan tacho parameters.
--- drivers/hwmon/npcm750-pwm-fan.c | 34 +++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-)
drivers/hwmon/npcm750-pwm-fan.c +30 -4
@@ -46,9 +46,9 @@#define NPCM7XX_PWM_CTRL_CH3_EN_BIT BIT(16)/* Define the maximum PWM channel number */ -#define NPCM7XX_PWM_MAX_CHN_NUM 8 +#define NPCM7XX_PWM_MAX_CHN_NUM 12#define NPCM7XX_PWM_MAX_CHN_NUM_IN_A_MODULE 4 -#define NPCM7XX_PWM_MAX_MODULES 2 +#define NPCM7XX_PWM_MAX_MODULES 3/* Define the Counter Register, value = 100 for match 100% */ #define NPCM7XX_PWM_COUNTER_DEFAULT_NUM 255
@@ -171,6 +171,10 @@#define FAN_PREPARE_TO_GET_FIRST_CAPTURE 0x01#define FAN_ENOUGH_SAMPLE 0x02 +struct npcm_hwmon_info { +u32 pwm_max_channel; +}; +struct npcm7xx_fan_dev {u8 fan_st_flg;u8 fan_pls_per_rev;
@@ -204,6 +208,7 @@ struct npcm7xx_pwm_fan_data {struct timer_list fan_timer;struct npcm7xx_fan_dev fan_dev[NPCM7XX_FAN_MAX_CHN_NUM ];struct npcm7xx_cooling_device *cdev[NPCM7XX_PWM_MAX_CHN_NUM ]; +const struct npcm_hwmon_info *info;u8 fan_select; };
@@ -619,9 +624,13 @@ static umode_t npcm7xx_is_visible(const void *data,enum hwmon_sensor_types type, u32 attr, int channel) { + const struct npcm7xx_pwm_fan_data *hwmon_data = data; +switch (type) {case hwmon_pwm: - return npcm7xx_pwm_is_visible(data, attr, channel); +if (channel < hwmon_data->info->pwm_max_channel) +return npcm7xx_pwm_is_visible (data, attr, channel); +return 0 ;case hwmon_fan:return npcm7xx_fan_is_visible (data, attr, channel);default :
@@ -638,6 +647,10 @@ static const struct hwmon_channel_info * const npcm7xx_info[] = { HWMON_PWM_INPUT,HWMON_PWM_INPUT ,HWMON_PWM_INPUT , +HWMON_PWM_INPUT , +HWMON_PWM_INPUT , +HWMON_PWM_INPUT , +HWMON_PWM_INPUT , HWMON_PWM_INPUT), HWMON_CHANNEL_INFO(fan, HWMON_F_INPUT,
@@ -670,6 +683,14 @@ static const struct hwmon_chip_info npcm7xx_chip_info = { .info = npcm7xx_info, }; +static const struct npcm_hwmon_info npxm7xx_hwmon_info = { + .pwm_max_channel =8 , +}; + +static const struct npcm_hwmon_info npxm8xx_hwmon_info = { + .pwm_max_channel =12 , +}; +static u32 npcm7xx_pwm_init (struct npcm7xx_pwm_fan_data *data) {int m, ch;
@@ -923,6 +944,10 @@ static int npcm7xx_pwm_fan_probe(struct platform_device *pdev)if (!data)return -ENOMEM ; + data->info =device_get_match_data (dev); +if (!data->info) +return -EINVAL ; + res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"pwm" );if (!res) {dev_err (dev,"pwm resource not found\n" );
@@ -1015,7 +1040,8 @@ static int npcm7xx_pwm_fan_probe(struct platform_device *pdev) }static const struct of_device_id of_pwm_fan_match_table[] = { - { .compatible ="nuvoton,npcm750-pwm-fan" , }, + { .compatible ="nuvoton,npcm750-pwm-fan" , .data = &npxm7xx_hwmon_info}, + { .compatible ="nuvoton,npcm845-pwm-fan" , .data = &npxm8xx_hwmon_info}, {}, };MODULE_DEVICE_TABLE (of, of_pwm_fan_match_table);
Signature · 1 line
2.33.0
Guenter Roeck
maintainerRe: [PATCH v3 1/1] hwmon: npcm750-pwm-fan: Add NPCM8xx support
Quoted 7 lines · Tomer Maimon
Adding Pulse Width Modulation (PWM) and fan tacho NPCM8xx support to NPCM PWM and fan tacho driver.
NPCM8xx uses a different number of PWM devices.As part of adding NPCM8XX support:
- Add NPCM8xx specific compatible string.
- Add data to handle architecture-specific PWM and fan tacho parameters.
^^^^^^^^^^^^^
I don't see any fan related changes in the patch. What am I missing ?
Guenter
Guenter Roeck
maintainerRe: [PATCH v3 1/1] hwmon: npcm750-pwm-fan: Add NPCM8xx support
In reply to Tomer MaimonQuoted 49 lines · Tomer Maimon
Adding Pulse Width Modulation (PWM) and fan tacho NPCM8xx support to NPCM PWM and fan tacho driver.
NPCM8xx uses a different number of PWM devices.As part of adding NPCM8XX support:
- Add NPCM8xx specific compatible string.
- Add data to handle architecture-specific PWM and fan tacho parameters.Signed-off-by Tomer Maimon <[email protected]>--- drivers/hwmon/npcm750-pwm-fan.c | 34 +++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-)drivers/hwmon/npcm750-pwm-fan.c +7
-2@@ -46,9 +46,9 @@#define NPCM7XX_PWM_CTRL_CH3_EN_BIT BIT(16)/* Define the maximum PWM channel number */ -#define NPCM7XX_PWM_MAX_CHN_NUM 8 +#define NPCM7XX_PWM_MAX_CHN_NUM 12#define NPCM7XX_PWM_MAX_CHN_NUM_IN_A_MODULE 4 -#define NPCM7XX_PWM_MAX_MODULES 2 +#define NPCM7XX_PWM_MAX_MODULES 3/* Define the Counter Register, value = 100 for match 100% */ #define NPCM7XX_PWM_COUNTER_DEFAULT_NUM 255@@ -171,6 +171,10 @@#define FAN_PREPARE_TO_GET_FIRST_CAPTURE 0x01#define FAN_ENOUGH_SAMPLE 0x02 +struct npcm_hwmon_info { +u32 pwm_max_channel; +}; +struct npcm7xx_fan_dev {u8 fan_st_flg;u8 fan_pls_per_rev;@@ -204,6 +208,7 @@ struct npcm7xx_pwm_fan_data {struct timer_list fan_timer;struct npcm7xx_fan_dev fan_dev[NPCM7XX_FAN_MAX_CHN_NUM ];struct npcm7xx_cooling_device *cdev[NPCM7XX_PWM_MAX_CHN_NUM ]; +const struct npcm_hwmon_info *info;u8 fan_select; };
drivers/hwmon/npcm750-pwm-fan.c static umode_t npcm7xx_is_visible(const void *data, · line 632
Quoted 10 lines
drivers/hwmon/npcm750-pwm-fan.c +4
-1@@ -619,9 +624,13 @@ static umode_t npcm7xx_is_visible(const void *data,enum hwmon_sensor_types type, u32 attr, int channel) { + const struct npcm7xx_pwm_fan_data *hwmon_data = data; +switch (type) {case hwmon_pwm: - return npcm7xx_pwm_is_visible(data, attr, channel); +if (channel < hwmon_data->info->pwm_max_channel) +return npcm7xx_pwm_is_visible (data, attr, channel);
I would have expected this check to be handled in npcm7xx_pwm_is_visible().
Guenter
Tomer Maimon
maintainerRe: [PATCH v3 1/1] hwmon: npcm750-pwm-fan: Add NPCM8xx support
Hi Guenter,
Thanks for your comments
Quoted 50 lines · Guenter Roeck
Quoted 48 lines · Tomer Maimon
Adding Pulse Width Modulation (PWM) and fan tacho NPCM8xx support to NPCM PWM and fan tacho driver.
NPCM8xx uses a different number of PWM devices.As part of adding NPCM8XX support:
- Add NPCM8xx specific compatible string.
- Add data to handle architecture-specific PWM and fan tacho parameters.Signed-off-by Tomer Maimon <[email protected]>--- drivers/hwmon/npcm750-pwm-fan.c | 34 +++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-)drivers/hwmon/npcm750-pwm-fan.c +7
-2@@ -46,9 +46,9 @@#define NPCM7XX_PWM_CTRL_CH3_EN_BIT BIT(16)/* Define the maximum PWM channel number */ -#define NPCM7XX_PWM_MAX_CHN_NUM 8 +#define NPCM7XX_PWM_MAX_CHN_NUM 12#define NPCM7XX_PWM_MAX_CHN_NUM_IN_A_MODULE 4 -#define NPCM7XX_PWM_MAX_MODULES 2 +#define NPCM7XX_PWM_MAX_MODULES 3/* Define the Counter Register, value = 100 for match 100% */ #define NPCM7XX_PWM_COUNTER_DEFAULT_NUM 255@@ -171,6 +171,10 @@#define FAN_PREPARE_TO_GET_FIRST_CAPTURE 0x01#define FAN_ENOUGH_SAMPLE 0x02 +struct npcm_hwmon_info { +u32 pwm_max_channel; +}; +struct npcm7xx_fan_dev {u8 fan_st_flg;u8 fan_pls_per_rev;@@ -204,6 +208,7 @@ struct npcm7xx_pwm_fan_data {struct timer_list fan_timer;struct npcm7xx_fan_dev fan_dev[NPCM7XX_FAN_MAX_CHN_NUM ];struct npcm7xx_cooling_device *cdev[NPCM7XX_PWM_MAX_CHN_NUM ]; +const struct npcm_hwmon_info *info;u8 fan_select; };
Quoted 13 lines
drivers/hwmon/npcm750-pwm-fan.c static umode_t npcm7xx_is_visible(const void *data, · line 632
Quoted 11 lines
drivers/hwmon/npcm750-pwm-fan.c +4
-1@@ -619,9 +624,13 @@ static umode_t npcm7xx_is_visible(const void *data,enum hwmon_sensor_types type, u32 attr, int channel) { + const struct npcm7xx_pwm_fan_data *hwmon_data = data; +switch (type) {case hwmon_pwm: - return npcm7xx_pwm_is_visible(data, attr, channel); +if (channel < hwmon_data->info->pwm_max_channel) +return npcm7xx_pwm_is_visible (data, attr, channel);I would have expected this check to be handled in
npcm7xx_pwm_is_visible().
I will change the handle in npcm7xx_pwm_is_visible
Quoted 3 lines
Guenter
Thanks,
Tomer