Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stm32f4: Add support for UART4 to 10 #27

Merged
merged 6 commits into from
May 15, 2017

Conversation

vaussard
Copy link
Contributor

@vaussard vaussard commented May 1, 2017

Some devices, like the STM32F413, support up to 10 UARTs. This series adds the necessary support with the following actions:

  • Add related Kconfig and initialisation code in the serial driver
  • Add the missing pinmux arrays
  • Add the missing dts nodes

This is targeting STM32F4, but similar patches can be done for other STM32 families if well received.


This change is Reviewable

#ifdef CONFIG_CLOCK_CONTROL_STM32_CUBE
.pclken = { .bus = STM32_CLOCK_BUS_APB2,
.enr = LL_APB2_GRP1_PERIPH_USART1 },
#define STM32Fxxx_CLOCK_UART(type, apb, n) \
Copy link
Member

Choose a reason for hiding this comment

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

Change macro name as this is also used for STM32LXX as well already.
STM32_CLOCK_UART would be enough

Then, use of dts should modify this as well anytime soon.
Hence I wonder if this is the right time to do this change.
@Kumar, @andy Gross, your view on this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm ok with this while we still work on generation, it helps at least see the pattern for the STM UART

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok I will change the name for all macro.

uart_stm32_isr, DEVICE_GET(uart_stm32_1),
0);
irq_enable(PORT_1_IRQ);
#define STM32Fxxx_UART_IRQ_HANDLER_DECL(n) \
Copy link
Member

Choose a reason for hiding this comment

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

same here STM32_UART_IRQ_HANDLER

irq_enable(PORT_1_IRQ);
#define STM32Fxxx_UART_IRQ_HANDLER_DECL(n) \
static void uart_stm32_irq_config_func_##n(struct device *dev)
#define STM32Fxxx_UART_IRQ_HANDLER_FUNC(n) \
Copy link
Member

Choose a reason for hiding this comment

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

same here

static void uart_stm32_irq_config_func_##n(struct device *dev)
#define STM32Fxxx_UART_IRQ_HANDLER_FUNC(n) \
.irq_config_func = uart_stm32_irq_config_func_##n,
#define STM32Fxxx_UART_IRQ_HANDLER(n) \
Copy link
Member

Choose a reason for hiding this comment

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

same here


#define PINMUX_UART_TX(pin, port) PINMUX_UART##port(TX, pin)
#define PINMUX_UART_RX(pin, port) PINMUX_UART##port(RX, pin)

