-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kestrel/leds/trigger: implement led trigger driver for group pwm #23
base: cp-release/lf-5.15.y
Are you sure you want to change the base?
Conversation
I would eventually generate a patch out of this commit and put inside
Currently, I don't want to touch |
f0f81fb
to
5a9d964
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this patch is extending the capability of pca9633. I already see existing driver has capability to do so ("nxp,hw-blink"). Not sure if something is missing there or not.
Moreover, this is not trigger per say, it is just extension of hardware capability into user space. There are other example driver which has capability to do so and I am sure you must have already seen Documentation/leds.
For macaw/kestrel, kernel changes are done through patch.
I'm all ears if you agree that we should implement group pwm in This patch is a first step towards utilizing full capabilities of pca9633.
Yes, I would create a patch and add into
This requires some changes in kcb_ocpp BR2 config for PATCH variable and this is for other day. |
I did not go through leds-pca963x.c completely but see some variable related to PCA963X_LED_GRP_PWM/ u8 grppwm. May be @chardin-cpi or @aswathgajendran-cpi can comment more on it but I am hesitant to separate out from original NXP driver. |
There is a reason why I went for a separate trigger implementation than implementing group pwm in e.g.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amiteshsingh-cpi - work with @carlnorum-cpi on this - he will look into approving it.
I would just make sure this Kernel Normal Form to follow linux code style and maybe just see if it gets simplified
ldev = dev_get_drvdata(dev); | ||
grppwm_data = led_get_trigger_data(ldev); | ||
|
||
return snprintf(buf, 2, "%d", grppwm_data->ldrstate); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Buf is a user PAGE_SIZE so no need to truncate state if this is 1000 or some other weird value.
return snprintf(buf, 2, "%d", grppwm_data->ldrstate); | |
return sprintf(buf, "%d", grppwm_data->ldrstate); |
ldev = dev_get_drvdata(dev); | ||
grppwm_data = led_get_trigger_data(ldev); | ||
|
||
return snprintf(buf, 2, "%d", grppwm_data->ldrstateall); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
return snprintf(buf, 2, "%d", grppwm_data->ldrstateall); | |
return sprintf(buf, "%d", grppwm_data->ldrstateall); |
#define BIT_LDR3 6 | ||
#define BIT_LDR2 4 | ||
#define BIT_LDR1 2 | ||
#define BIT_LDR0 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are shifts - so, maybe reference to that
#define BIT_LDR3 6 | |
#define BIT_LDR2 4 | |
#define BIT_LDR1 2 | |
#define BIT_LDR0 0 | |
#define BITSHIFT_LDR3 6 | |
#define BITSHIFT_LDR2 4 | |
#define BITSHIFT_LDR1 2 | |
#define BITSHIFT_LDR0 0 |
/** | ||
* Group duty cycle control | ||
*/ | ||
#define REG_GRPPWM 0x06 | ||
|
||
/** | ||
* Group frequency | ||
*/ | ||
#define REG_GRPFREQ 0x07 | ||
|
||
/** | ||
* LED output state | ||
*/ | ||
#define REG_LEDOUT 0x08 | ||
|
||
/** | ||
* Mode register 2 | ||
*/ | ||
#define REG_MODE2 0x01 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** | |
* Group duty cycle control | |
*/ | |
#define REG_GRPPWM 0x06 | |
/** | |
* Group frequency | |
*/ | |
#define REG_GRPFREQ 0x07 | |
/** | |
* LED output state | |
*/ | |
#define REG_LEDOUT 0x08 | |
/** | |
* Mode register 2 | |
*/ | |
#define REG_MODE2 0x01 | |
#define REG_GRPPWM 0x06 /* group duty cycle */ | |
#define REG_GRPFREQ 0x07 /* group frequency */ | |
#define REG_LEDOUT 0x08 /* output state */ | |
#define REG_MODE2 0x01 /* mode register */ |
ldev = dev_get_drvdata(dev); | ||
grppwm_data = led_get_trigger_data(ldev); | ||
|
||
return snprintf(buf, 4, "%d", grppwm_data->grppwm); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return snprintf(buf, 4, "%d", grppwm_data->grppwm); | |
return sprintf(buf, "%d", grppwm_data->grppwm); |
return 0; | ||
} | ||
if (kstrtol(buf, 10, &val)) | ||
return -ENOMEM; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return -ENOMEM; | |
return -EINVAL; |
|
||
if (!grppwm_data->i2c_client) { | ||
pr_err("i2c client is not present"); | ||
return 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return 0; | |
return -ENODEV; |
ldev = dev_get_drvdata(dev); | ||
grppwm_data = led_get_trigger_data(ldev); | ||
|
||
return snprintf(buf, 2, "%d", grppwm_data->grpctrlmode); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return snprintf(buf, 2, "%d", grppwm_data->grpctrlmode); | |
return sprintf(buf, "%d", grppwm_data->grpctrlmode); |
ldev = dev_get_drvdata(dev); | ||
grppwm_data = led_get_trigger_data(ldev); | ||
|
||
return snprintf(buf, 4, "%d", grppwm_data->onoffratio_perc); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return snprintf(buf, 4, "%d", grppwm_data->onoffratio_perc); | |
return sprintf(buf, "%d", grppwm_data->onoffratio_perc); |
262e274
to
4a30279
Compare
Thanks @chardin-cpi for the review. I tested this driver code during weekend and encountered following errors.
This is due to restriction, rightly so, set by kernel driver framework for i2c_new_client_device https://elixir.bootlin.com/linux/latest/source/drivers/i2c/i2c-core-base.c#L913 I'm going to add an export function in leds_pca963x.c which returns i2c_client pointer. |
4a30279
to
2f583a1
Compare
I shall take care of formatting and other review comments after I'm done with testing. |
36234f4
to
a1733a7
Compare
pca9633 i2c leds driver supports group pwm which currently not utilized by leds-pca963x driver. This patch exposes various registers values via sysfs to user and can be used to achieve group blinking and dimming. Signed-off-by: Amitesh Singh <[email protected]>
a1733a7
to
ac955b2
Compare
pca9633 i2c leds driver supports group pwm which currently not utilized
by leds-pca963x driver.
This patch exposes various registers values via sysfs to user and can be
used to achieve group blinking and dimming.
Signed-off-by: Amitesh Singh [email protected]