Skip to content

Commit

Permalink
drivers: emios_pwm: do not configure period, duty and polarity at boot
Browse files Browse the repository at this point in the history
Removing period, duty and polarity configuration from
channel devicetree. At boot time, only minimal setup like
pinctrl, prescaler, etc should be initialized. PWM signal
is produced by using pwm_set* API

Also after this change, PWM period, duty are changed at the
next counter period boundary

Signed-off-by: Dat Nguyen Duy <[email protected]>
  • Loading branch information
Dat-NguyenDuy authored and kartben committed Jan 18, 2025
1 parent 576b27a commit e72af32
Show file tree
Hide file tree
Showing 6 changed files with 318 additions and 267 deletions.
27 changes: 0 additions & 27 deletions boards/nxp/mr_canhubk3/mr_canhubk3.dts
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,6 @@
emios0_bus_a {
mode = "MCB_UP_COUNTER";
prescaler = <16>;
period = <1000>;
status = "okay";
};
};
Expand All @@ -513,63 +512,43 @@
pwm_0 {
channel = <0>;
pwm-mode = "OPWFMB";
period = <65535>;
duty-cycle = <0>;
prescaler = <8>;
polarity = "ACTIVE_HIGH";
};

pwm_1 {
channel = <1>;
pwm-mode = "OPWFMB";
period = <65535>;
duty-cycle = <0>;
prescaler = <8>;
polarity = "ACTIVE_HIGH";
};

pwm_2 {
channel = <2>;
pwm-mode = "OPWFMB";
period = <65535>;
duty-cycle = <0>;
prescaler = <8>;
polarity = "ACTIVE_HIGH";
};

pwm_3 {
channel = <3>;
pwm-mode = "OPWFMB";
period = <65535>;
duty-cycle = <0>;
prescaler = <8>;
polarity = "ACTIVE_HIGH";
};

pwm_4 {
channel = <4>;
pwm-mode = "OPWFMB";
period = <65535>;
duty-cycle = <0>;
prescaler = <8>;
polarity = "ACTIVE_HIGH";
};

pwm_5 {
channel = <5>;
pwm-mode = "OPWFMB";
period = <65535>;
duty-cycle = <0>;
prescaler = <8>;
polarity = "ACTIVE_HIGH";
};

rgb_red {
channel = <19>;
master-bus = <&emios0_bus_a>;
duty-cycle = <0>;
pwm-mode = "OPWMB";
polarity = "ACTIVE_LOW";
};
};
};
Expand All @@ -586,14 +565,12 @@
emios1_bus_a {
prescaler = <16>;
mode = "MCB_UP_COUNTER";
period = <1000>;
status = "okay";
};

emios1_bus_f {
prescaler = <16>;
mode = "MCB_UP_COUNTER";
period = <1000>;
status = "okay";
};
};
Expand All @@ -606,17 +583,13 @@
rgb_green {
channel = <10>;
master-bus = <&emios1_bus_a>;
duty-cycle = <0>;
pwm-mode = "OPWMB";
polarity = "ACTIVE_LOW";
};

rgb_blue {
channel = <5>;
master-bus = <&emios1_bus_f>;
duty-cycle = <0>;
pwm-mode = "OPWMB";
polarity = "ACTIVE_LOW";
};
};
};
Expand Down
9 changes: 1 addition & 8 deletions drivers/misc/nxp_s32_emios/nxp_s32_emios.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,17 @@ static int nxp_s32_emios_init(const struct device *dev)
.enableGlobalTimeBase = true \
};

#define NXP_S32_EMIOS_MASTER_BUS_VERIFY(node_id) \
BUILD_ASSERT(IN_RANGE(DT_PROP(node_id, period), \
MIN_MASTER_BUS_PERIOD, MAX_MASTER_BUS_PERIOD), \
"Node "DT_NODE_PATH(node_id)": period is out of range");

#define NXP_S32_EMIOS_MASTER_BUS_CONFIG(node_id) \
{ \
.hwChannel = DT_PROP(node_id, channel), \
.defaultPeriod = DT_PROP(node_id, period), \
.defaultPeriod = MAX_MASTER_BUS_PERIOD, \
.masterBusPrescaler = DT_PROP(node_id, prescaler) - 1, \
.allowDebugMode = DT_PROP(node_id, freeze), \
.masterMode = NXP_S32_EMIOS_MASTER_BUS_MODE(DT_STRING_TOKEN(node_id, mode)), \
.masterBusAltPrescaler = 0, \
},

#define NXP_S32_EMIOS_GENERATE_MASTER_BUS_CONFIG(n) \
DT_FOREACH_CHILD_STATUS_OKAY(DT_INST_CHILD(n, master_bus), \
NXP_S32_EMIOS_MASTER_BUS_VERIFY) \
const Emios_Ip_MasterBusConfigType nxp_s32_emios_##n##_master_bus_config[] = { \
DT_FOREACH_CHILD_STATUS_OKAY(DT_INST_CHILD(n, master_bus), \
NXP_S32_EMIOS_MASTER_BUS_CONFIG) \
Expand Down
Loading

0 comments on commit e72af32

Please sign in to comment.