public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 5/7] rpi: Properly detect which serial device is active
Date: Wed, 17 Jan 2018 23:05:31 +0100	[thread overview]
Message-ID: <8586d9ab-18cb-e0a9-0aca-92bc10817931@suse.de> (raw)
In-Reply-To: <CAPnjgZ1N5Swo89H-4-pburaxGa0gEehZXNHbe9p+2H8uDBGLSQ@mail.gmail.com>



On 17.01.18 20:46, Simon Glass wrote:
> Hi Alex,
> 
> On 17 January 2018 at 00:54, Alexander Graf <agraf@suse.de> wrote:
>> Now that we have all infrastructure in place to dynamically determine whether
>> a serial device is actually usable (read: routed to user accessible pins), we
>> can wire it up to the board.
>>
>> This patch adds support to determine whether the pl011 or mini-uart or no serial
>> is routed to the UART RX/TX pins on the Raspberry Pi family of boards.
>>
>> Signed-off-by: Alexander Graf <agraf@suse.de>
>> ---
>>  board/raspberrypi/rpi/rpi.c | 69 +++++++++++++++++++++++++++++++++++++++++++++
>>  1 file changed, 69 insertions(+)
>>
>> diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
>> index a96d5d8952..b0cdad70f7 100644
>> --- a/board/raspberrypi/rpi/rpi.c
>> +++ b/board/raspberrypi/rpi/rpi.c
>> @@ -24,9 +24,16 @@
>>  #include <asm/armv8/mmu.h>
>>  #endif
>>  #include <watchdog.h>
>> +#include <asm/io.h>
>>
>>  DECLARE_GLOBAL_DATA_PTR;
>>
>> +/*
>> + * This is the GPIO pin that the user facing UART RX line is attached to.
>> + * We use this pin to determine which serial device is available.
>> + */
>> +#define BCM2835_GPIO_RX                15
>> +
>>  /* From lowlevel_init.S */
>>  extern unsigned long fw_dtb_pointer;
>>
>> @@ -419,6 +426,68 @@ static void get_board_rev(void)
>>         printf("RPI %s (0x%x)\n", model->name, revision);
>>  }
>>
>> +/*
>> + * We may get called before the device model is initialized, so we can not
>> + * rely on the GPIO driver.
>> + */
>> +int get_func_id(unsigned gpio)
>> +{
>> +       u32 val;
>> +       u32 node;
>> +       u32 *gpfsel;
>> +       fdt_addr_t addr;
>> +       fdt_size_t size;
>> +
>> +       node = fdt_node_offset_by_compatible(gd->fdt_blob, -1, "brcm,bcm2835-gpio");
>> +       if (node < 0)
>> +               return -EINVAL;
>> +
>> +       addr = fdtdec_get_addr_size_auto_noparent(gd->fdt_blob, node, "reg",
>> +                                                 0, &size, true);
>> +       gpfsel = (void*)addr;
>> +
>> +       val = readl(&gpfsel[BCM2835_GPIO_FSEL_BANK(gpio)]);
>> +
>> +       return (val >> BCM2835_GPIO_FSEL_SHIFT(gpio) & BCM2835_GPIO_FSEL_MASK);
>> +}
> 
> Ick, this should be done in the GPIO driver and use gpio_get_function().

Yes, but what if users specify the serial device to be pre-reloc and
don't do that for the GPIO (or really pinctrl) one? Then we'd not have
the driver around to determine whether serial is active, right?


Alex

  reply	other threads:[~2018-01-17 22:05 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-17  8:54 [U-Boot] [PATCH v2 0/7] RPi: Properly handle dynamic serial configuration Alexander Graf
2018-01-17  8:54 ` [U-Boot] [PATCH v2 1/7] serial: Use next serial device if probing fails Alexander Graf
2018-01-17 10:54   ` Heinrich Schuchardt
2018-01-17 19:34   ` Simon Glass
2018-01-17 22:02     ` Alexander Graf
2018-01-17  8:54 ` [U-Boot] [PATCH v2 2/7] serial: Allow boards to determine whether a serial device is usable Alexander Graf
2018-01-17 19:39   ` Simon Glass
2018-01-17 22:03     ` Alexander Graf
2018-01-17 22:11       ` Simon Glass
2018-01-17 22:37         ` Alexander Graf
2018-01-17 23:18           ` Simon Glass
2018-01-17  8:54 ` [U-Boot] [PATCH v2 3/7] rpi: Remove runtime disabling support for serial Alexander Graf
2018-01-17  8:54 ` [U-Boot] [PATCH v2 4/7] serial: bcm283x_mu: Remove support for post-init disabling Alexander Graf
2018-01-17  8:54 ` [U-Boot] [PATCH v2 5/7] rpi: Properly detect which serial device is active Alexander Graf
2018-01-17 19:46   ` Simon Glass
2018-01-17 22:05     ` Alexander Graf [this message]
2018-01-17 23:18       ` Simon Glass
2018-01-17  8:54 ` [U-Boot] [PATCH v2 6/7] rpi: Determine PL011/Mini-UART availability at runtime Alexander Graf
2018-01-17  8:54 ` [U-Boot] [PATCH v2 7/7] rpi: Force skip_init on serial devices Alexander Graf
2018-01-17 19:40   ` Simon Glass
2018-01-17 22:08     ` Alexander Graf
2018-01-17 23:18       ` Simon Glass

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=8586d9ab-18cb-e0a9-0aca-92bc10817931@suse.de \
    --to=agraf@suse.de \
    --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