All of lore.kernel.org
 help / color / mirror / Atom feed
From: Graeme Russ <graeme.russ@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2] NS16550: buffer reads
Date: Wed, 26 Oct 2011 20:18:41 +1100	[thread overview]
Message-ID: <4EA7D071.9010104@gmail.com> (raw)
In-Reply-To: <20111026070000.1B9E811F9E7C@gemini.denx.de>

Hi Wolfgang,

On 26/10/11 18:00, Wolfgang Denk wrote:
> Dear Graeme,
> 
> In message <CALButCKQ_bgpOZquozzQnU01v41Y+uWo8ELLNqSE15D30p52ug@mail.gmail.com> you wrote:
>>
>> Well, I have the feeling than an console API might be in order. The way
>> U-Boot is structured at the moment, serial I/O is kind of taken for
>> granted to 'just exist' and nobody needs to really be self-aware that
>> they use it...
> 
> Indeed. All we need is a working set of srdin/stdout/stderr.  Keep in
> mind that anything couldbe attached - not only a serial line.
> 
>>           ... The same cannot be said of users of USB and Network -
>> Net is a good example - all 'users' of net call NetLoop() which does
>> an eth_init()...do stuff...eth_halt()
> 
> Driver API...
> 
>> So maybe a serial API which 'users' must 'wake up' and 'sleep'...
> 
> Arghhh...
> 
>>  - console_configure() - Set parameters (port, baud rate etc)
>>  - console_wake() - Prepare the console (could be serial, USB, netconsole)
>>  - console_flush() - Throw away any buffered characters
>>  - console_getc(), console_putc(), console_tstc() - Self explainatory
>>  - console_sleep() - Shut the console down (send XOFF, turn of USB etc)
> 
> Forget it.  We will not have a separate and completely non-standard "serial API".
> If anything gets changed here, then in the context of a general driver
> API cleanup, or at least based on a design for such a generic driver
> API.

Funny, I wrote that without the code in front of me. But look at this...

struct serial_device {
	char name[NAMESIZE];

	int  (*init) (void);
	int  (*uninit) (void);
	void (*setbrg) (void);
	int (*getc) (void);
	int (*tstc) (void);
	void (*putc) (const char c);
	void (*puts) (const char *s);
#if CONFIG_POST & CONFIG_SYS_POST_UART
	void (*loop) (int);
#endif

	struct serial_device *next;
};

and

struct stdio_dev {
	int	flags;		/* Device flags: input/output/system	*/
	int	ext;		/* Supported extensions			*/
	char	name[16]	/* Device name				*/

/* GENERAL functions */

	int (*start) (void);	/* To start the device		*/
	int (*stop) (void);	/* To stop the device		*/

/* OUTPUT functions */

	void (*putc) (const char c);	/* To put a char	*/
	void (*puts) (const char *s);	/* To put a string	*/

/* INPUT functions */

	int (*tstc) (void);		/* To test if a char is ready...*/
	int (*getc) (void);		/* To get that char		*/

/* Other functions */

	void *priv;			/* Private extensions		*/
	struct list_head list;
};

and

void serial_stdio_init (void)
{
	struct stdio_dev dev;
	struct serial_device *s = serial_devices;

	while (s) {
		memset (&dev, 0, sizeof (dev));

		strcpy (dev.name, s->name);
		dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT;

		dev.start = s->init;
		dev.stop = s->uninit;
		dev.putc = s->putc;
		dev.puts = s->puts;
		dev.getc = s->getc;
		dev.tstc = s->tstc;

		stdio_register (&dev);

		s = s->next;
	}
}

and mpc512x has this gem

int close_port(int num)
{
	struct stdio_dev *port;
	int ret;
	char name[7];

	if (num < 0 || num > 11)
		return -1;

	sprintf(name, "psc%d", num);
	port = stdio_get_by_name(name);
	if (!port)
		return -1;

	ret = port->stop();
	clear_bit(num, &initialized);

	return ret;
}

stdio_dev->start() is called in console_setfile() which is called by
console_init_r(). stdio_dev->stop() is never called apart from in the above
mpc512x example.

As I said, stdio is, unlike other devices, taken for granted - It gets
setup during console_init_r() and is assumed to be in-volatile from then on.

So the hooks are already there - All that would be needed is a hook to
allow console users to ultimately call stdio_dev->start when they want to
start using stdio and stdio_dev->stop when they are finished. Of course the
physical device itself is hidden and could be serial, USB, Ethernet, VGA,
Braille display - whatever.

Hmmm, stdio_open() and stdio_close()

>> UART like your SPI example. The command line interpreter calls
>> console_sleep() to release the serial UART resource before the command
>> which uses the multiplexed device wakes that device, does it's thing and
>> shuts the device down before returning to the command line interpreter
>> which wakes up the serial UART...
> 
> Sorry, but that's crappy by design.

