Hello,
We try to write a register (SAI2 Transmit Control Register (I2S2_TCSR)) from a linux kernel module, but for some reason after trying to read the value again, it reads 0. Here is a snippet of the imx6ull.dtsi :
sai2: sai@0202c000 {
compatible = "fsl,imx6ul-sai",
"fsl,imx6sx-sai";
reg = <0x0202c000 0x4000>;
interrupts = <GIC_SPI 98 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clks IMX6UL_CLK_SAI2_IPG>,
<&clks IMX6UL_CLK_DUMMY>,
<&clks IMX6UL_CLK_SAI2>,
<&clks 0>, <&clks 0>;
clock-names = "bus", "mclk0", "mclk1", "mclk2", "mclk3";
dma-names = "rx", "tx";
dmas = <&sdma 37 24 0>, <&sdma 38 24 0>;
status = "disabled";
};
And here is the dts we're adding :
&sai2 {
compatible = "fsl,clock32khz_imx6ulzb2";
status = "okay";
};
Eventually, here is a part of the module :
#define I2S2_TCSR_ADDR 0x0202C000
#define I2S2_TCSR_VALUE 0xD0000000
#define SAI2_MEM_REGION_SIZE 0x200
static void *pVirtAddr_I2S2_TCSR;
static int clock32khz_probe(struct platform_device *pdev)
{ int value;
pVirtAddr_I2S2_TCSR=0;
//SAI2 request mem region
if(!request_mem_region(I2S2_TCSR_ADDR,SAI2_MEM_REGION_SIZE,"clock32KHz : sai2"))
{ printk(KERN_ERR "Failed to request mem region I2S2_TCSR_ADDR\n");
ret=-EBUSY;
goto ErrSAI2req;
}
//I2S2_TCSR
pVirtAddr_I2S2_TCSR=devm_ioremap_nocache(&pdev->dev,I2S2_TCSR_ADDR,1);
if(!pVirtAddr_I2S2_TCSR)
{ printk(KERN_ERR "Failed to remap I/O memory I2S2_TCSR_ADDR\n");
ret=-ENXIO;
goto ErrI2S2_TCSR;
}
value=*(int *)(pVirtAddr_I2S2_TCSR);
printk(KERN_INFO "I2S2_TCSR=%X\n",value);
*(int *)(pVirtAddr_I2S2_TCSR)=I2S2_TCSR_VALUE;
//TEST
value=*(int *)(pVirtAddr_I2S2_TCSR);
printk(KERN_INFO "I2S2_TCSR test1=%X\n",value);
devm_iounmap(&pdev->dev,pVirtAddr_I2S2_TCSR);
pVirtAddr_I2S2_TCSR=devm_ioremap_nocache(&pdev->dev,I2S2_TCSR_ADDR,1);
if(!pVirtAddr_I2S2_TCSR)
{ printk(KERN_ERR "Failed to remap I/O memory I2S2_TCSR_ADDR\n");
ret=-ENXIO;
goto ErrI2S2_TCSR;
}
value=*(int *)(pVirtAddr_I2S2_TCSR);
printk(KERN_INFO "I2S2_TCSR test2=%X\n",value);
//TEST END
//No error
return 0;
}
static const struct of_device_id of_clock32khz_match[] = {
{ .compatible = "fsl,clock32khz_imx6ulzb2", },
{},
};
MODULE_DEVICE_TABLE(of, of_clock32khz_match);
static struct platform_driver clock32khz_device_driver = {
.probe = clock32khz_probe,
.remove = clock32khz_remove,
.driver = {
.name = "clock32khz_imx6ulzb2",
.of_match_table = of_clock32khz_match,
}
};
module_platform_driver(clock32khz_device_driver);
It seems that everything is working when the module is inserted, but the printk's output is :
I2S2_TCSR test1=D0000000
I2S2_TCSR test2=0
Any help would be much appreciated.
Guillaume