15 #include <linux/kernel.h>
16 #include <linux/module.h>
18 #include <linux/slab.h>
30 static const u16 COMP_VSEL_TABLE[] = {
31 0, 2500, 2500, 2500, 2500, 2550, 2600, 2650,
32 2700, 2750, 2800, 2850, 2900, 2950, 3000, 3050,
33 3100, 3150, 3200, 3250, 3300, 3350, 3400, 3450,
49 .vsel_table = COMP_VSEL_TABLE,
55 .vsel_table = COMP_VSEL_TABLE,
59 static int comp_threshold_set(
struct tps65910 *
tps65910,
int id,
int voltage)
69 while (curr_voltage < tps_comp.
uV_max) {
71 if (curr_voltage >= voltage)
73 else if (curr_voltage < voltage)
77 if (curr_voltage > tps_comp.
uV_max)
81 ret = tps65910->write(tps65910, tps_comp.
reg, 1, &
val);
86 static int comp_threshold_get(
struct tps65910 *tps65910,
int id)
95 ret = tps65910->read(tps65910, tps_comp.
reg, 1, &val);
110 if (!
strcmp(comp_attr.
name,
"comp1_threshold"))
112 else if (!
strcmp(comp_attr.
name,
"comp2_threshold"))
117 uVolt = comp_threshold_get(tps65910,
id);
119 return sprintf(buf,
"%d\n", uVolt);
133 dev_err(&pdev->
dev,
"cannot set COMP1 threshold\n");
139 dev_err(&pdev->
dev,
"cannot set COMP2 threshold\n");
146 dev_err(&pdev->
dev,
"failed to add COMP1 sysfs file\n");
150 dev_err(&pdev->
dev,
"failed to add COMP2 sysfs file\n");
157 struct tps65910 *tps65910;
168 .name =
"tps65911-comparator",
171 .probe = tps65911_comparator_probe,
175 static int __init tps65911_comparator_init(
void)
181 static void __exit tps65911_comparator_exit(
void)