drivers/input/misc/max77693-haptic.c
Source file repositories/reference/linux-study-clean/drivers/input/misc/max77693-haptic.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/misc/max77693-haptic.c- Extension
.c- Size
- 10918 bytes
- Lines
- 444
- Domain
- Driver Families
- Bucket
- drivers/input
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/err.hlinux/init.hlinux/i2c.hlinux/regmap.hlinux/input.hlinux/module.hlinux/platform_device.hlinux/pwm.hlinux/slab.hlinux/string_choices.hlinux/workqueue.hlinux/regulator/consumer.hlinux/mfd/max77693.hlinux/mfd/max77693-common.hlinux/mfd/max77693-private.hlinux/mfd/max77705-private.hlinux/mfd/max77843-private.h
Detected Declarations
struct max77693_hapticenum max77693_haptic_motor_typeenum max77693_haptic_pulse_modeenum max77693_haptic_pwm_divisorfunction max77693_haptic_set_duty_cyclefunction max77843_haptic_biasfunction max77693_haptic_configurefunction max77693_haptic_lowsysfunction max77693_haptic_enablefunction max77693_haptic_disablefunction max77693_haptic_play_workfunction max77693_haptic_play_effectfunction max77693_haptic_openfunction max77693_haptic_closefunction max77693_haptic_probefunction max77693_haptic_suspendfunction max77693_haptic_resume
Annotated Snippet
struct max77693_haptic {
enum max77693_types dev_type;
struct regmap *regmap_pmic;
struct regmap *regmap_haptic;
struct device *dev;
struct input_dev *input_dev;
struct pwm_device *pwm_dev;
struct regulator *motor_reg;
bool enabled;
bool suspend_state;
unsigned int magnitude;
unsigned int pwm_duty;
enum max77693_haptic_motor_type type;
enum max77693_haptic_pulse_mode mode;
struct work_struct work;
};
static int max77693_haptic_set_duty_cycle(struct max77693_haptic *haptic)
{
struct pwm_state state;
int error;
pwm_init_state(haptic->pwm_dev, &state);
state.duty_cycle = (state.period + haptic->pwm_duty) / 2;
error = pwm_apply_might_sleep(haptic->pwm_dev, &state);
if (error) {
dev_err(haptic->dev,
"failed to set pwm duty cycle: %d\n", error);
return error;
}
return 0;
}
static int max77843_haptic_bias(struct max77693_haptic *haptic, bool on)
{
int error;
if (haptic->dev_type != TYPE_MAX77843)
return 0;
error = regmap_update_bits(haptic->regmap_haptic,
MAX77843_SYS_REG_MAINCTRL1,
MAX77843_MAINCTRL1_BIASEN_MASK,
on << MAINCTRL1_BIASEN_SHIFT);
if (error) {
dev_err(haptic->dev, "failed to %s bias: %d\n",
str_enable_disable(on), error);
return error;
}
return 0;
}
static int max77693_haptic_configure(struct max77693_haptic *haptic,
bool enable)
{
unsigned int value, config_reg;
int error;
switch (haptic->dev_type) {
case TYPE_MAX77693:
value = ((haptic->type << MAX77693_CONFIG2_MODE) |
(enable << MAX77693_CONFIG2_MEN) |
(haptic->mode << MAX77693_CONFIG2_HTYP) |
MAX77693_HAPTIC_PWM_DIVISOR_128);
config_reg = MAX77693_HAPTIC_REG_CONFIG2;
break;
case TYPE_MAX77705:
value = ((haptic->type << MAX77693_CONFIG2_MODE) |
(enable << MAX77693_CONFIG2_MEN) |
(haptic->mode << MAX77693_CONFIG2_HTYP) |
MAX77693_HAPTIC_PWM_DIVISOR_128);
config_reg = MAX77705_PMIC_REG_MCONFIG;
break;
case TYPE_MAX77843:
value = (haptic->type << MCONFIG_MODE_SHIFT) |
(enable << MCONFIG_MEN_SHIFT) |
MAX77693_HAPTIC_PWM_DIVISOR_128;
config_reg = MAX77843_HAP_REG_MCONFIG;
break;
default:
return -EINVAL;
}
error = regmap_write(haptic->regmap_haptic,
Annotation
- Immediate include surface: `linux/err.h`, `linux/init.h`, `linux/i2c.h`, `linux/regmap.h`, `linux/input.h`, `linux/module.h`, `linux/platform_device.h`, `linux/pwm.h`.
- Detected declarations: `struct max77693_haptic`, `enum max77693_haptic_motor_type`, `enum max77693_haptic_pulse_mode`, `enum max77693_haptic_pwm_divisor`, `function max77693_haptic_set_duty_cycle`, `function max77843_haptic_bias`, `function max77693_haptic_configure`, `function max77693_haptic_lowsys`, `function max77693_haptic_enable`, `function max77693_haptic_disable`.
- Atlas domain: Driver Families / drivers/input.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.