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:
parent
64ff1a8efe
commit
8ecd5bb2f7
6 changed files with 49 additions and 60 deletions
|
@ -131,12 +131,16 @@
|
||||||
* then we should set frequency <=324Hz.
|
* then we should set frequency <=324Hz.
|
||||||
*/
|
*/
|
||||||
pwm-output-frequency = <324>;
|
pwm-output-frequency = <324>;
|
||||||
|
pinctrl-0 = <&pwm0_gpa0_default>;
|
||||||
|
pinctrl-names = "default";
|
||||||
};
|
};
|
||||||
/* pwm for fan */
|
/* pwm for fan */
|
||||||
&pwm7 {
|
&pwm7 {
|
||||||
status = "okay";
|
status = "okay";
|
||||||
prescaler-cx = <PWM_PRESCALER_C4>;
|
prescaler-cx = <PWM_PRESCALER_C4>;
|
||||||
pwm-output-frequency = <30000>;
|
pwm-output-frequency = <30000>;
|
||||||
|
pinctrl-0 = <&pwm7_gpa7_default>;
|
||||||
|
pinctrl-names = "default";
|
||||||
};
|
};
|
||||||
/* fan tachometer sensor */
|
/* fan tachometer sensor */
|
||||||
&tach0 {
|
&tach0 {
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
#include <device.h>
|
#include <device.h>
|
||||||
#include <drivers/pwm.h>
|
#include <drivers/pwm.h>
|
||||||
#include <drivers/pinmux.h>
|
#include <drivers/pinctrl.h>
|
||||||
#include <dt-bindings/pwm/it8xxx2_pwm.h>
|
#include <dt-bindings/pwm/it8xxx2_pwm.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <kernel.h>
|
#include <kernel.h>
|
||||||
|
@ -23,16 +23,6 @@ LOG_MODULE_REGISTER(pwm_ite_it8xxx2, CONFIG_PWM_LOG_LEVEL);
|
||||||
#define PWM_FREQ EC_FREQ
|
#define PWM_FREQ EC_FREQ
|
||||||
#define PCSSG_MASK 0x3
|
#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 {
|
struct pwm_it8xxx2_cfg {
|
||||||
/* PWM channel duty cycle register */
|
/* PWM channel duty cycle register */
|
||||||
uintptr_t reg_dcr;
|
uintptr_t reg_dcr;
|
||||||
|
@ -48,8 +38,8 @@ struct pwm_it8xxx2_cfg {
|
||||||
struct pwm_it8xxx2_regs *base;
|
struct pwm_it8xxx2_regs *base;
|
||||||
/* Select PWM prescaler that output to PWM channel */
|
/* Select PWM prescaler that output to PWM channel */
|
||||||
int prs_sel;
|
int prs_sel;
|
||||||
/* PWM alternate configuration list */
|
/* PWM alternate configuration */
|
||||||
const struct pwm_alt_cfg *alt_list;
|
const struct pinctrl_dev_config *pcfg;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void pwm_enable(const struct device *dev, int enabled)
|
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 prs_sel = config->prs_sel;
|
||||||
int pcssg_shift;
|
int pcssg_shift;
|
||||||
int pcssg_mask;
|
int pcssg_mask;
|
||||||
|
int status;
|
||||||
|
|
||||||
/* PWM channel clock source gating before configuring */
|
/* PWM channel clock source gating before configuring */
|
||||||
pwm_enable(dev, 0);
|
pwm_enable(dev, 0);
|
||||||
|
@ -244,9 +235,12 @@ static int pwm_it8xxx2_init(const struct device *dev)
|
||||||
inst->ZTIER |= IT8XXX2_PWM_PCCE;
|
inst->ZTIER |= IT8XXX2_PWM_PCCE;
|
||||||
|
|
||||||
/* Set alternate mode of PWM pin */
|
/* Set alternate mode of PWM pin */
|
||||||
pinmux_pin_set(config->alt_list->pinctrls,
|
status = pinctrl_apply_state(config->pcfg, PINCTRL_STATE_DEFAULT);
|
||||||
config->alt_list->pin,
|
if (status < 0) {
|
||||||
config->alt_list->alt_fun);
|
LOG_ERR("Failed to configure PWM pins");
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,9 +251,7 @@ static const struct pwm_driver_api pwm_it8xxx2_api = {
|
||||||
|
|
||||||
/* Device Instance */
|
/* Device Instance */
|
||||||
#define PWM_IT8XXX2_INIT(inst) \
|
#define PWM_IT8XXX2_INIT(inst) \
|
||||||
static const struct pwm_alt_cfg \
|
PINCTRL_DT_INST_DEFINE(inst); \
|
||||||
pwm_alt_##inst[DT_INST_NUM_PINCTRLS_BY_IDX(inst, 0)] = \
|
|
||||||
IT8XXX2_DT_ALT_ITEMS_LIST(inst); \
|
|
||||||
\
|
\
|
||||||
static const struct pwm_it8xxx2_cfg pwm_it8xxx2_cfg_##inst = { \
|
static const struct pwm_it8xxx2_cfg pwm_it8xxx2_cfg_##inst = { \
|
||||||
.reg_dcr = DT_INST_REG_ADDR_BY_IDX(inst, 0), \
|
.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), \
|
.channel = DT_PROP(DT_INST(inst, ite_it8xxx2_pwm), channel), \
|
||||||
.base = (struct pwm_it8xxx2_regs *) DT_REG_ADDR(DT_NODELABEL(prs)), \
|
.base = (struct pwm_it8xxx2_regs *) DT_REG_ADDR(DT_NODELABEL(prs)), \
|
||||||
.prs_sel = DT_PROP(DT_INST(inst, ite_it8xxx2_pwm), prescaler_cx), \
|
.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, \
|
DEVICE_DT_INST_DEFINE(inst, \
|
||||||
|
|
|
@ -5,7 +5,7 @@ description: ITE, it8xxx2 Pulse Width Modulator (PWM) node
|
||||||
|
|
||||||
compatible: "ite,it8xxx2-pwm"
|
compatible: "ite,it8xxx2-pwm"
|
||||||
|
|
||||||
include: [pwm-controller.yaml, base.yaml]
|
include: [pwm-controller.yaml, base.yaml, pinctrl-device.yaml]
|
||||||
|
|
||||||
properties:
|
properties:
|
||||||
reg:
|
reg:
|
||||||
|
@ -39,11 +39,6 @@ properties:
|
||||||
required: true
|
required: true
|
||||||
description: PWM prescaler controller
|
description: PWM prescaler controller
|
||||||
|
|
||||||
pinctrl-0:
|
|
||||||
type: phandle
|
|
||||||
required: true
|
|
||||||
description: configuration of PWM pinmux controller
|
|
||||||
|
|
||||||
prescaler-cx:
|
prescaler-cx:
|
||||||
type: int
|
type: int
|
||||||
required: true
|
required: true
|
||||||
|
@ -58,6 +53,12 @@ properties:
|
||||||
required: false
|
required: false
|
||||||
description: PWM output frequency for operation
|
description: PWM output frequency for operation
|
||||||
|
|
||||||
|
pinctrl-0:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
pinctrl-names:
|
||||||
|
required: true
|
||||||
|
|
||||||
pwm-cells:
|
pwm-cells:
|
||||||
- channel
|
- channel
|
||||||
- period
|
- period
|
||||||
|
|
|
@ -10,32 +10,6 @@
|
||||||
it8xxx2_alts_map {
|
it8xxx2_alts_map {
|
||||||
compatible = "ite,it8xxx2-pinctrl-conf";
|
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 */
|
/* Tachometer alternate function */
|
||||||
pinctrl_tach0a: tach0a {
|
pinctrl_tach0a: tach0a {
|
||||||
pinctrls = <&pinmuxd 6 IT8XXX2_PINMUX_FUNC_1>;
|
pinctrls = <&pinmuxd 6 IT8XXX2_PINMUX_FUNC_1>;
|
||||||
|
|
|
@ -1277,7 +1277,6 @@
|
||||||
label = "pwm_0";
|
label = "pwm_0";
|
||||||
status = "disabled";
|
status = "disabled";
|
||||||
pwmctrl = <&prs>;
|
pwmctrl = <&prs>;
|
||||||
pinctrl-0 = <&pinctrl_pwm0>; /* GPA0 */
|
|
||||||
#pwm-cells = <3>;
|
#pwm-cells = <3>;
|
||||||
};
|
};
|
||||||
pwm1: pwm@f01803 {
|
pwm1: pwm@f01803 {
|
||||||
|
@ -1290,7 +1289,6 @@
|
||||||
label = "pwm_1";
|
label = "pwm_1";
|
||||||
status = "disabled";
|
status = "disabled";
|
||||||
pwmctrl = <&prs>;
|
pwmctrl = <&prs>;
|
||||||
pinctrl-0 = <&pinctrl_pwm1>; /* GPA1 */
|
|
||||||
#pwm-cells = <3>;
|
#pwm-cells = <3>;
|
||||||
};
|
};
|
||||||
pwm2: pwm@f01804 {
|
pwm2: pwm@f01804 {
|
||||||
|
@ -1303,7 +1301,6 @@
|
||||||
label = "pwm_2";
|
label = "pwm_2";
|
||||||
status = "disabled";
|
status = "disabled";
|
||||||
pwmctrl = <&prs>;
|
pwmctrl = <&prs>;
|
||||||
pinctrl-0 = <&pinctrl_pwm2>; /* GPA2 */
|
|
||||||
#pwm-cells = <3>;
|
#pwm-cells = <3>;
|
||||||
};
|
};
|
||||||
pwm3: pwm@f01805 {
|
pwm3: pwm@f01805 {
|
||||||
|
@ -1316,7 +1313,6 @@
|
||||||
label = "pwm_3";
|
label = "pwm_3";
|
||||||
status = "disabled";
|
status = "disabled";
|
||||||
pwmctrl = <&prs>;
|
pwmctrl = <&prs>;
|
||||||
pinctrl-0 = <&pinctrl_pwm3>; /* GPA3 */
|
|
||||||
#pwm-cells = <3>;
|
#pwm-cells = <3>;
|
||||||
};
|
};
|
||||||
pwm4: pwm@f01806 {
|
pwm4: pwm@f01806 {
|
||||||
|
@ -1329,7 +1325,6 @@
|
||||||
label = "pwm_4";
|
label = "pwm_4";
|
||||||
status = "disabled";
|
status = "disabled";
|
||||||
pwmctrl = <&prs>;
|
pwmctrl = <&prs>;
|
||||||
pinctrl-0 = <&pinctrl_pwm4>; /* GPA4 */
|
|
||||||
#pwm-cells = <3>;
|
#pwm-cells = <3>;
|
||||||
};
|
};
|
||||||
pwm5: pwm@f01807 {
|
pwm5: pwm@f01807 {
|
||||||
|
@ -1342,7 +1337,6 @@
|
||||||
label = "pwm_5";
|
label = "pwm_5";
|
||||||
status = "disabled";
|
status = "disabled";
|
||||||
pwmctrl = <&prs>;
|
pwmctrl = <&prs>;
|
||||||
pinctrl-0 = <&pinctrl_pwm5>; /* GPA5 */
|
|
||||||
#pwm-cells = <3>;
|
#pwm-cells = <3>;
|
||||||
};
|
};
|
||||||
pwm6: pwm@f01808 {
|
pwm6: pwm@f01808 {
|
||||||
|
@ -1355,7 +1349,6 @@
|
||||||
label = "pwm_6";
|
label = "pwm_6";
|
||||||
status = "disabled";
|
status = "disabled";
|
||||||
pwmctrl = <&prs>;
|
pwmctrl = <&prs>;
|
||||||
pinctrl-0 = <&pinctrl_pwm6>; /* GPA6 */
|
|
||||||
#pwm-cells = <3>;
|
#pwm-cells = <3>;
|
||||||
};
|
};
|
||||||
pwm7: pwm@f01809 {
|
pwm7: pwm@f01809 {
|
||||||
|
@ -1368,7 +1361,6 @@
|
||||||
label = "pwm_7";
|
label = "pwm_7";
|
||||||
status = "disabled";
|
status = "disabled";
|
||||||
pwmctrl = <&prs>;
|
pwmctrl = <&prs>;
|
||||||
pinctrl-0 = <&pinctrl_pwm7>; /* GPA7 */
|
|
||||||
#pwm-cells = <3>;
|
#pwm-cells = <3>;
|
||||||
};
|
};
|
||||||
tach0: tach@f0181e {
|
tach0: tach@f0181e {
|
||||||
|
|
|
@ -89,6 +89,32 @@
|
||||||
pinmuxs = <&pinctrla 5 IT8XXX2_ALT_FUNC_3>;
|
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 */
|
/* UART alternate function */
|
||||||
uart1_rx_gpb0_default: uart1_rx_gpb0_default {
|
uart1_rx_gpb0_default: uart1_rx_gpb0_default {
|
||||||
pinmuxs = <&pinctrlb 0 IT8XXX2_ALT_FUNC_3>;
|
pinmuxs = <&pinctrlb 0 IT8XXX2_ALT_FUNC_3>;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue