Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F177470997
D60882.1794504919.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
4 KB
Referenced Files
None
Subscribers
None
D60882.1794504919.diff
View Options
Index: sys/arm/allwinner/a64/a64_padconf.c
===================================================================
--- sys/arm/allwinner/a64/a64_padconf.c
+++ sys/arm/allwinner/a64/a64_padconf.c
@@ -86,7 +86,7 @@
{ "PD19", 3, 19, { "gpio_in", "gpio_out", "lcd", "lvds", "emac" } },
{ "PD20", 3, 20, { "gpio_in", "gpio_out", "lcd", "lvds", "emac" } },
{ "PD21", 3, 21, { "gpio_in", "gpio_out", "lcd", "lvds", "emac" } },
- { "PD22", 3, 22, { "gpio_in", "gpio_out", "pwm0", NULL, "emac" } },
+ { "PD22", 3, 22, { "gpio_in", "gpio_out", "pwm", NULL, "emac" } },
{ "PD23", 3, 23, { "gpio_in", "gpio_out", NULL, NULL, "emac" } },
{ "PD24", 3, 24, { "gpio_in", "gpio_out" } },
Index: sys/dev/pwm/controller/allwinner/aw_pwm.c
===================================================================
--- sys/dev/pwm/controller/allwinner/aw_pwm.c
+++ sys/dev/pwm/controller/allwinner/aw_pwm.c
@@ -267,11 +267,12 @@
* duty are near 1 second. In some cases period_freq and duty_freq can
* be equal even if the period and the duty are significantly different.
*/
- duty_freq = NS_PER_SEC / duty;
- if (duty_freq < period_freq) {
+ if (duty > period) {
device_printf(sc->dev, "duty < period\n");
return (EINVAL);
}
+ /* A zero duty cycle (output fully inactive) has no frequency */
+ duty_freq = duty != 0 ? NS_PER_SEC / duty : 0;
/* First test without prescaler */
clk_rate = AW_PWM_MAX_FREQ;
@@ -309,7 +310,8 @@
/* Write the total/active cycles */
reg = ((clk_rate / period_freq - 1) << AW_PWM_PERIOD_TOTAL_SHIFT) |
- ((clk_rate / duty_freq) << AW_PWM_PERIOD_ACTIVE_SHIFT);
+ ((duty_freq != 0 ? clk_rate / duty_freq : 0) <<
+ AW_PWM_PERIOD_ACTIVE_SHIFT);
AW_PWM_WRITE(sc, AW_PWM_PERIOD, reg);
sc->period = period;
Index: sys/dev/pwm/pwm_backlight.c
===================================================================
--- sys/dev/pwm/pwm_backlight.c
+++ sys/dev/pwm/pwm_backlight.c
@@ -32,6 +32,7 @@
#include <sys/conf.h>
#include <sys/endian.h>
#include <sys/fcntl.h>
+#include <sys/gpio.h>
#include <sys/ioccom.h>
#include <sys/kernel.h>
#include <sys/kthread.h>
@@ -47,6 +48,8 @@
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
+#include <dev/gpio/gpiobusvar.h>
+
#include <dev/regulator/regulator.h>
#include <dev/backlight/backlight.h>
@@ -67,6 +70,7 @@
ssize_t current_level;
regulator_t power_supply;
+ gpio_pin_t enable_gpio;
uint64_t period;
uint64_t duty;
bool enabled;
@@ -112,6 +116,13 @@
return (ENXIO);
}
+ /* enable-gpios is optional */
+ if (gpio_pin_get_by_ofw_property(dev, node, "enable-gpios",
+ &sc->enable_gpio) == 0)
+ gpio_pin_setflags(sc->enable_gpio, GPIO_PIN_OUTPUT);
+ else
+ sc->enable_gpio = NULL;
+
if (OF_hasprop(node, "brightness-levels")) {
sc->nlevels = OF_getencprop_alloc(node, "brightness-levels",
(void **)&sc->levels);
@@ -154,13 +165,22 @@
regulator_enable(sc->power_supply);
sc->channel->enabled = true;
+ PWMBUS_CHANNEL_SET_FLAGS(sc->channel->dev, sc->channel->channel,
+ sc->channel->flags);
PWMBUS_CHANNEL_CONFIG(sc->channel->dev, sc->channel->channel,
sc->channel->period, sc->channel->duty);
PWMBUS_CHANNEL_ENABLE(sc->channel->dev, sc->channel->channel,
sc->channel->enabled);
-
- sc->current_level = pwm_backlight_find_level_per_percent(sc,
- sc->channel->period / sc->channel->duty);
+ if (sc->enable_gpio != NULL)
+ gpio_pin_set_active(sc->enable_gpio, true);
+
+ /*
+ * The level just programmed is the default one. Deriving it from
+ * the duty cycle divided the period by the duty (always 1 or 2),
+ * which reported level 0 and made backlight(4) drop a first
+ * "backlight 0" as a no-op.
+ */
+ sc->current_level = sc->default_level;
sc->cdev = backlight_register("pwm_backlight", dev);
if (sc->cdev == NULL)
device_printf(dev, "Cannot register as a backlight\n");
@@ -176,6 +196,10 @@
sc = device_get_softc(dev);
if (sc->nlevels > 0)
OF_prop_free(sc->levels);
+ if (sc->enable_gpio != NULL) {
+ gpio_pin_set_active(sc->enable_gpio, false);
+ gpio_pin_release(sc->enable_gpio);
+ }
regulator_disable(sc->power_supply);
backlight_destroy(sc->cdev);
return (0);
@@ -247,6 +271,8 @@
regulator_disable(sc->power_supply);
}
}
+ if (sc->enable_gpio != NULL)
+ gpio_pin_set_active(sc->enable_gpio, props->brightness > 0);
return (0);
}
Index: sys/modules/pwm/pwm_backlight/Makefile
===================================================================
--- sys/modules/pwm/pwm_backlight/Makefile
+++ sys/modules/pwm/pwm_backlight/Makefile
@@ -6,6 +6,7 @@
backlight_if.h \
bus_if.h \
device_if.h \
+ gpio_if.h \
opt_platform.h \
pwmbus_if.h \
regnode_if.h \
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 12, 5:35 PM (8 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41680257
Default Alt Text
D60882.1794504919.diff (4 KB)
Attached To
Mode
D60882: [PATCH 7/7] aw_gpio: report pinctrl configuration failures
Attached
Detach File
Event Timeline