diff mbox

[U-Boot,v4,5/8] arm: serial: Add ability to use pre-initialized UARTs

Message ID 1439900811-22954-6-git-send-email-s.temerkhanov@gmail.com
State Changes Requested
Delegated to: Tom Rini
Headers show

Commit Message

Sergey Temerkhanov Aug. 18, 2015, 12:26 p.m. UTC
On some systems, UART initialization is performed before running U-Boot.
This commit allows to skip UART re-initializaion on those systems

Signed-off-by: Sergey Temerkhanov <s.temerkhanov@gmail.com>
Signed-off-by: Radha Mohan Chintakuntla <rchintakuntla@cavium.com>

---

Changes in v4:
- Fixed build warnings
- Moved to DM_SERIAL

Changes in v3:
- Added __used keyword

Changes in v2: None

 drivers/serial/serial_pl01x.c           | 12 ++++++------
 include/dm/platform_data/serial_pl01x.h |  6 ++++++
 2 files changed, 12 insertions(+), 6 deletions(-)

Comments

Simon Glass Aug. 22, 2015, 12:36 a.m. UTC | #1
Hi Serkey,

On 18 August 2015 at 06:26, Sergey Temerkhanov <s.temerkhanov@gmail.com> wrote:
> On some systems, UART initialization is performed before running U-Boot.
> This commit allows to skip UART re-initializaion on those systems
>
> Signed-off-by: Sergey Temerkhanov <s.temerkhanov@gmail.com>
> Signed-off-by: Radha Mohan Chintakuntla <rchintakuntla@cavium.com>
>
> ---
>
> Changes in v4:
> - Fixed build warnings
> - Moved to DM_SERIAL
>
> Changes in v3:
> - Added __used keyword
>
> Changes in v2: None
>
>  drivers/serial/serial_pl01x.c           | 12 ++++++------
>  include/dm/platform_data/serial_pl01x.h |  6 ++++++
>  2 files changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/serial/serial_pl01x.c b/drivers/serial/serial_pl01x.c
> index ad503af..037fd23 100644
> --- a/drivers/serial/serial_pl01x.c
> +++ b/drivers/serial/serial_pl01x.c
> @@ -125,7 +125,7 @@ static int pl011_set_line_control(struct pl01x_regs *regs)
>  }
>
>  static int pl01x_generic_setbrg(struct pl01x_regs *regs, enum pl01x_type type,
> -                               int clock, int baudrate)
> +                                      int clock, int baudrate)
>  {
>         switch (type) {
>         case TYPE_PL010: {
> @@ -295,7 +295,6 @@ __weak struct serial_device *default_serial_console(void)
>  #endif /* nCONFIG_DM_SERIAL */
>
>  #ifdef CONFIG_DM_SERIAL
> -
>  struct pl01x_priv {
>         struct pl01x_regs *regs;
>         enum pl01x_type type;
> @@ -306,9 +305,9 @@ static int pl01x_serial_setbrg(struct udevice *dev, int baudrate)
>         struct pl01x_serial_platdata *plat = dev_get_platdata(dev);
>         struct pl01x_priv *priv = dev_get_priv(dev);
>
> -       pl01x_generic_setbrg(priv->regs, priv->type, plat->clock, baudrate);
> -
> -       return 0;
> +       return (plat->flags & PL0x_PREINITIALIZED) ? 0 :
> +               pl01x_generic_setbrg(priv->regs, priv->type,
> +                                    plat->clock, baudrate);
>  }
>
>  static int pl01x_serial_probe(struct udevice *dev)
> @@ -318,7 +317,8 @@ static int pl01x_serial_probe(struct udevice *dev)
>
>         priv->regs = (struct pl01x_regs *)plat->base;
>         priv->type = plat->type;
> -       return pl01x_generic_serial_init(priv->regs, priv->type);
> +       return (plat->flags & PL0x_PREINITIALIZED) ? 0 :
> +               pl01x_generic_serial_init(priv->regs, priv->type);
>  }
>
>  static int pl01x_serial_getc(struct udevice *dev)
> diff --git a/include/dm/platform_data/serial_pl01x.h b/include/dm/platform_data/serial_pl01x.h
> index 5e068f3..455121b 100644
> --- a/include/dm/platform_data/serial_pl01x.h
> +++ b/include/dm/platform_data/serial_pl01x.h
> @@ -11,17 +11,23 @@ enum pl01x_type {
>         TYPE_PL011,
>  };
>
> +enum pl01x_flags {
> +       PL0x_PREINITIALIZED = 1 << 0, /* Skip port initialization */
> +};
> +
>  /*
>   *Information about a serial port
>   *
>   * @base: Register base address
>   * @type: Port type
>   * @clock: Input clock rate, used for calculating the baud rate divisor
> + * @flags: Port flags
>   */
>  struct pl01x_serial_platdata {
>         unsigned long base;
>         enum pl01x_type type;
>         unsigned int clock;
> +       unsigned long flags;
>  };
>
>  #endif

This patch is fine as far as it goes (although the x in
PL0x_PREINITIALIZED should be capitalised to match style I think).

But why doesn't this board use device tree (CONFIG_OF_CONTROL)? Do you
have a device tree file for it?

Regards,
Simon
Sergey Temerkhanov Sept. 7, 2015, 10:20 a.m. UTC | #2
On Sat, Aug 22, 2015 at 3:36 AM, Simon Glass <sjg@chromium.org> wrote:
> Hi Serkey,
>
> On 18 August 2015 at 06:26, Sergey Temerkhanov <s.temerkhanov@gmail.com> wrote:
>> On some systems, UART initialization is performed before running U-Boot.
>> This commit allows to skip UART re-initializaion on those systems
>>
>> Signed-off-by: Sergey Temerkhanov <s.temerkhanov@gmail.com>
>> Signed-off-by: Radha Mohan Chintakuntla <rchintakuntla@cavium.com>
>>
>> ---
>>
>> Changes in v4:
>> - Fixed build warnings
>> - Moved to DM_SERIAL
>>
>> Changes in v3:
>> - Added __used keyword
>>
>> Changes in v2: None
>>
>>  drivers/serial/serial_pl01x.c           | 12 ++++++------
>>  include/dm/platform_data/serial_pl01x.h |  6 ++++++
>>  2 files changed, 12 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/serial/serial_pl01x.c b/drivers/serial/serial_pl01x.c
>> index ad503af..037fd23 100644
>> --- a/drivers/serial/serial_pl01x.c
>> +++ b/drivers/serial/serial_pl01x.c
>> @@ -125,7 +125,7 @@ static int pl011_set_line_control(struct pl01x_regs *regs)
>>  }
>>
>>  static int pl01x_generic_setbrg(struct pl01x_regs *regs, enum pl01x_type type,
>> -                               int clock, int baudrate)
>> +                                      int clock, int baudrate)
>>  {
>>         switch (type) {
>>         case TYPE_PL010: {
>> @@ -295,7 +295,6 @@ __weak struct serial_device *default_serial_console(void)
>>  #endif /* nCONFIG_DM_SERIAL */
>>
>>  #ifdef CONFIG_DM_SERIAL
>> -
>>  struct pl01x_priv {
>>         struct pl01x_regs *regs;
>>         enum pl01x_type type;
>> @@ -306,9 +305,9 @@ static int pl01x_serial_setbrg(struct udevice *dev, int baudrate)
>>         struct pl01x_serial_platdata *plat = dev_get_platdata(dev);
>>         struct pl01x_priv *priv = dev_get_priv(dev);
>>
>> -       pl01x_generic_setbrg(priv->regs, priv->type, plat->clock, baudrate);
>> -
>> -       return 0;
>> +       return (plat->flags & PL0x_PREINITIALIZED) ? 0 :
>> +               pl01x_generic_setbrg(priv->regs, priv->type,
>> +                                    plat->clock, baudrate);
>>  }
>>
>>  static int pl01x_serial_probe(struct udevice *dev)
>> @@ -318,7 +317,8 @@ static int pl01x_serial_probe(struct udevice *dev)
>>
>>         priv->regs = (struct pl01x_regs *)plat->base;
>>         priv->type = plat->type;
>> -       return pl01x_generic_serial_init(priv->regs, priv->type);
>> +       return (plat->flags & PL0x_PREINITIALIZED) ? 0 :
>> +               pl01x_generic_serial_init(priv->regs, priv->type);
>>  }
>>
>>  static int pl01x_serial_getc(struct udevice *dev)
>> diff --git a/include/dm/platform_data/serial_pl01x.h b/include/dm/platform_data/serial_pl01x.h
>> index 5e068f3..455121b 100644
>> --- a/include/dm/platform_data/serial_pl01x.h
>> +++ b/include/dm/platform_data/serial_pl01x.h
>> @@ -11,17 +11,23 @@ enum pl01x_type {
>>         TYPE_PL011,
>>  };
>>
>> +enum pl01x_flags {
>> +       PL0x_PREINITIALIZED = 1 << 0, /* Skip port initialization */
>> +};
>> +
>>  /*
>>   *Information about a serial port
>>   *
>>   * @base: Register base address
>>   * @type: Port type
>>   * @clock: Input clock rate, used for calculating the baud rate divisor
>> + * @flags: Port flags
>>   */
>>  struct pl01x_serial_platdata {
>>         unsigned long base;
>>         enum pl01x_type type;
>>         unsigned int clock;
>> +       unsigned long flags;
>>  };
>>
>>  #endif
>
> This patch is fine as far as it goes (although the x in
> PL0x_PREINITIALIZED should be capitalised to match style I think).

Agreed

>
> But why doesn't this board use device tree (CONFIG_OF_CONTROL)? Do you
> have a device tree file for it?

OK, I'll import one from the Linux kernel.

>
> Regards,
> Simon

Regards,
Sergey
diff mbox

Patch

diff --git a/drivers/serial/serial_pl01x.c b/drivers/serial/serial_pl01x.c
index ad503af..037fd23 100644
--- a/drivers/serial/serial_pl01x.c
+++ b/drivers/serial/serial_pl01x.c
@@ -125,7 +125,7 @@  static int pl011_set_line_control(struct pl01x_regs *regs)
 }
 
 static int pl01x_generic_setbrg(struct pl01x_regs *regs, enum pl01x_type type,
-				int clock, int baudrate)
+				       int clock, int baudrate)
 {
 	switch (type) {
 	case TYPE_PL010: {
@@ -295,7 +295,6 @@  __weak struct serial_device *default_serial_console(void)
 #endif /* nCONFIG_DM_SERIAL */
 
 #ifdef CONFIG_DM_SERIAL
-
 struct pl01x_priv {
 	struct pl01x_regs *regs;
 	enum pl01x_type type;
@@ -306,9 +305,9 @@  static int pl01x_serial_setbrg(struct udevice *dev, int baudrate)
 	struct pl01x_serial_platdata *plat = dev_get_platdata(dev);
 	struct pl01x_priv *priv = dev_get_priv(dev);
 
-	pl01x_generic_setbrg(priv->regs, priv->type, plat->clock, baudrate);
-
-	return 0;
+	return (plat->flags & PL0x_PREINITIALIZED) ? 0 :
+		pl01x_generic_setbrg(priv->regs, priv->type,
+				     plat->clock, baudrate);
 }
 
 static int pl01x_serial_probe(struct udevice *dev)
@@ -318,7 +317,8 @@  static int pl01x_serial_probe(struct udevice *dev)
 
 	priv->regs = (struct pl01x_regs *)plat->base;
 	priv->type = plat->type;
-	return pl01x_generic_serial_init(priv->regs, priv->type);
+	return (plat->flags & PL0x_PREINITIALIZED) ? 0 :
+		pl01x_generic_serial_init(priv->regs, priv->type);
 }
 
 static int pl01x_serial_getc(struct udevice *dev)
diff --git a/include/dm/platform_data/serial_pl01x.h b/include/dm/platform_data/serial_pl01x.h
index 5e068f3..455121b 100644
--- a/include/dm/platform_data/serial_pl01x.h
+++ b/include/dm/platform_data/serial_pl01x.h
@@ -11,17 +11,23 @@  enum pl01x_type {
 	TYPE_PL011,
 };
 
+enum pl01x_flags {
+	PL0x_PREINITIALIZED = 1 << 0, /* Skip port initialization */
+};
+
 /*
  *Information about a serial port
  *
  * @base: Register base address
  * @type: Port type
  * @clock: Input clock rate, used for calculating the baud rate divisor
+ * @flags: Port flags
  */
 struct pl01x_serial_platdata {
 	unsigned long base;
 	enum pl01x_type type;
 	unsigned int clock;
+	unsigned long flags;
 };
 
 #endif