ITE: drivers/pwm: Use pinctrl instead of pinmux driver

Use pinctrl instead of pinmux driver.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
This commit is contained in:
Tim Lin 2022-03-25 16:59:22 +08:00 committed by Carles Cufí
commit 8ecd5bb2f7
6 changed files with 49 additions and 60 deletions

View file

@ -131,12 +131,16 @@
* then we should set frequency <=324Hz.
*/
pwm-output-frequency = <324>;
pinctrl-0 = <&pwm0_gpa0_default>;
pinctrl-names = "default";
};
/* pwm for fan */
&pwm7 {
status = "okay";
prescaler-cx = <PWM_PRESCALER_C4>;
pwm-output-frequency = <30000>;
pinctrl-0 = <&pwm7_gpa7_default>;
pinctrl-names = "default";
};
/* fan tachometer sensor */
&tach0 {

View file

@ -8,7 +8,7 @@
#include <device.h>
#include <drivers/pwm.h>
#include <drivers/pinmux.h>
#include <drivers/pinctrl.h>
#include <dt-bindings/pwm/it8xxx2_pwm.h>
#include <errno.h>
#include <kernel.h>
@ -23,16 +23,6 @@ LOG_MODULE_REGISTER(pwm_ite_it8xxx2, CONFIG_PWM_LOG_LEVEL);
#define PWM_FREQ EC_FREQ
#define PCSSG_MASK 0x3
/* Device config */
struct pwm_alt_cfg {
/* Pinmux control device structure */
const struct device *pinctrls;
/* GPIO pin */
uint8_t pin;
/* Alternate function */
uint8_t alt_fun;
};
struct pwm_it8xxx2_cfg {
/* PWM channel duty cycle register */
uintptr_t reg_dcr;
@ -48,8 +38,8 @@ struct pwm_it8xxx2_cfg {
struct pwm_it8xxx2_regs *base;
/* Select PWM prescaler that output to PWM channel */
int prs_sel;
/* PWM alternate configuration list */
const struct pwm_alt_cfg *alt_list;
/* PWM alternate configuration */
const struct pinctrl_dev_config *pcfg;
};
static void pwm_enable(const struct device *dev, int enabled)
@ -216,6 +206,7 @@ static int pwm_it8xxx2_init(const struct device *dev)
int prs_sel = config->prs_sel;
int pcssg_shift;
int pcssg_mask;
int status;
/* PWM channel clock source gating before configuring */
pwm_enable(dev, 0);
@ -244,9 +235,12 @@ static int pwm_it8xxx2_init(const struct device *dev)
inst->ZTIER |= IT8XXX2_PWM_PCCE;
/* Set alternate mode of PWM pin */
pinmux_pin_set(config->alt_list->pinctrls,
config->alt_list->pin,
config->alt_list->alt_fun);
status = pinctrl_apply_state(config->pcfg, PINCTRL_STATE_DEFAULT);
if (status < 0) {
LOG_ERR("Failed to configure PWM pins");
return status;
}
return 0;
}
@ -257,9 +251,7 @@ static const struct pwm_driver_api pwm_it8xxx2_api = {
/* Device Instance */
#define PWM_IT8XXX2_INIT(inst) \
static const struct pwm_alt_cfg \
pwm_alt_##inst[DT_INST_NUM_PINCTRLS_BY_IDX(inst, 0)] = \
IT8XXX2_DT_ALT_ITEMS_LIST(inst); \
PINCTRL_DT_INST_DEFINE(inst); \
\
static const struct pwm_it8xxx2_cfg pwm_it8xxx2_cfg_##inst = { \
.reg_dcr = DT_INST_REG_ADDR_BY_IDX(inst, 0), \
@ -269,7 +261,7 @@ static const struct pwm_driver_api pwm_it8xxx2_api = {
.channel = DT_PROP(DT_INST(inst, ite_it8xxx2_pwm), channel), \
.base = (struct pwm_it8xxx2_regs *) DT_REG_ADDR(DT_NODELABEL(prs)), \
.prs_sel = DT_PROP(DT_INST(inst, ite_it8xxx2_pwm), prescaler_cx), \
.alt_list = pwm_alt_##inst, \
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(inst), \
}; \
\
DEVICE_DT_INST_DEFINE(inst, \

View file

@ -5,7 +5,7 @@ description: ITE, it8xxx2 Pulse Width Modulator (PWM) node
compatible: "ite,it8xxx2-pwm"
include: [pwm-controller.yaml, base.yaml]
include: [pwm-controller.yaml, base.yaml, pinctrl-device.yaml]
properties:
reg:
@ -39,11 +39,6 @@ properties:
required: true
description: PWM prescaler controller
pinctrl-0:
type: phandle
required: true
description: configuration of PWM pinmux controller
prescaler-cx:
type: int
required: true
@ -58,6 +53,12 @@ properties:
required: false
description: PWM output frequency for operation
pinctrl-0:
required: true
pinctrl-names:
required: true
pwm-cells:
- channel
- period

View file

@ -10,32 +10,6 @@
it8xxx2_alts_map {
compatible = "ite,it8xxx2-pinctrl-conf";
/* PWM alternate function */
pinctrl_pwm0: pwm0 {
pinctrls = <&pinmuxa 0 IT8XXX2_PINMUX_FUNC_1>;
};
pinctrl_pwm1: pwm1 {
pinctrls = <&pinmuxa 1 IT8XXX2_PINMUX_FUNC_1>;
};
pinctrl_pwm2: pwm2 {
pinctrls = <&pinmuxa 2 IT8XXX2_PINMUX_FUNC_1>;
};
pinctrl_pwm3: pwm3 {
pinctrls = <&pinmuxa 3 IT8XXX2_PINMUX_FUNC_1>;
};
pinctrl_pwm4: pwm4 {
pinctrls = <&pinmuxa 4 IT8XXX2_PINMUX_FUNC_1>;
};
pinctrl_pwm5: pwm5 {
pinctrls = <&pinmuxa 5 IT8XXX2_PINMUX_FUNC_1>;
};
pinctrl_pwm6: pwm6 {
pinctrls = <&pinmuxa 6 IT8XXX2_PINMUX_FUNC_1>;
};
pinctrl_pwm7: pwm7 {
pinctrls = <&pinmuxa 7 IT8XXX2_PINMUX_FUNC_1>;
};
/* Tachometer alternate function */
pinctrl_tach0a: tach0a {
pinctrls = <&pinmuxd 6 IT8XXX2_PINMUX_FUNC_1>;

View file

@ -1277,7 +1277,6 @@
label = "pwm_0";
status = "disabled";
pwmctrl = <&prs>;
pinctrl-0 = <&pinctrl_pwm0>; /* GPA0 */
#pwm-cells = <3>;
};
pwm1: pwm@f01803 {
@ -1290,7 +1289,6 @@
label = "pwm_1";
status = "disabled";
pwmctrl = <&prs>;
pinctrl-0 = <&pinctrl_pwm1>; /* GPA1 */
#pwm-cells = <3>;
};
pwm2: pwm@f01804 {
@ -1303,7 +1301,6 @@
label = "pwm_2";
status = "disabled";
pwmctrl = <&prs>;
pinctrl-0 = <&pinctrl_pwm2>; /* GPA2 */
#pwm-cells = <3>;
};
pwm3: pwm@f01805 {
@ -1316,7 +1313,6 @@
label = "pwm_3";
status = "disabled";
pwmctrl = <&prs>;
pinctrl-0 = <&pinctrl_pwm3>; /* GPA3 */
#pwm-cells = <3>;
};
pwm4: pwm@f01806 {
@ -1329,7 +1325,6 @@
label = "pwm_4";
status = "disabled";
pwmctrl = <&prs>;
pinctrl-0 = <&pinctrl_pwm4>; /* GPA4 */
#pwm-cells = <3>;
};
pwm5: pwm@f01807 {
@ -1342,7 +1337,6 @@
label = "pwm_5";
status = "disabled";
pwmctrl = <&prs>;
pinctrl-0 = <&pinctrl_pwm5>; /* GPA5 */
#pwm-cells = <3>;
};
pwm6: pwm@f01808 {
@ -1355,7 +1349,6 @@
label = "pwm_6";
status = "disabled";
pwmctrl = <&prs>;
pinctrl-0 = <&pinctrl_pwm6>; /* GPA6 */
#pwm-cells = <3>;
};
pwm7: pwm@f01809 {
@ -1368,7 +1361,6 @@
label = "pwm_7";
status = "disabled";
pwmctrl = <&prs>;
pinctrl-0 = <&pinctrl_pwm7>; /* GPA7 */
#pwm-cells = <3>;
};
tach0: tach@f0181e {

View file

@ -89,6 +89,32 @@
pinmuxs = <&pinctrla 5 IT8XXX2_ALT_FUNC_3>;
};
/* PWM alternate function */
pwm0_gpa0_default: pwm0_gpa0_default {
pinmuxs = <&pinctrla 0 IT8XXX2_ALT_FUNC_1>;
};
pwm1_gpa1_default: pwm1_gpa1_default {
pinmuxs = <&pinctrla 1 IT8XXX2_ALT_FUNC_1>;
};
pwm2_gpa2_default: pwm2_gpa2_default {
pinmuxs = <&pinctrla 2 IT8XXX2_ALT_FUNC_1>;
};
pwm3_gpa3_default: pwm3_gpa3_default {
pinmuxs = <&pinctrla 3 IT8XXX2_ALT_FUNC_1>;
};
pwm4_gpa4_default: pwm4_gpa4_default {
pinmuxs = <&pinctrla 4 IT8XXX2_ALT_FUNC_1>;
};
pwm5_gpa5_default: pwm5_gpa5_default {
pinmuxs = <&pinctrla 5 IT8XXX2_ALT_FUNC_1>;
};
pwm6_gpa6_default: pwm6_gpa6_default {
pinmuxs = <&pinctrla 6 IT8XXX2_ALT_FUNC_1>;
};
pwm7_gpa7_default: pwm7_gpa7_default {
pinmuxs = <&pinctrla 7 IT8XXX2_ALT_FUNC_1>;
};
/* UART alternate function */
uart1_rx_gpb0_default: uart1_rx_gpb0_default {
pinmuxs = <&pinctrlb 0 IT8XXX2_ALT_FUNC_3>;