When resources are tight - The eNET board has 8-bit CF ports instead of 16
bit because of board space and FPGA limitation which necessitated a slight
mod to the Linux CF driver. Crappy yes, but hey, when given lemons

Regards,

Graeme

  reply	other threads:[~2011-10-26  9:18 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-16  5:14 [U-Boot] [PATCH v4 1/2] NS16550: trivial code clean for checkpatch Simon Glass
2011-10-16  5:14 ` [U-Boot] [PATCH v4 2/2] NS16550: buffer reads Simon Glass
2011-10-16 12:57   ` Albert ARIBAUD
2011-10-16 17:06     ` Simon Glass
2011-10-16 20:13       ` Wolfgang Denk
2011-10-16 20:47         ` Simon Glass
2011-10-16 21:03           ` Wolfgang Denk
2011-10-17 11:08   ` Wolfgang Denk
2011-10-17 16:25     ` Simon Glass
2011-10-17 20:19     ` Simon Glass
2011-10-17 20:33       ` Wolfgang Denk
2011-10-17 20:58         ` Simon Glass
2011-10-22  8:29           ` Albert ARIBAUD
2011-10-17 12:18   ` Wolfgang Denk
2011-10-17 16:40     ` Simon Glass
2011-10-22  8:44       ` Albert ARIBAUD
2011-10-22 22:15         ` Graeme Russ
2011-10-23  8:20           ` Wolfgang Denk
2011-10-23 11:50             ` Graeme Russ
2011-10-23 17:15               ` Wolfgang Denk
2011-10-23 20:17                 ` Graeme Russ
2011-10-23 21:22                   ` Wolfgang Denk
2011-10-23 21:32                     ` [U-Boot] [PATCH v2] " Graeme Russ
2011-10-23 22:18                       ` Wolfgang Denk
2011-10-23 23:30                         ` Graeme Russ
2011-10-24  4:47                           ` Simon Glass
2011-10-24 18:46                           ` Wolfgang Denk
2011-10-24 19:26                             ` Graeme Russ
2011-10-24 20:00                               ` Wolfgang Denk
2011-10-24 20:40                                 ` Graeme Russ
2011-10-24 21:59                                   ` Wolfgang Denk
2011-10-24 22:22                                     ` Graeme Russ
2011-10-24 23:31                                       ` J. William Campbell
2011-10-25  7:31                                       ` Wolfgang Denk
2011-10-25  8:34                                         ` Graeme Russ
2011-10-25 18:41                                           ` Wolfgang Denk
2011-10-25 22:37                                             ` Graeme Russ
2011-10-25 23:17                                               ` Simon Glass
     [not found]                                                 ` <CALButCK2XnZ=HR72VaXioCfxkMFgMh2JbXzSDq9TadgKFH52rQ@mail.gmail.com >
2011-10-25 23:37                                                 ` Graeme Russ
2011-10-25 23:48                                                   ` Simon Glass
2011-10-26  3:41                                                     ` Graeme Russ
2011-10-26  7:00                                                       ` Wolfgang Denk
2011-10-26  9:18                                                         ` Graeme Russ [this message]
2011-10-26 10:19                                                           ` Wolfgang Denk
2011-10-26 16:55                                                   ` Scott Wood
2011-10-26 18:17                                                     ` Wolfgang Denk
2011-10-26 18:50                                                       ` Scott Wood
2011-10-26 19:19                                                         ` Wolfgang Denk
2011-10-26  6:54                                               ` Wolfgang Denk
2011-10-23 18:17   ` [U-Boot] [PATCH v4 2/2] " Wolfgang Denk
2011-10-23 18:20 ` [U-Boot] [PATCH v4 1/2] NS16550: trivial code clean for checkpatch Wolfgang Denk
  -- strict thread matches above, loose matches on Subject: below --
2011-10-15  0:03 [U-Boot] [PATCH v2] NS16550: buffer reads Simon Glass
2011-10-15 10:43 ` Albert ARIBAUD
2011-10-15 14:47   ` Simon Glass
2011-10-15 16:02     ` Wolfgang Denk
2011-10-15 16:12       ` Simon Glass
2011-10-15 16:21         ` Albert ARIBAUD
2011-10-15 16:50           ` Simon Glass
2011-10-15 17:45             ` Simon Glass
2011-10-15 19:14               ` Wolfgang Denk
2011-10-16  4:46                 ` Simon Glass
2011-10-16 19:52                   ` Wolfgang Denk
2011-10-16 21:02                     ` Simon Glass
2011-10-15 19:05             ` Wolfgang Denk
2011-10-15 19:00         ` Wolfgang Denk
2011-10-16  4:39           ` Simon Glass
2011-10-16 19:47             ` Wolfgang Denk
2011-10-16 20:43               ` Simon Glass
2011-10-16 21:00                 ` Wolfgang Denk

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=4EA7D071.9010104@gmail.com \
    --to=graeme.russ@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.