Lines Matching +full:lgm +full:- +full:clk

1 // SPDX-License-Identifier: GPL-2.0
6 * - The hardware supports fixed period & configures only 2-wire mode.
7 * - Supports normal polarity. Does not support changing polarity.
8 * - When PWM is disabled, output of PWM will become 0(inactive). It doesn't
10 * - When duty cycle is changed, PWM output may be a mix of previous setting
13 * - It is a dedicated PWM fan controller. There are no other consumers for
17 #include <linux/clk.h>
36 #define LGM_PWM_MAX_RPM (BIT(16) - 1)
38 #define LGM_PWM_MAX_DUTY_CYCLE (BIT(8) - 1)
57 struct regmap *regmap = pc->regmap; in lgm_pwm_enable()
71 if (state->polarity != PWM_POLARITY_NORMAL || state->period < pc->period) in lgm_pwm_apply()
72 return -EINVAL; in lgm_pwm_apply()
74 if (!state->enabled) in lgm_pwm_apply()
77 duty_cycle = min_t(u64, state->duty_cycle, pc->period); in lgm_pwm_apply()
78 val = duty_cycle * LGM_PWM_MAX_DUTY_CYCLE / pc->period; in lgm_pwm_apply()
80 ret = regmap_update_bits(pc->regmap, LGM_PWM_FAN_CON0, LGM_PWM_FAN_DC_MSK, in lgm_pwm_apply()
94 state->enabled = regmap_test_bits(pc->regmap, LGM_PWM_FAN_CON0, in lgm_pwm_get_state()
96 state->polarity = PWM_POLARITY_NORMAL; in lgm_pwm_get_state()
97 state->period = pc->period; /* fixed period */ in lgm_pwm_get_state()
99 regmap_read(pc->regmap, LGM_PWM_FAN_CON0, &val); in lgm_pwm_get_state()
101 state->duty_cycle = DIV_ROUND_UP(duty * pc->period, LGM_PWM_MAX_DUTY_CYCLE); in lgm_pwm_get_state()
113 struct regmap *regmap = pc->regmap; in lgm_pwm_init()
117 pc->period = LGM_PWM_PERIOD_2WIRE_NS; in lgm_pwm_init()
132 struct clk *clk = data; in lgm_clk_release() local
134 clk_disable_unprepare(clk); in lgm_clk_release()
137 static int lgm_clk_enable(struct device *dev, struct clk *clk) in lgm_clk_enable() argument
141 ret = clk_prepare_enable(clk); in lgm_clk_enable()
145 return devm_add_action_or_reset(dev, lgm_clk_release, clk); in lgm_clk_enable()
168 struct device *dev = &pdev->dev; in lgm_pwm_probe()
173 struct clk *clk; in lgm_pwm_probe() local
185 pc->regmap = devm_regmap_init_mmio(dev, io_base, &lgm_pwm_regmap_config); in lgm_pwm_probe()
186 if (IS_ERR(pc->regmap)) in lgm_pwm_probe()
187 return dev_err_probe(dev, PTR_ERR(pc->regmap), in lgm_pwm_probe()
190 clk = devm_clk_get(dev, NULL); in lgm_pwm_probe()
191 if (IS_ERR(clk)) in lgm_pwm_probe()
192 return dev_err_probe(dev, PTR_ERR(clk), "failed to get clock\n"); in lgm_pwm_probe()
194 ret = lgm_clk_enable(dev, clk); in lgm_pwm_probe()
207 chip->ops = &lgm_pwm_ops; in lgm_pwm_probe()
219 { .compatible = "intel,lgm-pwm" },
226 .name = "intel-pwm",
233 MODULE_DESCRIPTION("Intel LGM Pulse Width Modulator driver");