From: Thierry Reding <thierry.reding@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 23/23] ARM: tegra: Enable PCIe on Jetson TK1
Date: Wed, 27 Aug 2014 16:34:32 +0200 [thread overview]
Message-ID: <20140827143431.GD32243@ulmo> (raw)
In-Reply-To: <20140827132800.GA32243@ulmo>
On Wed, Aug 27, 2014 at 03:28:06PM +0200, Thierry Reding wrote:
> On Tue, Aug 26, 2014 at 03:54:50PM +0300, Tuomas Tynkkynen wrote:
> > On 18/08/14 10:16, Thierry Reding wrote:
> > [...]
> > > +static int as3722_gpio_direction_output(u8 gpio, u8 level)
> > > +{
> > > + u8 value;
> > > + int err;
> > > +
> > > + if (gpio > 7)
> > > + return -EINVAL;
> > > +
> > > + if (level == 0)
> > > + value = AS3722_GPIO_CONTROL_MODE_OUTPUT_VDDL;
> > > + else
> > > + value = AS3722_GPIO_CONTROL_MODE_OUTPUT_VDDH;
> > > +
> > > + err = as3722_write(AS3722_GPIO_CONTROL(gpio), value);
> > > + if (err) {
> > > + error("as3722: failed to configure GPIO#%u as output: %d\n",
> > > + gpio, err);
> > > + return err;
> > > + }
> > > +
> > > + err = as3722_gpio_set(gpio, level);
> > > + if (err < 0) {
> > > + error("as3722: failed to set GPIO#%u high: %d\n", gpio, err);
> > > + return err;
> > > + }
> > > +
> > > + return 0;
> > > +}
> >
> > This function doesn't work correctly if the GPIO was originally configured
> > as inverted and low, which GPIO#2 seems to be.
> > (as3722_read(AS3722_GPIO_CONTROL(2), &value) returns value == 0x87)...
>
> That should be equivalent to what we're setting but is a somewhat weird
> default. I guess the fact that we're inverting it and then changing the
> value to high in separate transactions makes the output flip twice.
>
> > > +
> > > +int tegra_pcie_board_init(void)
> > > +{
> > [...]
> > > +
> > > + err = as3722_gpio_direction_output(2, 1);
> > > + if (err < 0) {
> > > + error("as3722: failed to set GPIO#2 high: %d\n", err);
> > > + return err;
> > > + }
> > [...]
> >
> > On my board, this call results in UART corruption, like this:
> >
> > tegra-pcie: non-prefetchable memory: 0x13000000-0x20000000
> > tegra-pcie: prefetchable memory: 0x20000000-0x40000000
> > ??????b????b2x1, 1x1 configuration
> > ??5R?tegra-pcie: probing port 1, using 1 lanes
> >
> > Likely because GPIO#2 controls the +3.3V_LP0 rail, which powers the UART
> > level shifters. Commenting the function call out fixes the corruption and
> > PCI-E still works fine.
>
> If I add a udelay(500) after the above I'm not able to reproduce the
> UART breakage anymore. But I guess making the AS3722 GPIO code smarter
> would be helpful. In the kernel this is done by checking the invert bit
> and then setting the value accordingly. I suppose the same could be done
> for the mode bits. I'll see if I can work up a patch.
How about this:
-------------- next part --------------
diff --git a/drivers/power/as3722.c b/drivers/power/as3722.c
index 59d1bf1b50b0..393dc8608d07 100644
--- a/drivers/power/as3722.c
+++ b/drivers/power/as3722.c
@@ -17,6 +17,7 @@
#define AS3722_GPIO_CONTROL(n) (0x08 + (n))
#define AS3722_GPIO_CONTROL_MODE_OUTPUT_VDDH (1 << 0)
#define AS3722_GPIO_CONTROL_MODE_OUTPUT_VDDL (7 << 0)
+#define AS3722_GPIO_CONTROL_MODE_MASK (7 << 0)
#define AS3722_GPIO_CONTROL_INVERT (1 << 7)
#define AS3722_LDO_VOLTAGE(n) (0x10 + (n))
#define AS3722_GPIO_SIGNAL_OUT 0x20
@@ -220,10 +221,21 @@ int as3722_gpio_direction_output(struct as3722 *pmic, unsigned int gpio,
if (gpio > 7)
return -EINVAL;
+ err = as3722_read(pmic, AS3722_GPIO_CONTROL(gpio), &value);
+ if (err < 0) {
+ error("failed to read GPIO#%u control register: %d", gpio, err);
+ return err;
+ }
+
+ if (value & AS3722_GPIO_CONTROL_INVERT)
+ level = !level;
+
+ value &= ~AS3722_GPIO_CONTROL_MODE_MASK;
+
if (level == 0)
- value = AS3722_GPIO_CONTROL_MODE_OUTPUT_VDDL;
+ value |= AS3722_GPIO_CONTROL_MODE_OUTPUT_VDDL;
else
- value = AS3722_GPIO_CONTROL_MODE_OUTPUT_VDDH;
+ value |= AS3722_GPIO_CONTROL_MODE_OUTPUT_VDDH;
err = as3722_write(pmic, AS3722_GPIO_CONTROL(gpio), value);
if (err) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140827/e771d6cb/attachment.pgp>
next prev parent reply other threads:[~2014-08-27 14:34 UTC|newest]
Thread overview: 92+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-18 7:16 [U-Boot] [PATCH 00/23] ARM: tegra: Add PCIe support Thierry Reding
2014-08-18 7:16 ` [U-Boot] [PATCH 01/23] fdt: Add functions to query a node's #address- and #size-cells Thierry Reding
2014-08-18 17:52 ` Simon Glass
2014-08-19 10:59 ` Thierry Reding
2014-08-19 12:52 ` Simon Glass
2014-08-19 13:06 ` Thierry Reding
2014-08-23 3:03 ` Simon Glass
2014-08-23 11:26 ` Thierry Reding
2014-08-18 7:16 ` [U-Boot] [PATCH 02/23] fdt: Add a function to get the index of a string Thierry Reding
2014-08-18 17:58 ` Simon Glass
2014-08-19 11:13 ` Thierry Reding
2014-08-18 7:16 ` [U-Boot] [PATCH 03/23] fdt: Add resource parsing functions Thierry Reding
2014-08-18 18:06 ` Simon Glass
2014-08-19 11:35 ` Thierry Reding
2014-08-19 12:55 ` Simon Glass
2014-08-19 13:12 ` Thierry Reding
2014-08-19 21:28 ` Simon Glass
2014-08-20 6:36 ` Thierry Reding
2014-08-20 14:05 ` Simon Glass
2014-08-18 7:16 ` [U-Boot] [PATCH 04/23] fdt: Add a function to return PCI BDF triplet Thierry Reding
2014-08-18 18:20 ` Simon Glass
2014-08-18 7:16 ` [U-Boot] [PATCH 05/23] fdt: Add a subnodes iterator macro Thierry Reding
2014-08-18 18:11 ` Simon Glass
2014-08-19 12:22 ` Thierry Reding
2014-08-19 12:57 ` Simon Glass
2014-08-19 13:12 ` Thierry Reding
2014-08-18 7:16 ` [U-Boot] [PATCH 06/23] pci: Abort early if bus does not exist Thierry Reding
2014-08-18 7:16 ` [U-Boot] [PATCH 07/23] pci: Honour pci_skip_dev() Thierry Reding
2014-08-18 7:16 ` [U-Boot] [PATCH 08/23] Add pr_fmt() macro Thierry Reding
2014-08-18 18:24 ` Simon Glass
2014-08-19 12:27 ` Thierry Reding
2014-08-19 12:58 ` Simon Glass
2014-08-18 7:16 ` [U-Boot] [PATCH 09/23] ARM: tegra: Implement tegra_plle_enable() Thierry Reding
2014-08-20 18:12 ` Stephen Warren
2014-08-18 7:16 ` [U-Boot] [PATCH 10/23] ARM: tegra: Provide PCIEXCLK reset ID Thierry Reding
2014-08-20 18:20 ` Stephen Warren
2014-08-22 12:38 ` Thierry Reding
2014-08-18 7:16 ` [U-Boot] [PATCH 11/23] ARM: tegra: Implement powergate support Thierry Reding
2014-08-20 18:24 ` Stephen Warren
2014-08-22 13:54 ` Thierry Reding
2014-08-18 7:16 ` [U-Boot] [PATCH 12/23] ARM: tegra: Implement XUSB pad controller Thierry Reding
2014-08-20 18:32 ` Stephen Warren
2014-08-22 14:11 ` Thierry Reding
2014-08-22 14:38 ` Thierry Reding
2014-08-18 7:16 ` [U-Boot] [PATCH 13/23] ARM: tegra: Add XUSB pad controller on Tegra124 Thierry Reding
2014-08-20 18:33 ` Stephen Warren
2014-08-18 7:16 ` [U-Boot] [PATCH 14/23] ARM: tegra: Enable XUSB pad controller on Jetson TK1 Thierry Reding
2014-08-20 18:34 ` Stephen Warren
2014-08-18 7:16 ` [U-Boot] [PATCH 15/23] pci: tegra: Add Tegra PCIe driver Thierry Reding
2014-08-20 19:04 ` Stephen Warren
2014-08-22 15:24 ` Thierry Reding
2014-08-22 17:33 ` Stephen Warren
2014-08-22 19:41 ` Thierry Reding
2014-08-18 7:16 ` [U-Boot] [PATCH 16/23] ARM: tegra: Add Tegra20 PCIe device tree node Thierry Reding
2014-08-20 18:37 ` Stephen Warren
2014-08-18 7:16 ` [U-Boot] [PATCH 17/23] ARM: tegra: Enable PCIe on TrimSlice Thierry Reding
2014-08-20 18:38 ` Stephen Warren
2014-08-22 14:44 ` Thierry Reding
2014-08-18 7:16 ` [U-Boot] [PATCH 18/23] ARM: tegra: Add Tegra30 PCIe device tree node Thierry Reding
2014-08-20 18:39 ` Stephen Warren
2014-08-22 14:51 ` Thierry Reding
2014-08-18 7:16 ` [U-Boot] [PATCH 19/23] ARM: tegra: Enable PCIe on Beaver Thierry Reding
2014-08-19 13:48 ` Marcel Ziswiler
2014-08-20 6:38 ` Thierry Reding
2014-08-20 8:56 ` Marcel Ziswiler
2014-08-20 9:46 ` Thierry Reding
2014-08-20 13:13 ` Marcel Ziswiler
2014-08-20 18:43 ` Stephen Warren
2014-08-22 12:33 ` Thierry Reding
2014-08-18 7:16 ` [U-Boot] [PATCH 20/23] ARM: tegra: Enable PCIe on Cardhu Thierry Reding
2014-08-18 7:16 ` [U-Boot] [PATCH 21/23] ARM: tegra: Add GIC for Tegra124 Thierry Reding
2014-08-20 18:45 ` Stephen Warren
2014-08-18 7:16 ` [U-Boot] [PATCH 22/23] ARM: tegra: Add Tegra124 PCIe device tree node Thierry Reding
2014-08-20 18:46 ` Stephen Warren
2014-08-18 7:16 ` [U-Boot] [PATCH 23/23] ARM: tegra: Enable PCIe on Jetson TK1 Thierry Reding
2014-08-18 18:37 ` Simon Glass
2014-08-19 12:29 ` Thierry Reding
2014-08-19 13:07 ` Simon Glass
2014-08-20 18:51 ` Stephen Warren
2014-08-22 12:09 ` Thierry Reding
2014-08-22 18:50 ` Stephen Warren
2014-08-22 19:27 ` Simon Glass
2014-08-22 19:40 ` Thierry Reding
2014-08-22 20:12 ` Simon Glass
2014-08-22 22:03 ` Thierry Reding
2014-08-23 1:47 ` Simon Glass
2014-08-23 11:33 ` Thierry Reding
2014-08-20 18:54 ` Stephen Warren
2014-08-26 12:54 ` Tuomas Tynkkynen
2014-08-27 13:28 ` Thierry Reding
2014-08-27 14:34 ` Thierry Reding [this message]
2014-08-27 16:52 ` Tuomas Tynkkynen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140827143431.GD32243@ulmo \
--to=thierry.reding@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox