Understanding interrupt-controller in Linux kernel device tree - linux

The Linux kernel device tree can specify the address of an interrupt controller like this:
interrupt-controller {
compatible = "arm,cortex-a15-gic";
interrupt-parent = <0x38>;
#interrupt-cells = <0x3>;
interrupt-controller;
reg = <0x0 0x50041000 0x0 0x1000 0x0 0x50042000 0x0 0x100>;
status = "okay";
linux,phandle = <0x38>;
phandle = <0x38>;
};
https://www.kernel.org/doc/Documentation/devicetree/bindings/interrupt-controller/interrupts.txt seems outdated, it doesn't mention what it means when #interrupt-cells = <0x3>;, so I don't know for example what 0x0 0x50041000 0x0 means.
Also, what does status, linux, phandle, phandle and interrupt-parent mean?
I want to add support for virtualization on a Jetson Nano board, and I must know which interrupts to add to the device tree, as well as how to translate them to the device three interrupt-controller node.

Related

write MAC address to I.MX 8M Plus from Linux user space

I have a I.MX 8M Plus chip on my PCB and I need to write to it a MAC address from Linux user space.
The Linux kernel uses NVMEM driver(drivers/nvmem/ocotp.c) rather than FSL_OTP driver. The dts include the ocotp device support.
ocotp: efuse#30350000 {
compatible = "fsl,imx8mp-ocotp", "fsl,imx8mm-ocotp", "syscon";
reg = <0x30350000 0x10000>;
clocks = <&clk IMX8MP_CLK_OCOTP_ROOT>;
/* For nvmem subnodes */
#address-cells = <1>;
#size-cells = <1>;
imx8mp_uid: unique-id#420 {
reg = <0x8 0x8>;
};
cpu_speed_grade: speed-grade#10 {
reg = <0x10 4>;
};
eth_mac1: mac-address#640 {
reg = <0x90 6>;
};
eth_mac2: mac-address#650 {
reg = <0x96 6>;
};
The nvmem in the sysfs entry is /sys/devices/platform/soc#0/{SOME_ID}.bus/{SOME_ID}.ocotp-ctrl/imx-ocotp0/nvmem
The patch mentioned in the https://community.nxp.com/t5/i-MX-Processors/OCOTP-write-support-on-i-mx8m/m-p/825028?commentID=1161... is already present.
Could you please let me know how to write the MAC address from userspace (eg. Aa:Bb:Cc:Dd:Ee:Ff).I need to assign mac addresses to mac1(mac-address#640) and mac2(mac-address#650) I dont want to write the MAC address from uboot or using UUU.

How to match a Linux driver with a hardware device

I am writing a Linux driver for some custom hardware. My questions is how does Linux match the hardware to my driver. The hardware's DT entry is
nvme_host_sys#43c00000 {
clock-names = "sys_clk_p", "sys_clk_n", "aclk";
clocks = <0x13 0x13 0x13>;
compatible = "xlnx,nvme-host-sys-1.0";
interrupt-names = "intr";
interrupt-parent = <0x4>;
interrupts = <0x0 0x1d 0x4>;
reg = <0x43c00000 0x80000>;
phandle = <0x38>;
};
I can insert my driver using modprobe and that works fine as I can see the printk in the init being written. I can also create an entry in /dev using mknod and that also works fine. But is the driver now associated with the hardware? Do I need to do something else? Thanks
I found the solution. In the driver code we just need to add the following :-
static struct of_device_id nvmedrv_of_match[] = {
{ .compatible = "xlnx,nvme-host-sys-1.0", },
{ /* end of list */ },
};

Linux Kernel Platform Driver: Modifications to _probe() for multiple Devices

What modifications must be done to a Linux kernel driver to support (equal) multiple devices(myipcore) on a SoC (defined in the device tree) instead of only one?
In my application: only one process will open the appropriate /dev/myipcoreX file!
Device Tree:
amba: amba {
compatible = "simple-bus";
#address-cells = <2>;
#size-cells = <2>;
ranges;
axi_myipcore1: myipcore#A0001000 {
compatible = "xy,my-ip-core-1.00";
status = "disabled";
interrupt-parent = <&gic>;
interrupts = <0 89 1>;
reg = <0x0 0xA0001000 0x0 0x14>;
};
axi_myipcore2: myipcore#A0002000 {
compatible = "xy,my-ip-core-1.00";
status = "disabled";
interrupt-parent = <&gic>;
interrupts = <0 90 1>;
reg = <0x0 0xA0002000 0x0 0x14>;
};
....
}
For each device tree entry the _probe() function of the driver is called. How to get dynamically the next minor number for alloc_chrdev_region() and how to execute class_create() only once?
Or do I have to modify the device tree?
You see, I'm looking for the central theme....

