Skip to content

A DW UART driver for Sue Creek - #957

Closed
lyakh wants to merge 4 commits into
thesofproject:masterfrom
lyakh:sue-dw-uart
Closed

A DW UART driver for Sue Creek#957
lyakh wants to merge 4 commits into
thesofproject:masterfrom
lyakh:sue-dw-uart

Conversation

@lyakh

@lyakh lyakh commented Feb 4, 2019

Copy link
Copy Markdown
Collaborator

This adds a DW UART driver and enables it for only the trace_point() functionality for Sue Creek, until support for DW INTC is added too.

Comment thread src/arch/xtensa/boot_loader.c Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls #define the magic numbers.

Comment thread src/arch/xtensa/boot_loader.c Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be pre-proc'ed by CONFIG_UART (feature-orineted).

Comment thread src/lib/trace.c Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CONFIG_TRACE_UART & CONFIG_TRACE_DMA could be more feature-oriented compilation options.

Comment thread src/drivers/dw/uart.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should all be in a struct dw_uart.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lgirdwood speaking of which: do we need a device object to pass it around? We'd need a global struct uart *trace_uart pointer then.

Comment thread src/drivers/dw/uart.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a platform macro too.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, could you elaborate a bit. Currently that macro is defined in src/platform/suecreek/include/platform/interrupt.h i.e. it is already platform-specific. Or you mean the whole thing should be
#define PLATFORM_UART_IRQ IRQ_EXT_HOST_UART(0)
or similar? Actually wondering what that "EXT_HOST" part of the name is supposed to mean, I think I'll change it too. In fact we can remove that struct from the driver and put it in a platform file, but as long as we don't have any other uses for UARTs as a log console and we don't foresee having more than one of them, we can keep this as is.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean

#define PLATFORM_UART_IRQ IRQ_WHATEVER

in platform.h

Comment thread src/drivers/dw/uart.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd expect to see a struct uart_ops here with pointer to each UART operation. That way clients would call uart_write() instead of dw_write(). A generic struct sof_uart would also need to be defined and passed into each operation.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we also do it like I've done for SPI / GPIO / IOMUX? Just use generic names for exported functions and rely on linking no more than just one required driver? So I'll just drop "dw_" prefixes from exported functions and types.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, your solution breaks when > 1 devices exists. please use existing convention.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean you want to be able to handle multiple UART models / drivers simultaneously? Ok, sure, this version only works when there's a single UART, used only for logging (the driver cannot even receive data). I'll add ops then.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes exactly.

Comment thread src/lib/trace.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should map onto UART driver ops via generic APIs

Comment thread src/platform/intel/cavs/platform.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be a generic uart = uart_init(any params) and we would use a CONFIG_CAVS_UART (which selects DW_UART in Kconfig) instead of CONFIG_USE_CREEK

@lyakh
lyakh force-pushed the sue-dw-uart branch 2 times, most recently from 97c8373 to 90c2df0 Compare February 11, 2019 08:58
@lyakh

lyakh commented Feb 11, 2019

Copy link
Copy Markdown
Collaborator Author

...once again I don't understand the reason for the "build" CI test, any ideas?

@lgirdwood

Copy link
Copy Markdown
Member

Ask ci team.

@michalgrodzicki

Copy link
Copy Markdown
  • @zrombel ,
    Could you take a look into this?

@zrombel

zrombel commented Feb 11, 2019

Copy link
Copy Markdown

We encountered problems with tests repository server. Now everything should be back on line.

@lyakh

lyakh commented Feb 15, 2019

Copy link
Copy Markdown
Collaborator Author

@lgirdwood @mmaka1 ping any more comments? good to merge?

@lgirdwood lgirdwood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please look at ssp.c an dw-dma from driver model info and I need to see more comments describing HW programming flow.

Comment thread src/drivers/dw/uart.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean

#define PLATFORM_UART_IRQ IRQ_WHATEVER

in platform.h

Comment thread src/drivers/dw/uart.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add more comments in this function for each block

Comment thread src/drivers/dw/uart.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, your solution breaks when > 1 devices exists. please use existing convention.

Using macro arguments multiple times within the macro definition body
can lead to repeated expressioon evaluation. To avoid that replace
MIN() and MAX() macros with safer versions.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
This patch adds a driver for the DesignWare UART IP, used on Sue Creek
boards for both the boot-loader and for the SOF runtime proper.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
On Sue Creek the UART is at 0x80800, not at 0x88000.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
The DW UART driver support both trace_point() and trace_event() style
debugging. For trace_event() it uses an interrupt. However, on Sue
Creek the UART interrupt cannot be used yet. Enable only the
trace_point() part of it.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
@lyakh

lyakh commented Feb 26, 2019

Copy link
Copy Markdown
Collaborator Author

@lgirdwood something like this?

Comment thread src/include/sof/uart.h
static inline int uart_write(struct uart *uart,
const char *data, uint32_t size)
{
return uart ? uart->ops->write(uart, data, size) : -ENODEV;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also change this to check for write e.g.

if (uart && uart->ops->write)
        uart->ops->write();

As some drivers may not implement all the ops. Ditto for others.

Comment thread src/drivers/dw/uart-ll.c
@@ -0,0 +1,105 @@
/*
* Copyright (c) 2017-2018, Intel Corporation

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please switch to SPDX identifier in this and other added files

@tlauda

tlauda commented Aug 15, 2019

Copy link
Copy Markdown
Contributor

@lyakh Is this still valid?

@lbetlej

lbetlej commented Dec 6, 2019

Copy link
Copy Markdown
Collaborator

@lyakh Do you plan to work on the PR ? I'd like to close obsolete PRs.

@lyakh

lyakh commented Dec 9, 2019

Copy link
Copy Markdown
Collaborator Author

@lbetlej let's close it for now

@lyakh lyakh closed this Dec 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants