public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 1/5] serial: Introduce ->getinfo() callback
Date: Thu, 15 Nov 2018 19:58:50 +0200	[thread overview]
Message-ID: <20181115175854.7550-2-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20181115175854.7550-1-andriy.shevchenko@linux.intel.com>

New callback will give a necessary information to fill up ACPI SPCR table,
for example. Maybe used later for other purposes.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/serial/serial-uclass.c | 21 +++++++++++++++++++++
 include/common.h               |  3 +++
 include/serial.h               | 17 +++++++++++++++++
 3 files changed, 41 insertions(+)

diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
index 665cca85cb..274734d059 100644
--- a/drivers/serial/serial-uclass.c
+++ b/drivers/serial/serial-uclass.c
@@ -308,6 +308,25 @@ int serial_setconfig(uint config)
 	return 0;
 }
 
+int serial_getinfo(struct serial_device_info *info)
+{
+	struct dm_serial_ops *ops;
+
+	if (!gd->cur_serial_dev)
+		return -ENODEV;
+
+	if (!info)
+		return -EINVAL;
+
+	info->baudrate = gd->baudrate;
+
+	ops = serial_get_ops(gd->cur_serial_dev);
+	if (ops->getinfo)
+		return ops->getinfo(gd->cur_serial_dev, info);
+
+	return -EINVAL;
+}
+
 void serial_stdio_init(void)
 {
 }
@@ -425,6 +444,8 @@ static int serial_post_probe(struct udevice *dev)
 	if (ops->loop)
 		ops->loop += gd->reloc_off;
 #endif
+	if (ops->getinfo)
+		ops->getinfo += gd->reloc_off;
 #endif
 	/* Set the baud rate */
 	if (ops->setbrg) {
diff --git a/include/common.h b/include/common.h
index 8b9f859c07..1f9c98e735 100644
--- a/include/common.h
+++ b/include/common.h
@@ -349,6 +349,8 @@ void smp_set_core_boot_addr(unsigned long addr, int corenr);
 void smp_kick_all_cpus(void);
 
 /* $(CPU)/serial.c */
+struct serial_device_info;
+
 int	serial_init   (void);
 void	serial_setbrg (void);
 void	serial_putc   (const char);
@@ -357,6 +359,7 @@ void	serial_puts   (const char *);
 int	serial_getc   (void);
 int	serial_tstc   (void);
 int	serial_setconfig(uint config);
+int	serial_getinfo(struct serial_device_info *info);
 
 /* $(CPU)/speed.c */
 int	get_clocks (void);
diff --git a/include/serial.h b/include/serial.h
index 020cd392e8..33531b7791 100644
--- a/include/serial.h
+++ b/include/serial.h
@@ -111,6 +111,16 @@ enum serial_stop {
 				SERIAL_8_BITS << SERIAL_BITS_SHIFT | \
 				SERIAL_ONE_STOP << SERIAL_STOP_SHIFT
 
+/* REVISIT: ACPI GAS specification implied */
+struct serial_device_info {
+	unsigned int baudrate;
+	u8	addr_space;	/* 0 - MMIO, 1 - IO */
+	u8	reg_width;
+	u8	reg_offset;
+	u8	reg_shift;
+	u64	addr;
+};
+
 /**
  * struct struct dm_serial_ops - Driver model serial operations
  *
@@ -201,6 +211,13 @@ struct dm_serial_ops {
 	 * @return 0 if OK, -ve on error
 	 */
 	int (*setconfig)(struct udevice *dev, uint serial_config);
+	/**
+	 * getinfo() - Get serial device information
+	 *
+	 * @dev: Device pointer
+	 * @info: struct serial_device_info to fill
+	 */
+	int (*getinfo)(struct udevice *dev, struct serial_device_info *info);
 };
 
 /**
-- 
2.19.1

  reply	other threads:[~2018-11-15 17:58 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-15 17:58 [U-Boot] [PATCH v2 0/5] ACPI: Generate SPCR table Andy Shevchenko
2018-11-15 17:58 ` Andy Shevchenko [this message]
2018-11-15 18:22   ` [U-Boot] [PATCH v2 1/5] serial: Introduce ->getinfo() callback Alexander Graf
2018-11-15 19:31     ` Andy Shevchenko
2018-11-15 20:09       ` Alexander Graf
2018-11-20 18:27         ` Andy Shevchenko
2018-11-15 19:45   ` Simon Glass
2018-11-15 19:51     ` Andy Shevchenko
2018-11-15 20:22       ` Simon Glass
2018-11-20 17:39         ` Andy Shevchenko
2018-11-20 18:32     ` Andy Shevchenko
2018-11-20 22:04       ` Alexander Graf
2018-11-20 22:16         ` Andy Shevchenko
2018-11-15 17:58 ` [U-Boot] [PATCH v2 2/5] serial: ns16550: Read reg-io-width from device tree Andy Shevchenko
2018-11-15 18:28   ` Alexander Graf
2018-11-15 19:33     ` Andy Shevchenko
2018-11-15 20:12       ` Alexander Graf
2018-11-15 19:45   ` Simon Glass
2018-11-15 19:53     ` Andy Shevchenko
2018-11-15 17:58 ` [U-Boot] [PATCH v2 3/5] serial: ns16550: Provide ->getinfo() implementation Andy Shevchenko
2018-11-15 18:30   ` Alexander Graf
2018-11-15 19:37     ` Andy Shevchenko
2018-11-15 19:45       ` Simon Glass
2018-11-15 17:58 ` [U-Boot] [PATCH v2 4/5] x86: acpi: Add SPCR table description Andy Shevchenko
2018-11-18 12:37   ` Bin Meng
2018-11-15 17:58 ` [U-Boot] [PATCH v2 5/5] x86: acpi: Generate SPCR table Andy Shevchenko
2018-11-15 18:27   ` Alexander Graf
2018-11-15 19:43     ` Andy Shevchenko
2018-11-15 20:19       ` Alexander Graf
2018-11-20 21:06         ` Andy Shevchenko
2018-11-18 12:37   ` Bin Meng
2018-11-20 20:47     ` Andy Shevchenko

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=20181115175854.7550-2-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.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