I am working with a custom imx6dlsabresd board and I want to dynamically change the clk line to a GPIO and then back again as needed. By default the pin is muxed as an SPI clk on the dtb and controlled by the spi-imx.c driver. I modified this driver to write to the IOMUXC register and change the clk pin to a GPIO, then I requested this GPIO and did some test value modifications. All of the operations reported success but the changes were not being reflected on the line. Here is the code I tried as a proof of concept:
static void spi_imx_clk_debug(void)
void __iomem *clkmux = ioremap(0x020E0144, 4);
uint32_t spimux= ioread32(clkmux);
printk("[SPI] IOMUXC Before DEBUG: 0x%08X\n", spimux);
uint32_t gpiomux = spimux & 0xFFFFFFF0;
gpiomux |= 0x5;
printk("[SPI] IOMUXC DURING DEBUG: 0x%08X\n", ioread32(clkmux));
int ret = gpio_request(80, "spi_clk_gpio");
printk("[SPI] gpio_request: %d\n", ret);
ret = gpio_direction_output(80, 0);
printk("[SPI] gpio_direction_output: %d\n", ret);
printk("[SPI] IOMUXC AFTER DEBUG: 0x%08X\n", ioread32(clkmux));
I called this function within the spi_imx_prepare_message function and it seemed to be executed successfully, but I could not see any changes on the clk line. Am I missing something here?
Hello Jose Argao,
Are you still experiencing this problem? Since the SPI clock is set to the pin from the device tree it won’t be assigned as GPIO by pinctrl. You should be able to achieve what you want by writing the necessary registers directly. That way the pincntrl won’t be aware of the change and you should see the correct behavior.
I hope this helps!