[v2,7/7] rpi: Force skip_init on serial devices

Message ID 20180117085458.27293-8-agraf@suse.de
State New
Headers show
Series
  • RPi: Properly handle dynamic serial configuration
Related show

Commit Message

Alexander Graf Jan. 17, 2018, 8:54 a.m.
The serial devices on the raspberry pi are based on clocks we can't easily
read and influence in U-Boot. However, the serial devices are always already
properly set up when coming up, so all we need to do is leave them alone.

The way to do that is to specify "skip-init" in device tree usually, but
if we set CONFIG_OF_BOARD to get the device tree from the RPi firmware,
that does not have skip-init properly set.

So instead we just force it in board specific code. That way serial devices
also work fine when skip-init is not passed explicitly in DT.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 board/raspberrypi/rpi/rpi.c        | 7 +++++++
 drivers/serial/serial_bcm283x_mu.c | 2 +-
 drivers/serial/serial_pl01x.c      | 2 +-
 3 files changed, 9 insertions(+), 2 deletions(-)

Comments

Simon Glass Jan. 17, 2018, 7:40 p.m. | #1
Hi Alex,

On 17 January 2018 at 00:54, Alexander Graf <agraf@suse.de> wrote:
> The serial devices on the raspberry pi are based on clocks we can't easily
> read and influence in U-Boot. However, the serial devices are always already
> properly set up when coming up, so all we need to do is leave them alone.
>
> The way to do that is to specify "skip-init" in device tree usually, but
> if we set CONFIG_OF_BOARD to get the device tree from the RPi firmware,
> that does not have skip-init properly set.
>
> So instead we just force it in board specific code. That way serial devices
> also work fine when skip-init is not passed explicitly in DT.
>
> Signed-off-by: Alexander Graf <agraf@suse.de>
> ---
>  board/raspberrypi/rpi/rpi.c        | 7 +++++++
>  drivers/serial/serial_bcm283x_mu.c | 2 +-
>  drivers/serial/serial_pl01x.c      | 2 +-
>  3 files changed, 9 insertions(+), 2 deletions(-)

Would you mind converting these drivers to livetree before adding these patches?

Regards,
Simon
Alexander Graf Jan. 17, 2018, 10:08 p.m. | #2
On 17.01.18 20:40, Simon Glass wrote:
> Hi Alex,
> 
> On 17 January 2018 at 00:54, Alexander Graf <agraf@suse.de> wrote:
>> The serial devices on the raspberry pi are based on clocks we can't easily
>> read and influence in U-Boot. However, the serial devices are always already
>> properly set up when coming up, so all we need to do is leave them alone.
>>
>> The way to do that is to specify "skip-init" in device tree usually, but
>> if we set CONFIG_OF_BOARD to get the device tree from the RPi firmware,
>> that does not have skip-init properly set.
>>
>> So instead we just force it in board specific code. That way serial devices
>> also work fine when skip-init is not passed explicitly in DT.
>>
>> Signed-off-by: Alexander Graf <agraf@suse.de>
>> ---
>>  board/raspberrypi/rpi/rpi.c        | 7 +++++++
>>  drivers/serial/serial_bcm283x_mu.c | 2 +-
>>  drivers/serial/serial_pl01x.c      | 2 +-
>>  3 files changed, 9 insertions(+), 2 deletions(-)
> 
> Would you mind converting these drivers to livetree before adding these patches?

Uh, why? I don't quite see how it's related - and I'm not sure I'll make
the rc1 cut-off even with just the pile I have right now :)


Alex
Simon Glass Jan. 17, 2018, 11:18 p.m. | #3
Hi Alex,

On 17 January 2018 at 15:08, Alexander Graf <agraf@suse.de> wrote:
>
>
> On 17.01.18 20:40, Simon Glass wrote:
>> Hi Alex,
>>
>> On 17 January 2018 at 00:54, Alexander Graf <agraf@suse.de> wrote:
>>> The serial devices on the raspberry pi are based on clocks we can't easily
>>> read and influence in U-Boot. However, the serial devices are always already
>>> properly set up when coming up, so all we need to do is leave them alone.
>>>
>>> The way to do that is to specify "skip-init" in device tree usually, but
>>> if we set CONFIG_OF_BOARD to get the device tree from the RPi firmware,
>>> that does not have skip-init properly set.
>>>
>>> So instead we just force it in board specific code. That way serial devices
>>> also work fine when skip-init is not passed explicitly in DT.
>>>
>>> Signed-off-by: Alexander Graf <agraf@suse.de>
>>> ---
>>>  board/raspberrypi/rpi/rpi.c        | 7 +++++++
>>>  drivers/serial/serial_bcm283x_mu.c | 2 +-
>>>  drivers/serial/serial_pl01x.c      | 2 +-
>>>  3 files changed, 9 insertions(+), 2 deletions(-)
>>
>> Would you mind converting these drivers to livetree before adding these patches?
>
> Uh, why? I don't quite see how it's related - and I'm not sure I'll make
> the rc1 cut-off even with just the pile I have right now :)

I'm trying to make sure that people that touch drivers convert them,
since otherwise it won't get done. I hope we can accept v2/v3 patches
which just miss rc1.

Regards,
Simon

Patch

diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
index b0cdad70f7..ce1286a53a 100644
--- a/board/raspberrypi/rpi/rpi.c
+++ b/board/raspberrypi/rpi/rpi.c
@@ -20,6 +20,7 @@ 
 #include <asm/arch/sdhci.h>
 #include <asm/global_data.h>
 #include <dm/platform_data/serial_bcm283x_mu.h>
+#include <dm/platform_data/serial_pl01x.h>
 #ifdef CONFIG_ARM64
 #include <asm/armv8/mmu.h>
 #endif
@@ -472,9 +473,15 @@  int board_check_serial(struct udevice *dev)
 	printf("Checking serial %s\n", dev->name);
 
 	if (device_is_compatible(dev, "arm,pl011")) {
+		struct pl01x_serial_platdata *plat = dev_get_platdata(dev);
+
 		func = BCM2835_GPIO_ALT0;
+		plat->skip_init = true;
 	} else if (device_is_compatible(dev, "brcm,bcm2835-aux-uart")) {
+		struct bcm283x_mu_serial_platdata *plat = dev_get_platdata(dev);
+
 		func = BCM2835_GPIO_ALT5;
+		plat->skip_init = true;
 	} else {
 		return 0;
 	}
diff --git a/drivers/serial/serial_bcm283x_mu.c b/drivers/serial/serial_bcm283x_mu.c
index 7ce990b9b8..8a7ca75d4a 100644
--- a/drivers/serial/serial_bcm283x_mu.c
+++ b/drivers/serial/serial_bcm283x_mu.c
@@ -151,7 +151,7 @@  static int bcm283x_mu_serial_ofdata_to_platdata(struct udevice *dev)
 	plat->base = addr;
 	plat->clock = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "clock",
 				     1);
-	plat->skip_init = fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
+	plat->skip_init |= fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
 	                                  "skip-init");
 	return 0;
 }
diff --git a/drivers/serial/serial_pl01x.c b/drivers/serial/serial_pl01x.c
index 4ec0f29c42..f957eddc07 100644
--- a/drivers/serial/serial_pl01x.c
+++ b/drivers/serial/serial_pl01x.c
@@ -357,7 +357,7 @@  static int pl01x_serial_ofdata_to_platdata(struct udevice *dev)
 	plat->clock = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "clock",
 				     1);
 	plat->type = dev_get_driver_data(dev);
-	plat->skip_init = fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
+	plat->skip_init |= fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
 	                                  "skip-init");
 	return 0;
 }