summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpio/mpc8xxx_gpio.c12
-rw-r--r--drivers/timer/mpc83xx_timer.c2
2 files changed, 12 insertions, 2 deletions
diff --git a/drivers/gpio/mpc8xxx_gpio.c b/drivers/gpio/mpc8xxx_gpio.c
index e9bd38f162c..709d04017d1 100644
--- a/drivers/gpio/mpc8xxx_gpio.c
+++ b/drivers/gpio/mpc8xxx_gpio.c
@@ -204,7 +204,17 @@ static int mpc8xxx_gpio_plat_to_priv(struct udevice *dev)
return -ENOMEM;
priv->gpio_count = plat->ngpios;
- priv->dat_shadow = 0;
+
+ /*
+ * On platforms that do support reading back output values, we want to
+ * try preserving them, so that we don't accidentally set unrelated
+ * GPIOs to zero in mpc8xxx_gpio_set_value.
+ */
+ if (priv->little_endian)
+ priv->dat_shadow = in_le32(&priv->base->gpdat) & in_le32(&priv->base->gpdir);
+ else
+ priv->dat_shadow = in_be32(&priv->base->gpdat) & in_be32(&priv->base->gpdir);
+
priv->type = driver_data;
diff --git a/drivers/timer/mpc83xx_timer.c b/drivers/timer/mpc83xx_timer.c
index 9da74479aaa..f92009e4ccc 100644
--- a/drivers/timer/mpc83xx_timer.c
+++ b/drivers/timer/mpc83xx_timer.c
@@ -206,7 +206,7 @@ static u64 mpc83xx_timer_get_count(struct udevice *dev)
tbl = mftb();
} while (tbu != mftbu());
- return (tbu * 0x10000ULL) + tbl;
+ return (uint64_t)tbu << 32 | tbl;
}
static int mpc83xx_timer_probe(struct udevice *dev)