Adding touch screen driver to Wandboard, i2c device registration

First I must to tell you, I am not really from electronics background, I have very rough knowledge about Linux drivers, I2C, touch screens, etc.
Problem background
My Wandboard was previously working with Fusion 7 touch display worked with Prism touch screen driver, already provided by Wandboard.
As per my new requirement, I have got Ilitek touch screen which I am trying get it working with my Wandboard dual (i.MX6-Cortex-A9, Linux Kernel:3.0.35).
I got following Ilitek touch screen driver files under folder ilitek_limv3_0_9.
ilitek_lim.c
ilitek.h
ilitek_update.c
ilitek_i2c.idc
I compiled the driver into Linux kerenl as a built-in module, tried to run on the board but failed. The driver doesn't appear in /dev/input.
I debuged the kerenl code a bit, and found that the code doesn't reach to driver's probe function, instead it fails in device binding (i2c device registration). Just then I come to know about Device tree.
I looked into following dts files (which I believe my Wandboard is using), putting little i2c configuration present in the files here.
imx6qdl.dtsi
i2c1: i2c#021a0000 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "fsl,imx6q-i2c", "fsl,imx21-i2c";
reg = <0x021a0000 0x4000>;
interrupts = <0 36 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clks IMX6QDL_CLK_I2C1>;
status = "disabled";
};
i2c2: i2c#021a4000 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "fsl,imx6q-i2c", "fsl,imx21-i2c";
reg = <0x021a4000 0x4000>;
interrupts = <0 37 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clks IMX6QDL_CLK_I2C2>;
status = "disabled";
};
i2c3: i2c#021a8000 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "fsl,imx6q-i2c", "fsl,imx21-i2c";
reg = <0x021a8000 0x4000>;
interrupts = <0 38 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clks IMX6QDL_CLK_I2C3>;
status = "disabled";
};
imx6qdl-wandboard.dtsi
&hdmi {
ddc-i2c-bus = <&i2c1>;
status = "okay";
};
&i2c1 {
clock-frequency = <100000>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_i2c1>;
status = "okay";
};
&i2c2 {
clock-frequency = <100000>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_i2c2>;
status = "okay";
codec: sgtl5000#0a {
compatible = "fsl,sgtl5000";
reg = <0x0a>;
clocks = <&clks 201>;
VDDA-supply = <&reg_2p5v>;
VDDIO-supply = <&reg_3p3v>;
};
};
I see dts note entry for sgtl5000 which is audio codec which then appears as /dev/input/event0. But I don't find any entry for 'prism' driver, which actually runs perfectly on the board. Neither dts files nor board-files have entry for 'prism' driver. But I am sure it's using 'device-tree' approach.
Questions
As my Wandboard works fine with 'prism' driver and touch device, why I don't see device node entry for 'prism' in dts files ?
Is there any other way for 'i2c device registration' other than 'device-tree' and 'earlier board-file' approach ?
How could I get past with ilitek touch driver not getting i2c-matched/registered problem ?
Thanks in advance.

Adding entry for an i2c device connected on i2c mux in linux device tree

I am using freescale powerpc 85xx processor with linux 2.6.32.
The i2c subsytem is mapped at address 0x03000 inside the ccsr registers. I want to add an RTC device,DS1338 (i2c addr: 0x68) connected to an I2c mux (address: 0x76) on channel 5 (selected by writing 0xfd on control register).
Without adding the device in the dts file, the rtc device won't bind to driver.
I have the following entry in my device tree right now:
i2c#3000 { /* I2C 1 */
#address-cells = <1>;
#size-cells = <0>;
cell-index = <0>;
compatible = "fsl-i2c";
reg = <0x3000 0x100>;
interrupts = <43 2>;
interrupt-parent = <&mpic>;
dfsrr;
};
What would it look like after adding the above information. Had it been a device directly on the i2c bus and not through mux, I would have added something like this:
i2c#3000 { /* I2C 1 */
#address-cells = <1>;
#size-cells = <0>;
cell-index = <0>;
compatible = "fsl-i2c";
reg = <0x3000 0x100>;
interrupts = <43 2>;
interrupt-parent = <&mpic>;
rtc:rtc#68 {
compatible = "dallas,ds1307";
reg = <0x68>;
};
dfsrr;
};
Now with the mux in the path, and having to select channel, I don't think I know how to make an entry.

Resources