ODROID-COMMON:PWM driver pinctrl for odroid.

Change-Id: Iced9657a28d6cf1715f5d130644079b0dc96c865
This commit is contained in:
Kevin Kim
2019-01-08 14:26:58 +09:00
parent e867ebe0e7
commit ca9d1a71f6
3 changed files with 53 additions and 1 deletions

View File

@@ -254,8 +254,18 @@
tv_bit_mode = <1>;
};
&pwm_cd {
status = "disabled";
pinctrl-names = "pwm_pins","gpio_periphs";
pinctrl-0 = <&pwm_c_pins2 &pwm_d_pins1>;
pinctrl-1 = <&pwmcd_to_gpios>;
};
&pwm_ef {
status = "okay";
status = "disabled";
pinctrl-names = "pwm_pins","gpio_periphs";
pinctrl-0 = <&pwm_e_pins &pwm_f_pins1>;
pinctrl-1 = <&pwmef_to_gpios>;
};
&pwm_AO_cd {
@@ -478,4 +488,16 @@
function = "spdif_out";
};
};
pwmcd_to_gpios:pwmcd_gpio {
mux {
groups = "GPIOX_5", "GPIOX_3";
function = "gpio_periphs";
};
};
pwmef_to_gpios:pwmef_gpio {
mux {
groups = "GPIOX_16", "GPIOX_7";
function = "gpio_periphs";
};
};
}; /* end of pinctrl_periphs */

View File

@@ -61,6 +61,10 @@
#include <linux/amlogic/pwm_meson.h>
#include <linux/of_device.h>
#if defined(CONFIG_ARCH_MESON64_ODROID_COMMON)
#include <linux/pinctrl/consumer.h>
#endif
struct meson_pwm_channel {
unsigned int hi;
unsigned int lo;
@@ -125,6 +129,9 @@ static int meson_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
struct meson_pwm_channel *channel = pwm_get_chip_data(pwm);
struct device *dev = chip->dev;
int err;
#if defined(CONFIG_ARCH_MESON64_ODROID_COMMON)
struct meson_pwm *meson = to_meson_pwm(chip);
#endif
if (!channel)
return -ENODEV;
@@ -148,6 +155,13 @@ static int meson_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
chip->ops->get_state(chip, pwm, &channel->state);
#if defined(CONFIG_ARCH_MESON64_ODROID_COMMON)
meson->p_pinctrl = devm_pinctrl_get_select(dev, "pwm_pins");
if (IS_ERR(meson->p_pinctrl)) {
meson->p_pinctrl = NULL;
dev_err(dev, "pwm pinmux : can't get pinctrl\n");
}
#endif
return 0;
}
@@ -155,6 +169,16 @@ static void meson_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
{
struct meson_pwm_channel *channel = pwm_get_chip_data(pwm);
#if defined(CONFIG_ARCH_MESON64_ODROID_COMMON)
struct meson_pwm *meson = to_meson_pwm(chip);
struct device *dev = chip->dev;
if (meson->p_pinctrl)
devm_pinctrl_put(meson->p_pinctrl);
meson->p_pinctrl = devm_pinctrl_get_select(dev, "gpio_periphs");
devm_pinctrl_put(meson->p_pinctrl);
meson->p_pinctrl = NULL;
#endif
if (channel)
clk_disable_unprepare(channel->clk);
}
@@ -652,6 +676,9 @@ static int meson_pwm_probe(struct platform_device *pdev)
meson->chip.npwm = 2;
meson->inverter_mask = BIT(meson->chip.npwm) - 1;
#if defined(CONFIG_ARCH_MESON64_ODROID_COMMON)
meson->p_pinctrl = NULL;
#endif
channels = devm_kcalloc(&pdev->dev, meson->chip.npwm, sizeof(*channels),
GFP_KERNEL);
if (!channels)

View File

@@ -124,6 +124,9 @@ struct meson_pwm {
struct mutex lock;
spinlock_t pwm_lock;
unsigned int clk_mask;
#if defined(CONFIG_ARCH_MESON64_ODROID_COMMON)
struct pinctrl *p_pinctrl;
#endif
};
/*the functions only use for meson pwm driver*/