static const stm32_pin_func_t pin_pa0_funcs[] = {
Copy link
Member

Choose a reason for hiding this comment

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

This is an interesting proposal (that would eventually deserve to be extended to whole stm32 family to keep consistency across STM32 series). Thought, please keep it easily readable and consistent across IPs. For instance:
PINMUX_UART(PA2, UART2, TX)
PINMUX_PWM(PA0, PWM2, CH1)
Aim is to understand what macro does at first reading w/o refering to macro definition.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it would be good to extend to other STM32 as I also said in the cover letter. This can be done as a follow-up if you agree, especially considering that I do not have other STM32 on my desk right now.

Sure, I will look into the consistency issue, thanks.

Copy link
Collaborator

@galak galak left a comment

Choose a reason for hiding this comment

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

Would also be good to look at using the generated defines from dts directly now that all STM boards use DTS.

@galak galak force-pushed the arm branch 4 times, most recently from 34a8649 to 255f198 Compare May 9, 2017 15:42
@vaussard
Copy link
Contributor Author

Hi Kumar.

Would also be good to look at using the generated defines from dts directly now that all STM boards use DTS.

So you mean the defines for the UART (without the fixup file), right? We do not have the pinmux AFAIK.

Do you have an idea/proposal how to do that? The generated defines does contain the physical address (ST_STM32_USART_40004800_IRQ_0), so I do not see how to cleanly abstract this across all STM32; unless we assume that the physical address is always the same across devices.

Florian Vaussard added 6 commits May 11, 2017 12:27
The registration of each serial port differs only by a few details.
These differences can be factorized in order to create a generic
registration macro.

This has several advantages:
- Less code
- Easier to add new ports
- Less work to add support for new STM32 families

Change-Id: I6e62a96ccbbf03c9d51bc2617db6a851ff0d83c7
Signed-off-by: Florian Vaussard <florian.vaussard@heig-vd.ch>
Add support for U(S)ART 4 to 10 that can be found at least on some
members of the STM32F4 family.

Change-Id: Ie870492511f885005cf023040e498bd4d800e807
Signed-off-by: Florian Vaussard <florian.vaussard@heig-vd.ch>
Clean-up the pinmux arrays as a preparatory work before adding more
pinmuxes.

This is achieved by the following two actions:
- Define the PAD macro to simplify the [x - 1] = y construct
- Reorder the declartions by bank / pin to make it easier to
  locate a pin among a high number of other pins, while minimizing the
  risk of conflict when two people add a new declaration for two
  different pins

Change-Id: I1ca0cc4f48bcd8cfd35b331e9821935f5c855876
Signed-off-by: Florian Vaussard <florian.vaussard@heig-vd.ch>
It is useless to include the pinmux for a peripheral if it is not
enabled in the Kconfig. This is unnecessary and it increases the size of
the binary.

Define macros that will default to void if the associated Kconfig is not
enabled.

Change-Id: I0857fcef335c75b8bb6d537fd859f93d5be4a228
Signed-off-by: Florian Vaussard <florian.vaussard@heig-vd.ch>
Add defines and pinmux arrays to support more UARTs on STM32F4.

Change-Id: Ib06c549bdb2b3d7065554a0a6d1a3d15441b29c9
Signed-off-by: Florian Vaussard <florian.vaussard@heig-vd.ch>
Add missing UARTs from the main device tree. They are declared as
disabled and can be enabled individually by each board.

Change-Id: I0ec73c59b4c3c4ee56f12ae70f2d6cdbec14fe33
Signed-off-by: Florian Vaussard <florian.vaussard@heig-vd.ch>
@vaussard vaussard force-pushed the stm32f4_more_uart_v3 branch from 313855b to b6bebea Compare May 11, 2017 12:19
@vaussard
Copy link
Contributor Author

I rebased + addressed Erwan's comments.

Kumar please provide me with more details regarding your requested changes. Thanks!

static const stm32_pin_func_t pin_pa9_funcs[] = {
[STM32F4_PINMUX_FUNC_PA9_USART1_TX - 1] =
STM32F4X_PIN_CONFIG_AF_PUSH_UP,
#define PAD(AF, func) \
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need to separate this on more than one line?

@galak galak merged commit 975a9d6 into zephyrproject-rtos:arm May 15, 2017
nagineni pushed a commit to nagineni/zephyr that referenced this pull request Nov 20, 2017
[ZEPHYR] Fix build errors against upstream Zephyr
pabigot added a commit to pabigot/zephyr that referenced this pull request Nov 2, 2019
Add specific compatible to existing JEDEC SPI device.

Add a second JEDEC SPI device with a different compatible.

Demonstrates issues with checkpatch:

    -:27: WARNING:UNDOCUMENTED_DT_STRING: DT compatible string "mxicy,mx25r6435f" appears un-documented -- check ./dts/bindings/
    zephyrproject-rtos#27: FILE: boards/arm/nrf52840_pca10056/nrf52840_pca10056.dts:195:
    +  compatible = "mxicy,mx25r6435f", "jedec,spi-nor";

    -:37: WARNING:UNDOCUMENTED_DT_STRING: DT compatible string "mxicy,mx25l3233f" appears un-documented -- check ./dts/bindings/
    zephyrproject-rtos#37: FILE: boards/arm/nrf52840_pca10056/nrf52840_pca10056.dts:207:
    +  compatible = "mxicy,mx25l3233f", "jedec,spi-nor";

Demonstrates inability to relate specific to generic variant by prefix:

    #define DT_INST_0_MXICY_MX25R6435F  1
    #define DT_INST_0_JEDEC_SPI_NOR     1
    #define DT_INST_0_MXICY_MX25L3233F  1
    #define DT_INST_1_JEDEC_SPI_NOR     1

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
NickolasLapp pushed a commit to NickolasLapp/zephyr that referenced this pull request Oct 19, 2022
MFI audio packets now pass through HCI with the packet boundary flag set to '11' as suggested by the MFI spec
pkunieck pushed a commit to pkunieck/zephyr that referenced this pull request Jul 18, 2023
Signed-off-by: Connor Graydon <connor.graydon@intel.com>
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.

3 participants