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;
iowrite32(gpiomux, clkmux);
printk("[SPI] IOMUXC DURING DEBUG: 0x%08X\n", ioread32(clkmux));
iowrite32(spimux, 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);
gpio_set_value(80, 1);
udelay(1000);
gpio_set_value(80, 0);
udelay(1000);
gpio_set_value(80, 1);
udelay(1000);
gpio_set_value(80, 0);
gpio_free(80);
printk("[SPI] IOMUXC AFTER DEBUG: 0x%08X\n", ioread32(clkmux));
iounmap(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?