Commit b63ae841 authored by Yuri Tikhonov's avatar Yuri Tikhonov
Browse files

RT72064. stm32f2_gpio: add MCO GPIO role



MCO will be used for clocking PHY in ethernet.
Signed-off-by: default avatarYuri Tikhonov <yur@emcraft.com>
parent 34b11b9f
......@@ -122,7 +122,8 @@ static const unsigned long io_base[] = {
static const u32 af_val[] = {
STM32F2_GPIO_AF_USART1, STM32F2_GPIO_AF_USART2, STM32F2_GPIO_AF_USART3,
STM32F2_GPIO_AF_USART4, STM32F2_GPIO_AF_USART5, STM32F2_GPIO_AF_USART6,
STM32F2_GPIO_AF_MAC
STM32F2_GPIO_AF_MAC,
0
};
/*
......@@ -161,6 +162,7 @@ int stm32f2_gpio_config(unsigned int port, unsigned int pin,
pupd = STM32F2_GPIO_PUPD_UP;
break;
case STM32F2_GPIO_ROLE_ETHERNET:
case STM32F2_GPIO_ROLE_MCO:
otype = STM32F2_GPIO_OTYPE_PP;
ospeed = STM32F2_GPIO_SPEED_100M;
pupd = STM32F2_GPIO_PUPD_NO;
......@@ -182,12 +184,14 @@ int stm32f2_gpio_config(unsigned int port, unsigned int pin,
*/
rcc_regs->ahb1enr |= 1 << port;
/*
* Connect PXy to the specified controller (role)
*/
i = (pin & 0x07) * 4;
gpio_regs->afr[pin >> 3] &= ~(0xF << i);
gpio_regs->afr[pin >> 3] |= af_val[role] << i;
if (role != STM32F2_GPIO_ROLE_MCO) {
/*
* Connect PXy to the specified controller (role)
*/
i = (pin & 0x07) * 4;
gpio_regs->afr[pin >> 3] &= ~(0xF << i);
gpio_regs->afr[pin >> 3] |= af_val[role] << i;
}
i = pin * 2;
......
......@@ -32,7 +32,8 @@ enum stm32f2_gpio_role {
STM32F2_GPIO_ROLE_USART4, /* GPIO is used by USART4 */
STM32F2_GPIO_ROLE_USART5, /* GPIO is used by USART5 */
STM32F2_GPIO_ROLE_USART6, /* GPIO is used by USART6 */
STM32F2_GPIO_ROLE_ETHERNET /* GPIO is used by MAC */
STM32F2_GPIO_ROLE_ETHERNET, /* GPIO is used by MAC */
STM32F2_GPIO_ROLE_MCO /* GPIO is used for MC ext output clk */
};
/*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment