|
| 1 | +// Copyright (c) 2017, Intel Corporation. |
| 2 | + |
| 3 | +// This file is currently meant only for FRDM_K64F board |
| 4 | + |
| 5 | +// C includes |
| 6 | +#include <stdio.h> |
| 7 | + |
| 8 | +// Zephyr includes |
| 9 | +#include <kernel.h> |
| 10 | +#include <init.h> |
| 11 | +#include <pinmux.h> |
| 12 | +#include <pinmux/pinmux.h> |
| 13 | +#include <fsl_port.h> |
| 14 | + |
| 15 | +// CONFIG_INIT_PINMUX_PRIORITY + 1 to override default pinmux settings |
| 16 | +#define CONFIG_K64F_PINMUX_PRIORITY 46 |
| 17 | + |
| 18 | +int frdm_k64f_pinmux_setup(struct device *unused) |
| 19 | +{ |
| 20 | + // NOTE: Here we enable all the controllers but in a real design you would |
| 21 | + // probably try to optimize for the minimum number of GPIO controllers |
| 22 | + // turned on to save power. See zephyr/boards/arm/frdm_k64f/pinmux.c for |
| 23 | + // defaults. |
| 24 | + |
| 25 | + // TODO: eventually we maybe need to analyze script to decide how to do |
| 26 | + // pinmux, or have user provide a static configuration |
| 27 | + struct device *porta = device_get_binding(CONFIG_PINMUX_MCUX_PORTA_NAME); |
| 28 | + pinmux_pin_set(porta, 0, PORT_PCR_MUX(kPORT_MuxAsGpio)); |
| 29 | + pinmux_pin_set(porta, 1, PORT_PCR_MUX(kPORT_MuxAsGpio)); |
| 30 | + pinmux_pin_set(porta, 2, PORT_PCR_MUX(kPORT_MuxAsGpio)); |
| 31 | + |
| 32 | + struct device *portb = device_get_binding(CONFIG_PINMUX_MCUX_PORTB_NAME); |
| 33 | + pinmux_pin_set(portb, 9, PORT_PCR_MUX(kPORT_MuxAsGpio)); |
| 34 | + pinmux_pin_set(portb, 23, PORT_PCR_MUX(kPORT_MuxAsGpio)); |
| 35 | + |
| 36 | + struct device *portc = device_get_binding(CONFIG_PINMUX_MCUX_PORTC_NAME); |
| 37 | + pinmux_pin_set(portc, 2, PORT_PCR_MUX(kPORT_MuxAsGpio)); |
| 38 | + pinmux_pin_set(portc, 3, PORT_PCR_MUX(kPORT_MuxAsGpio)); |
| 39 | + pinmux_pin_set(portc, 4, PORT_PCR_MUX(kPORT_MuxAsGpio)); |
| 40 | + pinmux_pin_set(portc, 16, PORT_PCR_MUX(kPORT_MuxAsGpio)); |
| 41 | + pinmux_pin_set(portc, 17, PORT_PCR_MUX(kPORT_MuxAsGpio)); |
| 42 | + |
| 43 | + struct device *portd = device_get_binding(CONFIG_PINMUX_MCUX_PORTD_NAME); |
| 44 | + pinmux_pin_set(portd, 0, PORT_PCR_MUX(kPORT_MuxAsGpio)); |
| 45 | + pinmux_pin_set(portd, 1, PORT_PCR_MUX(kPORT_MuxAsGpio)); |
| 46 | + pinmux_pin_set(portd, 2, PORT_PCR_MUX(kPORT_MuxAsGpio)); |
| 47 | + pinmux_pin_set(portd, 3, PORT_PCR_MUX(kPORT_MuxAsGpio)); |
| 48 | + |
| 49 | + struct device *porte = device_get_binding(CONFIG_PINMUX_MCUX_PORTE_NAME); |
| 50 | + pinmux_pin_set(porte, 25, PORT_PCR_MUX(kPORT_MuxAsGpio)); |
| 51 | + pinmux_pin_set(porte, 24, PORT_PCR_MUX(kPORT_MuxAsGpio)); |
| 52 | + return 0; |
| 53 | +} |
| 54 | + |
| 55 | +SYS_INIT(frdm_k64f_pinmux_setup, POST_KERNEL, CONFIG_K64F_PINMUX_PRIORITY); |
0 commit comments