lpc18xx_pwm       112 drivers/pwm/pwm-lpc18xx-sct.c static inline void lpc18xx_pwm_writel(struct lpc18xx_pwm_chip *lpc18xx_pwm,
lpc18xx_pwm       115 drivers/pwm/pwm-lpc18xx-sct.c 	writel(val, lpc18xx_pwm->base + reg);
lpc18xx_pwm       118 drivers/pwm/pwm-lpc18xx-sct.c static inline u32 lpc18xx_pwm_readl(struct lpc18xx_pwm_chip *lpc18xx_pwm,
lpc18xx_pwm       121 drivers/pwm/pwm-lpc18xx-sct.c 	return readl(lpc18xx_pwm->base + reg);
lpc18xx_pwm       124 drivers/pwm/pwm-lpc18xx-sct.c static void lpc18xx_pwm_set_conflict_res(struct lpc18xx_pwm_chip *lpc18xx_pwm,
lpc18xx_pwm       130 drivers/pwm/pwm-lpc18xx-sct.c 	mutex_lock(&lpc18xx_pwm->res_lock);
lpc18xx_pwm       137 drivers/pwm/pwm-lpc18xx-sct.c 	val = lpc18xx_pwm_readl(lpc18xx_pwm, LPC18XX_PWM_RES_BASE);
lpc18xx_pwm       140 drivers/pwm/pwm-lpc18xx-sct.c 	lpc18xx_pwm_writel(lpc18xx_pwm, LPC18XX_PWM_RES_BASE, val);
lpc18xx_pwm       142 drivers/pwm/pwm-lpc18xx-sct.c 	mutex_unlock(&lpc18xx_pwm->res_lock);
lpc18xx_pwm       147 drivers/pwm/pwm-lpc18xx-sct.c 	struct lpc18xx_pwm_chip *lpc18xx_pwm = to_lpc18xx_pwm_chip(chip);
lpc18xx_pwm       150 drivers/pwm/pwm-lpc18xx-sct.c 	val = (u64)period_ns * lpc18xx_pwm->clk_rate;
lpc18xx_pwm       153 drivers/pwm/pwm-lpc18xx-sct.c 	lpc18xx_pwm_writel(lpc18xx_pwm,
lpc18xx_pwm       154 drivers/pwm/pwm-lpc18xx-sct.c 			   LPC18XX_PWM_MATCH(lpc18xx_pwm->period_event),
lpc18xx_pwm       157 drivers/pwm/pwm-lpc18xx-sct.c 	lpc18xx_pwm_writel(lpc18xx_pwm,
lpc18xx_pwm       158 drivers/pwm/pwm-lpc18xx-sct.c 			   LPC18XX_PWM_MATCHREL(lpc18xx_pwm->period_event),
lpc18xx_pwm       165 drivers/pwm/pwm-lpc18xx-sct.c 	struct lpc18xx_pwm_chip *lpc18xx_pwm = to_lpc18xx_pwm_chip(chip);
lpc18xx_pwm       169 drivers/pwm/pwm-lpc18xx-sct.c 	val = (u64)duty_ns * lpc18xx_pwm->clk_rate;
lpc18xx_pwm       172 drivers/pwm/pwm-lpc18xx-sct.c 	lpc18xx_pwm_writel(lpc18xx_pwm,
lpc18xx_pwm       176 drivers/pwm/pwm-lpc18xx-sct.c 	lpc18xx_pwm_writel(lpc18xx_pwm,
lpc18xx_pwm       184 drivers/pwm/pwm-lpc18xx-sct.c 	struct lpc18xx_pwm_chip *lpc18xx_pwm = to_lpc18xx_pwm_chip(chip);
lpc18xx_pwm       187 drivers/pwm/pwm-lpc18xx-sct.c 	if (period_ns < lpc18xx_pwm->min_period_ns ||
lpc18xx_pwm       188 drivers/pwm/pwm-lpc18xx-sct.c 	    period_ns > lpc18xx_pwm->max_period_ns) {
lpc18xx_pwm       193 drivers/pwm/pwm-lpc18xx-sct.c 	mutex_lock(&lpc18xx_pwm->period_lock);
lpc18xx_pwm       195 drivers/pwm/pwm-lpc18xx-sct.c 	requested_events = bitmap_weight(&lpc18xx_pwm->event_map,
lpc18xx_pwm       203 drivers/pwm/pwm-lpc18xx-sct.c 	if (requested_events > 2 && lpc18xx_pwm->period_ns != period_ns &&
lpc18xx_pwm       204 drivers/pwm/pwm-lpc18xx-sct.c 	    lpc18xx_pwm->period_ns) {
lpc18xx_pwm       207 drivers/pwm/pwm-lpc18xx-sct.c 		mutex_unlock(&lpc18xx_pwm->period_lock);
lpc18xx_pwm       211 drivers/pwm/pwm-lpc18xx-sct.c 	if ((requested_events <= 2 && lpc18xx_pwm->period_ns != period_ns) ||
lpc18xx_pwm       212 drivers/pwm/pwm-lpc18xx-sct.c 	    !lpc18xx_pwm->period_ns) {
lpc18xx_pwm       213 drivers/pwm/pwm-lpc18xx-sct.c 		lpc18xx_pwm->period_ns = period_ns;
lpc18xx_pwm       219 drivers/pwm/pwm-lpc18xx-sct.c 	mutex_unlock(&lpc18xx_pwm->period_lock);
lpc18xx_pwm       235 drivers/pwm/pwm-lpc18xx-sct.c 	struct lpc18xx_pwm_chip *lpc18xx_pwm = to_lpc18xx_pwm_chip(chip);
lpc18xx_pwm       240 drivers/pwm/pwm-lpc18xx-sct.c 	lpc18xx_pwm_writel(lpc18xx_pwm,
lpc18xx_pwm       245 drivers/pwm/pwm-lpc18xx-sct.c 	lpc18xx_pwm_writel(lpc18xx_pwm,
lpc18xx_pwm       250 drivers/pwm/pwm-lpc18xx-sct.c 		set_event = lpc18xx_pwm->period_event;
lpc18xx_pwm       255 drivers/pwm/pwm-lpc18xx-sct.c 		clear_event = lpc18xx_pwm->period_event;
lpc18xx_pwm       259 drivers/pwm/pwm-lpc18xx-sct.c 	lpc18xx_pwm_writel(lpc18xx_pwm, LPC18XX_PWM_OUTPUTSET(pwm->hwpwm),
lpc18xx_pwm       261 drivers/pwm/pwm-lpc18xx-sct.c 	lpc18xx_pwm_writel(lpc18xx_pwm, LPC18XX_PWM_OUTPUTCL(pwm->hwpwm),
lpc18xx_pwm       263 drivers/pwm/pwm-lpc18xx-sct.c 	lpc18xx_pwm_set_conflict_res(lpc18xx_pwm, pwm, res_action);
lpc18xx_pwm       270 drivers/pwm/pwm-lpc18xx-sct.c 	struct lpc18xx_pwm_chip *lpc18xx_pwm = to_lpc18xx_pwm_chip(chip);
lpc18xx_pwm       273 drivers/pwm/pwm-lpc18xx-sct.c 	lpc18xx_pwm_writel(lpc18xx_pwm,
lpc18xx_pwm       275 drivers/pwm/pwm-lpc18xx-sct.c 	lpc18xx_pwm_writel(lpc18xx_pwm, LPC18XX_PWM_OUTPUTSET(pwm->hwpwm), 0);
lpc18xx_pwm       276 drivers/pwm/pwm-lpc18xx-sct.c 	lpc18xx_pwm_writel(lpc18xx_pwm, LPC18XX_PWM_OUTPUTCL(pwm->hwpwm), 0);
lpc18xx_pwm       281 drivers/pwm/pwm-lpc18xx-sct.c 	struct lpc18xx_pwm_chip *lpc18xx_pwm = to_lpc18xx_pwm_chip(chip);
lpc18xx_pwm       285 drivers/pwm/pwm-lpc18xx-sct.c 	event = find_first_zero_bit(&lpc18xx_pwm->event_map,
lpc18xx_pwm       289 drivers/pwm/pwm-lpc18xx-sct.c 		dev_err(lpc18xx_pwm->dev,
lpc18xx_pwm       294 drivers/pwm/pwm-lpc18xx-sct.c 	set_bit(event, &lpc18xx_pwm->event_map);
lpc18xx_pwm       302 drivers/pwm/pwm-lpc18xx-sct.c 	struct lpc18xx_pwm_chip *lpc18xx_pwm = to_lpc18xx_pwm_chip(chip);
lpc18xx_pwm       305 drivers/pwm/pwm-lpc18xx-sct.c 	clear_bit(lpc18xx_data->duty_event, &lpc18xx_pwm->event_map);
lpc18xx_pwm       326 drivers/pwm/pwm-lpc18xx-sct.c 	struct lpc18xx_pwm_chip *lpc18xx_pwm;
lpc18xx_pwm       332 drivers/pwm/pwm-lpc18xx-sct.c 	lpc18xx_pwm = devm_kzalloc(&pdev->dev, sizeof(*lpc18xx_pwm),
lpc18xx_pwm       334 drivers/pwm/pwm-lpc18xx-sct.c 	if (!lpc18xx_pwm)
lpc18xx_pwm       337 drivers/pwm/pwm-lpc18xx-sct.c 	lpc18xx_pwm->dev = &pdev->dev;
lpc18xx_pwm       340 drivers/pwm/pwm-lpc18xx-sct.c 	lpc18xx_pwm->base = devm_ioremap_resource(&pdev->dev, res);
lpc18xx_pwm       341 drivers/pwm/pwm-lpc18xx-sct.c 	if (IS_ERR(lpc18xx_pwm->base))
lpc18xx_pwm       342 drivers/pwm/pwm-lpc18xx-sct.c 		return PTR_ERR(lpc18xx_pwm->base);
lpc18xx_pwm       344 drivers/pwm/pwm-lpc18xx-sct.c 	lpc18xx_pwm->pwm_clk = devm_clk_get(&pdev->dev, "pwm");
lpc18xx_pwm       345 drivers/pwm/pwm-lpc18xx-sct.c 	if (IS_ERR(lpc18xx_pwm->pwm_clk)) {
lpc18xx_pwm       347 drivers/pwm/pwm-lpc18xx-sct.c 		return PTR_ERR(lpc18xx_pwm->pwm_clk);
lpc18xx_pwm       350 drivers/pwm/pwm-lpc18xx-sct.c 	ret = clk_prepare_enable(lpc18xx_pwm->pwm_clk);
lpc18xx_pwm       356 drivers/pwm/pwm-lpc18xx-sct.c 	lpc18xx_pwm->clk_rate = clk_get_rate(lpc18xx_pwm->pwm_clk);
lpc18xx_pwm       357 drivers/pwm/pwm-lpc18xx-sct.c 	if (!lpc18xx_pwm->clk_rate) {
lpc18xx_pwm       363 drivers/pwm/pwm-lpc18xx-sct.c 	mutex_init(&lpc18xx_pwm->res_lock);
lpc18xx_pwm       364 drivers/pwm/pwm-lpc18xx-sct.c 	mutex_init(&lpc18xx_pwm->period_lock);
lpc18xx_pwm       367 drivers/pwm/pwm-lpc18xx-sct.c 	do_div(val, lpc18xx_pwm->clk_rate);
lpc18xx_pwm       368 drivers/pwm/pwm-lpc18xx-sct.c 	lpc18xx_pwm->max_period_ns = val;
lpc18xx_pwm       370 drivers/pwm/pwm-lpc18xx-sct.c 	lpc18xx_pwm->min_period_ns = DIV_ROUND_UP(NSEC_PER_SEC,
lpc18xx_pwm       371 drivers/pwm/pwm-lpc18xx-sct.c 						  lpc18xx_pwm->clk_rate);
lpc18xx_pwm       373 drivers/pwm/pwm-lpc18xx-sct.c 	lpc18xx_pwm->chip.dev = &pdev->dev;
lpc18xx_pwm       374 drivers/pwm/pwm-lpc18xx-sct.c 	lpc18xx_pwm->chip.ops = &lpc18xx_pwm_ops;
lpc18xx_pwm       375 drivers/pwm/pwm-lpc18xx-sct.c 	lpc18xx_pwm->chip.base = -1;
lpc18xx_pwm       376 drivers/pwm/pwm-lpc18xx-sct.c 	lpc18xx_pwm->chip.npwm = 16;
lpc18xx_pwm       377 drivers/pwm/pwm-lpc18xx-sct.c 	lpc18xx_pwm->chip.of_xlate = of_pwm_xlate_with_flags;
lpc18xx_pwm       378 drivers/pwm/pwm-lpc18xx-sct.c 	lpc18xx_pwm->chip.of_pwm_n_cells = 3;
lpc18xx_pwm       381 drivers/pwm/pwm-lpc18xx-sct.c 	lpc18xx_pwm_writel(lpc18xx_pwm, LPC18XX_PWM_CONFIG,
lpc18xx_pwm       388 drivers/pwm/pwm-lpc18xx-sct.c 	set_bit(LPC18XX_PWM_EVENT_PERIOD, &lpc18xx_pwm->event_map);
lpc18xx_pwm       389 drivers/pwm/pwm-lpc18xx-sct.c 	lpc18xx_pwm->period_event = LPC18XX_PWM_EVENT_PERIOD;
lpc18xx_pwm       391 drivers/pwm/pwm-lpc18xx-sct.c 	lpc18xx_pwm_writel(lpc18xx_pwm,
lpc18xx_pwm       392 drivers/pwm/pwm-lpc18xx-sct.c 			   LPC18XX_PWM_EVSTATEMSK(lpc18xx_pwm->period_event),
lpc18xx_pwm       395 drivers/pwm/pwm-lpc18xx-sct.c 	val = LPC18XX_PWM_EVCTRL_MATCH(lpc18xx_pwm->period_event) |
lpc18xx_pwm       397 drivers/pwm/pwm-lpc18xx-sct.c 	lpc18xx_pwm_writel(lpc18xx_pwm,
lpc18xx_pwm       398 drivers/pwm/pwm-lpc18xx-sct.c 			   LPC18XX_PWM_EVCTRL(lpc18xx_pwm->period_event), val);
lpc18xx_pwm       400 drivers/pwm/pwm-lpc18xx-sct.c 	lpc18xx_pwm_writel(lpc18xx_pwm, LPC18XX_PWM_LIMIT,
lpc18xx_pwm       401 drivers/pwm/pwm-lpc18xx-sct.c 			   BIT(lpc18xx_pwm->period_event));
lpc18xx_pwm       403 drivers/pwm/pwm-lpc18xx-sct.c 	ret = pwmchip_add(&lpc18xx_pwm->chip);
lpc18xx_pwm       409 drivers/pwm/pwm-lpc18xx-sct.c 	for (i = 0; i < lpc18xx_pwm->chip.npwm; i++) {
lpc18xx_pwm       412 drivers/pwm/pwm-lpc18xx-sct.c 		pwm = &lpc18xx_pwm->chip.pwms[i];
lpc18xx_pwm       414 drivers/pwm/pwm-lpc18xx-sct.c 		data = devm_kzalloc(lpc18xx_pwm->dev, sizeof(*data),
lpc18xx_pwm       424 drivers/pwm/pwm-lpc18xx-sct.c 	platform_set_drvdata(pdev, lpc18xx_pwm);
lpc18xx_pwm       426 drivers/pwm/pwm-lpc18xx-sct.c 	val = lpc18xx_pwm_readl(lpc18xx_pwm, LPC18XX_PWM_CTRL);
lpc18xx_pwm       431 drivers/pwm/pwm-lpc18xx-sct.c 	lpc18xx_pwm_writel(lpc18xx_pwm, LPC18XX_PWM_CTRL, val);
lpc18xx_pwm       436 drivers/pwm/pwm-lpc18xx-sct.c 	pwmchip_remove(&lpc18xx_pwm->chip);
lpc18xx_pwm       438 drivers/pwm/pwm-lpc18xx-sct.c 	clk_disable_unprepare(lpc18xx_pwm->pwm_clk);
lpc18xx_pwm       444 drivers/pwm/pwm-lpc18xx-sct.c 	struct lpc18xx_pwm_chip *lpc18xx_pwm = platform_get_drvdata(pdev);
lpc18xx_pwm       447 drivers/pwm/pwm-lpc18xx-sct.c 	val = lpc18xx_pwm_readl(lpc18xx_pwm, LPC18XX_PWM_CTRL);
lpc18xx_pwm       448 drivers/pwm/pwm-lpc18xx-sct.c 	lpc18xx_pwm_writel(lpc18xx_pwm, LPC18XX_PWM_CTRL,
lpc18xx_pwm       451 drivers/pwm/pwm-lpc18xx-sct.c 	clk_disable_unprepare(lpc18xx_pwm->pwm_clk);
lpc18xx_pwm       453 drivers/pwm/pwm-lpc18xx-sct.c 	return pwmchip_remove(&lpc18xx_pwm->chip);