* Converting "board file" to device tree one device at a time?
@ 2015-07-31 9:57 ` Mason
0 siblings, 0 replies; 10+ messages in thread
From: Mason @ 2015-07-31 9:57 UTC (permalink / raw)
To: linux-arm-kernel
Hello,
I'm using an ARM Cortex A9 based platform. I have a minimal
3.14 port working (UART and Ethernet, loads a root file system
over NFS) using a board file.
I'm trying to convert the port to device tree, so that I can
(try to) push it upstream.
As I can't wrap my head around the concept, I'm trying to do
the conversion "one device at a time", starting with just the
UART, then Ethernet, then the clock tree, and that's basically
all I need to boot the board.
I started by enabling
CONFIG_ARM_APPENDED_DTB=y
CONFIG_ARM_ATAG_DTB_COMPAT=y
CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_FROM_BOOTLOADER=y
CONFIG_SERIAL_OF_PLATFORM=y
and wrote this dts:
/dts-v1/;
/ {
compatible = "sigma,tango4-soc";
#address-cells = <1>;
#size-cells = <1>;
soc {
compatible = "simple-bus";
#address-cells = <1>;
#size-cells = <1>;
ranges;
uart0: serial at 10700 {
compatible = "ns16550a";
reg = <0x10700 0x100>;
interrupts = <1>;
clock-frequency = <7372800>;
reg-shift = <2>;
no-loopback-test;
#address-cells = <1>;
#size-cells = <1>;
};
};
};
and added "sigma,tango4-soc" to my struct machine_desc .dt_compat
Then I generated a kernel with appended DT using:
$ make dtbs
$ make -j2 zImage && cat arch/arm/boot/zImage arch/arm/boot/dts/tango.dtb >XXX
$ mv XXX arch/arm/boot/zImage && make uImage
Then I set a breakpoint in of_platform_serial_probe, hoping
to witness the miracle... and nothing. Looks like device is
never registered :-(
Can anyone point me where to look?
What did I do wrong?
Where does the kernel parse the appended DTB?
Is it setup_machine_fdt?
When/Where is the UART description in the device tree supposed
to be used to register the device?
Any help greatly appreciated!
Regards.
^ permalink raw reply [flat|nested] 10+ messages in thread* Converting "board file" to device tree one device at a time? @ 2015-07-31 9:57 ` Mason 0 siblings, 0 replies; 10+ messages in thread From: Mason @ 2015-07-31 9:57 UTC (permalink / raw) To: DT; +Cc: Linux ARM, Grant Likely, Rob Herring Hello, I'm using an ARM Cortex A9 based platform. I have a minimal 3.14 port working (UART and Ethernet, loads a root file system over NFS) using a board file. I'm trying to convert the port to device tree, so that I can (try to) push it upstream. As I can't wrap my head around the concept, I'm trying to do the conversion "one device at a time", starting with just the UART, then Ethernet, then the clock tree, and that's basically all I need to boot the board. I started by enabling CONFIG_ARM_APPENDED_DTB=y CONFIG_ARM_ATAG_DTB_COMPAT=y CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_FROM_BOOTLOADER=y CONFIG_SERIAL_OF_PLATFORM=y and wrote this dts: /dts-v1/; / { compatible = "sigma,tango4-soc"; #address-cells = <1>; #size-cells = <1>; soc { compatible = "simple-bus"; #address-cells = <1>; #size-cells = <1>; ranges; uart0: serial@10700 { compatible = "ns16550a"; reg = <0x10700 0x100>; interrupts = <1>; clock-frequency = <7372800>; reg-shift = <2>; no-loopback-test; #address-cells = <1>; #size-cells = <1>; }; }; }; and added "sigma,tango4-soc" to my struct machine_desc .dt_compat Then I generated a kernel with appended DT using: $ make dtbs $ make -j2 zImage && cat arch/arm/boot/zImage arch/arm/boot/dts/tango.dtb >XXX $ mv XXX arch/arm/boot/zImage && make uImage Then I set a breakpoint in of_platform_serial_probe, hoping to witness the miracle... and nothing. Looks like device is never registered :-( Can anyone point me where to look? What did I do wrong? Where does the kernel parse the appended DTB? Is it setup_machine_fdt? When/Where is the UART description in the device tree supposed to be used to register the device? Any help greatly appreciated! Regards. -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 10+ messages in thread
* Converting "board file" to device tree one device at a time? @ 2015-07-31 14:54 ` Mason 0 siblings, 0 replies; 10+ messages in thread From: Mason @ 2015-07-31 14:54 UTC (permalink / raw) To: linux-arm-kernel On 31/07/2015 11:57, Mason wrote: > Then I set a breakpoint in of_platform_serial_probe, hoping > to witness the miracle... and nothing. Looks like device is > never registered :-( IIUC, the kernel is supposed to parse my "uart0" node, and register the device. Then the platform framework should see that the node's "compatible" property is equal to one advertized by the of_platform_serial_driver, and the kernel should #!@& call of_platform_serial_probe? Right?! I just can't believe how much time I've been pulling my hair over this trivial issue... Regards. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Converting "board file" to device tree one device at a time? @ 2015-07-31 14:54 ` Mason 0 siblings, 0 replies; 10+ messages in thread From: Mason @ 2015-07-31 14:54 UTC (permalink / raw) To: DT; +Cc: Linux ARM, Grant Likely, Rob Herring On 31/07/2015 11:57, Mason wrote: > Then I set a breakpoint in of_platform_serial_probe, hoping > to witness the miracle... and nothing. Looks like device is > never registered :-( IIUC, the kernel is supposed to parse my "uart0" node, and register the device. Then the platform framework should see that the node's "compatible" property is equal to one advertized by the of_platform_serial_driver, and the kernel should #!@& call of_platform_serial_probe? Right?! I just can't believe how much time I've been pulling my hair over this trivial issue... Regards. -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 10+ messages in thread
* Converting "board file" to device tree one device at a time? @ 2015-07-31 15:05 ` Russell King - ARM Linux 0 siblings, 0 replies; 10+ messages in thread From: Russell King - ARM Linux @ 2015-07-31 15:05 UTC (permalink / raw) To: linux-arm-kernel On Fri, Jul 31, 2015 at 04:54:00PM +0200, Mason wrote: > On 31/07/2015 11:57, Mason wrote: > > > Then I set a breakpoint in of_platform_serial_probe, hoping > > to witness the miracle... and nothing. Looks like device is > > never registered :-( > > IIUC, the kernel is supposed to parse my "uart0" node, and > register the device. Then the platform framework should see > that the node's "compatible" property is equal to one > advertized by the of_platform_serial_driver, and the kernel > should #!@& call of_platform_serial_probe? Right?! No, it doesn't work like that. The kernel creates platform devices from the nodes described in the DT file, which are then used to bind to the drivers in a very similar way to non-DT, except that if there's an dev->of_node pointer present, the compatible property is used. If there are no devices being created from DT, drivers won't have anything to bind to. > I just can't believe how much time I've been pulling my hair > over this trivial issue... My /guess/ is that you have an .init_machine callback in place, but that is not calling of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); which means none of the DT-described devices are being created. -- FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up according to speedtest.net. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Converting "board file" to device tree one device at a time? @ 2015-07-31 15:05 ` Russell King - ARM Linux 0 siblings, 0 replies; 10+ messages in thread From: Russell King - ARM Linux @ 2015-07-31 15:05 UTC (permalink / raw) To: Mason; +Cc: DT, Grant Likely, Rob Herring, Linux ARM On Fri, Jul 31, 2015 at 04:54:00PM +0200, Mason wrote: > On 31/07/2015 11:57, Mason wrote: > > > Then I set a breakpoint in of_platform_serial_probe, hoping > > to witness the miracle... and nothing. Looks like device is > > never registered :-( > > IIUC, the kernel is supposed to parse my "uart0" node, and > register the device. Then the platform framework should see > that the node's "compatible" property is equal to one > advertized by the of_platform_serial_driver, and the kernel > should #!@& call of_platform_serial_probe? Right?! No, it doesn't work like that. The kernel creates platform devices from the nodes described in the DT file, which are then used to bind to the drivers in a very similar way to non-DT, except that if there's an dev->of_node pointer present, the compatible property is used. If there are no devices being created from DT, drivers won't have anything to bind to. > I just can't believe how much time I've been pulling my hair > over this trivial issue... My /guess/ is that you have an .init_machine callback in place, but that is not calling of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); which means none of the DT-described devices are being created. -- FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up according to speedtest.net. -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 10+ messages in thread
* Converting "board file" to device tree one device at a time? @ 2015-07-31 15:13 ` Mason 0 siblings, 0 replies; 10+ messages in thread From: Mason @ 2015-07-31 15:13 UTC (permalink / raw) To: linux-arm-kernel On 31/07/2015 17:05, Russell King - ARM Linux wrote: > On Fri, Jul 31, 2015 at 04:54:00PM +0200, Mason wrote: >> On 31/07/2015 11:57, Mason wrote: >> >>> Then I set a breakpoint in of_platform_serial_probe, hoping >>> to witness the miracle... and nothing. Looks like device is >>> never registered :-( >> >> IIUC, the kernel is supposed to parse my "uart0" node, and >> register the device. Then the platform framework should see >> that the node's "compatible" property is equal to one >> advertized by the of_platform_serial_driver, and the kernel >> should #!@& call of_platform_serial_probe? Right?! > > No, it doesn't work like that. The kernel creates platform devices > from the nodes described in the DT file, which are then used to bind > to the drivers in a very similar way to non-DT, except that if there's > an dev->of_node pointer present, the compatible property is used. If > there are no devices being created from DT, drivers won't have anything > to bind to. > >> I just can't believe how much time I've been pulling my hair >> over this trivial issue... > > My /guess/ is that you have an .init_machine callback in place, but that > is not calling of_platform_populate(NULL, of_default_bus_match_table, > NULL, NULL); which means none of the DT-described devices are being > created. You are my savior. Yes, I've read 5 bazillion OF/FDT tutorials/overviews, and I managed to miss of_platform_populate. You have just saved this desk from one more week of head-banging. Thanks again! Regards. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Converting "board file" to device tree one device at a time? @ 2015-07-31 15:13 ` Mason 0 siblings, 0 replies; 10+ messages in thread From: Mason @ 2015-07-31 15:13 UTC (permalink / raw) To: Russell King - ARM Linux; +Cc: DT, Grant Likely, Rob Herring, Linux ARM On 31/07/2015 17:05, Russell King - ARM Linux wrote: > On Fri, Jul 31, 2015 at 04:54:00PM +0200, Mason wrote: >> On 31/07/2015 11:57, Mason wrote: >> >>> Then I set a breakpoint in of_platform_serial_probe, hoping >>> to witness the miracle... and nothing. Looks like device is >>> never registered :-( >> >> IIUC, the kernel is supposed to parse my "uart0" node, and >> register the device. Then the platform framework should see >> that the node's "compatible" property is equal to one >> advertized by the of_platform_serial_driver, and the kernel >> should #!@& call of_platform_serial_probe? Right?! > > No, it doesn't work like that. The kernel creates platform devices > from the nodes described in the DT file, which are then used to bind > to the drivers in a very similar way to non-DT, except that if there's > an dev->of_node pointer present, the compatible property is used. If > there are no devices being created from DT, drivers won't have anything > to bind to. > >> I just can't believe how much time I've been pulling my hair >> over this trivial issue... > > My /guess/ is that you have an .init_machine callback in place, but that > is not calling of_platform_populate(NULL, of_default_bus_match_table, > NULL, NULL); which means none of the DT-described devices are being > created. You are my savior. Yes, I've read 5 bazillion OF/FDT tutorials/overviews, and I managed to miss of_platform_populate. You have just saved this desk from one more week of head-banging. Thanks again! Regards. -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 10+ messages in thread
* Converting "board file" to device tree one device at a time? 2015-07-31 15:05 ` Russell King - ARM Linux (?) (?) @ 2015-07-31 16:17 ` Mason 2015-07-31 16:46 ` Russell King - ARM Linux -1 siblings, 1 reply; 10+ messages in thread From: Mason @ 2015-07-31 16:17 UTC (permalink / raw) To: linux-arm-kernel On 31/07/2015 17:05, Russell King - ARM Linux wrote: > My /guess/ is that you have an .init_machine callback in place, but that > is not calling of_platform_populate(NULL, of_default_bus_match_table, > NULL, NULL); which means none of the DT-described devices are being > created. You guessed right. Thanks again! One more question, if I may. I deleted the .init_machine callback, but the board init function was still being called! MACHINE_START(TANGOX_87XX, "TANGOX_87XX") ... //.init_machine = tangox_87xx_board_init, MACHINE_END I suspected it might be called directly from elsewhere, and launched grep: arch_initcall(tangox_init_devices); I suppose the arch_initcall macro registers the function to be called at some point during init? Then this means that, before I commented the .init_machine callback, the function was being called twice? Once through .init_machine and once through arch_initcall? Regards. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Converting "board file" to device tree one device at a time? 2015-07-31 16:17 ` Mason @ 2015-07-31 16:46 ` Russell King - ARM Linux 0 siblings, 0 replies; 10+ messages in thread From: Russell King - ARM Linux @ 2015-07-31 16:46 UTC (permalink / raw) To: linux-arm-kernel On Fri, Jul 31, 2015 at 06:17:11PM +0200, Mason wrote: > On 31/07/2015 17:05, Russell King - ARM Linux wrote: > > > My /guess/ is that you have an .init_machine callback in place, but that > > is not calling of_platform_populate(NULL, of_default_bus_match_table, > > NULL, NULL); which means none of the DT-described devices are being > > created. > > You guessed right. Thanks again! > > One more question, if I may. > > I deleted the .init_machine callback, but the board init > function was still being called! > > MACHINE_START(TANGOX_87XX, "TANGOX_87XX") > ... > //.init_machine = tangox_87xx_board_init, > MACHINE_END > > I suspected it might be called directly from elsewhere, > and launched grep: > > arch_initcall(tangox_init_devices); Looks like different function names to me. Not being able to see the code you're modifying means I can't comment. -- FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up according to speedtest.net. ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2015-07-31 16:46 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-07-31 9:57 Converting "board file" to device tree one device at a time? Mason 2015-07-31 9:57 ` Mason 2015-07-31 14:54 ` Mason 2015-07-31 14:54 ` Mason 2015-07-31 15:05 ` Russell King - ARM Linux 2015-07-31 15:05 ` Russell King - ARM Linux 2015-07-31 15:13 ` Mason 2015-07-31 15:13 ` Mason 2015-07-31 16:17 ` Mason 2015-07-31 16:46 ` Russell King - ARM Linux
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.