Re: [PATCH v4 1/2] uart: pl011: Support registers offset with LUT

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Apr 07, 2015 at 03:11:25PM +0800, Jun Nie wrote:
> Both ARM and ST uart use the same pl011 IP, but some registers
> have different offset. Support the different offset with look
> up table.
> 
> Signed-off-by: Jun Nie <jun.nie@xxxxxxxxxx>
> ---
>  drivers/tty/serial/amba-pl011.c | 343 ++++++++++++++++++++++++----------------
>  include/linux/amba/serial.h     |   4 +
>  2 files changed, 209 insertions(+), 138 deletions(-)
> 
> diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
> index 8d94c19..7c494f8 100644
> --- a/drivers/tty/serial/amba-pl011.c
> +++ b/drivers/tty/serial/amba-pl011.c
> @@ -29,7 +29,6 @@
>   * and hooked into this driver.
>   */
>  
> -
>  #if defined(CONFIG_SERIAL_AMBA_PL011_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
>  #define SUPPORT_SYSRQ
>  #endif
> @@ -66,6 +65,8 @@
>  #define SERIAL_AMBA_NR		UART_NR
>  
>  #define AMBA_ISR_PASS_LIMIT	256
> +#define REG_NR			19
> +#define IDX(x)			((x) >> 2)
>  
>  #define UART_DR_ERROR		(UART011_DR_OE|UART011_DR_BE|UART011_DR_PE|UART011_DR_FE)
>  #define UART_DUMMY_DR_RX	(1 << 16)
> @@ -73,8 +74,7 @@
>  /* There is by now at least one vendor with differing details, so handle it */
>  struct vendor_data {
>  	unsigned int		ifls;
> -	unsigned int		lcrh_tx;
> -	unsigned int		lcrh_rx;
> +	u8			*reg_lut;
>  	bool			oversampling;
>  	bool			dma_threshold;
>  	bool			cts_event_workaround;
> @@ -87,10 +87,32 @@ static unsigned int get_fifosize_arm(struct amba_device *dev)
>  	return amba_rev(dev) < 3 ? 16 : 32;
>  }
>  
> +static u8 arm_reg[] = {
> +	/*  All registers offset are in order except [8]=0x2c */
> +	[IDX(UART01x_DR)]	= UART01x_DR,
> +	[IDX(UART01x_RSR)]	= UART01x_RSR,
> +	[IDX(ST_UART011_DMAWM)]	= ST_UART011_DMAWM,
> +	[IDX(UART010_LCRM)]	= UART010_LCRM,
> +	[IDX(UART010_LCRL)]	= UART010_LCRL,
> +	[IDX(UART010_CR)]	= UART010_CR,
> +	[IDX(UART01x_FR)]	= UART01x_FR,
> +	[IDX(UART011_LCRH_TX)]	= UART011_LCRH_TX, /* remapped */

Are you sure this is correct?  Shouldn't this be:
	[IDX(UART011_LCRH_RX)]	= UART011_LCRH_TX, /* remapped */

though, I'd prefer:
	[IDX(UART011_LCRH_RX)]	= UART011_LCRH, /* remapped */

> +	[IDX(UART01x_ILPR)]	= UART01x_ILPR,
> +	[IDX(UART011_IBRD)]	= UART011_IBRD,
> +	[IDX(UART011_FBRD)]	= UART011_FBRD,
> +	[IDX(UART011_LCRH_TX)]	= UART011_LCRH_TX,

and:
	[IDX(UART011_LCRH_TX)]	= UART011_LCRH,

to make it more obvious that the one on the right refers to something
else.

What I would also like to see is a follow up patch which introduces an
enum for the IDX(...) stuff and replaces the indexes there, something
like:

enum {
	REG_DR,
	REG_RSR,
	...
};

and the initialisers as:

	[REG_DR]		= UART01x_DR,
...

This'll also allow us to get rid of the UART011_LCRH_RX macro again
which really doesn't belong (it's not in the standard version of the
primecell, so I don't want these things to be misleading... I'd
prefer to stick to the ST_* naming convention for the ST-specific
stuff.)

> +static u8 st_reg[] = {
> +	/* All registers offset are in order */
> +	[IDX(UART01x_DR)]	= UART01x_DR,
> +	[IDX(UART01x_RSR)]	= UART01x_RSR,
> +	[IDX(ST_UART011_DMAWM)]	= ST_UART011_DMAWM,
> +	[IDX(UART010_LCRM)]	= UART010_LCRM,
> +	[IDX(UART010_LCRL)]	= UART010_LCRL,
> +	[IDX(UART010_CR)]	= UART010_CR,
> +	[IDX(UART01x_FR)]	= UART01x_FR,
> +	[IDX(UART011_LCRH_TX)]	= UART011_LCRH_RX,

Presumably this should be IDX(UART011_LCRH_RX) here too?

-- 
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.
--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux